fix: render point cloud as real GL points

drawVertices on the indexed skin mesh gave a degenerate gl_PointCoord,
so the round-point discard killed every fragment. Use a dedicated
OF_PRIMITIVE_POINTS mesh, float it 5% outside the skin, enlarge points.
This commit is contained in:
L'électron rare
2026-05-18 18:05:50 +02:00
parent e06f53b11e
commit e33375f7ac
3 changed files with 13 additions and 4 deletions
+4 -3
View File
@@ -20,10 +20,11 @@ void main() {
float row = (dir.y >= 0.0) ? 0.25 : 0.75; // CH1 north, CH2 south
float wave = texture(waveformTex, vec2(lon, row)).r; // [-1,1]
float r = baseRadius * (1.0 + displaceAmount * wave);
if (renderMode == 1) {
r *= 1.05; // float the point cloud just outside the skin
gl_PointSize = 6.0;
}
gl_Position = modelViewProjectionMatrix * vec4(dir * r, 1.0);
if (renderMode == 1) {
gl_PointSize = 3.0;
}
vSphereUV = vec2(lon, lat);
}
+8 -1
View File
@@ -14,6 +14,13 @@ void SphereViz::setup(int icoIterations, int spectroWidth, int spectroHeight,
mesh_.addNormals(src.getNormals());
mesh_.addIndices(src.getIndices());
// A separate GL_POINTS-primitive mesh for layer C. drawVertices() on the
// indexed skin mesh does not yield a proper point primitive (gl_PointCoord
// ends up degenerate), so the point cloud needs its own points mesh.
pointsMesh_.clear();
pointsMesh_.setMode(OF_PRIMITIVE_POINTS);
pointsMesh_.addVertices(src.getVertices());
// ofDisableArbTex() is a global, app-wide GL state change: it makes all
// textures use normalized [0,1] coordinates. oscope-sphere has a single
// SphereViz so this is safe; revisit if other ARB-texture components are
@@ -87,6 +94,6 @@ void SphereViz::drawPoints() {
shader_.begin();
bindUniforms();
shader_.setUniform1i("renderMode", 1);
mesh_.drawVertices();
pointsMesh_.draw();
shader_.end();
}
+1
View File
@@ -26,6 +26,7 @@ private:
std::unique_ptr<oscope::SpectrogramBuffer> spectro_;
ofVboMesh mesh_;
ofVboMesh pointsMesh_;
ofShader shader_;
ofTexture spectroTex_;
ofTexture waveTex_;