From e33375f7ac8042ab161abb1c31a73ec124ce5105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=27=C3=A9lectron=20rare?= <108685187+electron-rare@users.noreply.github.com> Date: Mon, 18 May 2026 18:05:50 +0200 Subject: [PATCH] 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. --- oscope-sphere/bin/data/shaders/sphere.vert | 7 ++++--- oscope-sphere/src/SphereViz.cpp | 9 ++++++++- oscope-sphere/src/SphereViz.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/oscope-sphere/bin/data/shaders/sphere.vert b/oscope-sphere/bin/data/shaders/sphere.vert index 87b407b..d81568f 100644 --- a/oscope-sphere/bin/data/shaders/sphere.vert +++ b/oscope-sphere/bin/data/shaders/sphere.vert @@ -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); } diff --git a/oscope-sphere/src/SphereViz.cpp b/oscope-sphere/src/SphereViz.cpp index 89048c5..a0ffbc3 100644 --- a/oscope-sphere/src/SphereViz.cpp +++ b/oscope-sphere/src/SphereViz.cpp @@ -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(); } diff --git a/oscope-sphere/src/SphereViz.h b/oscope-sphere/src/SphereViz.h index a4a8811..eb77909 100644 --- a/oscope-sphere/src/SphereViz.h +++ b/oscope-sphere/src/SphereViz.h @@ -26,6 +26,7 @@ private: std::unique_ptr spectro_; ofVboMesh mesh_; + ofVboMesh pointsMesh_; ofShader shader_; ofTexture spectroTex_; ofTexture waveTex_;