diff --git a/oscope-sphere/bin/data/shaders/sphere.frag b/oscope-sphere/bin/data/shaders/sphere.frag index dc9a2d3..505ba63 100644 --- a/oscope-sphere/bin/data/shaders/sphere.frag +++ b/oscope-sphere/bin/data/shaders/sphere.frag @@ -3,6 +3,7 @@ uniform sampler2D spectroTex; // width = time, height = freq, R32F [0,1] uniform float scrollOffset; uniform int colormapId; +uniform int renderMode; // 0 = skin, 1 = points in vec2 vSphereUV; out vec4 fragColor; @@ -33,5 +34,9 @@ void main() { float u = fract(vSphereUV.x - scrollOffset); float mag = clamp(texture(spectroTex, vec2(u, vSphereUV.y)).r, 0.0, 1.0); vec3 col = (colormapId == 0) ? magma(mag) : viridis(mag); + if (renderMode == 1) { + vec2 d = gl_PointCoord - vec2(0.5); + if (dot(d, d) > 0.25) discard; // round the points + } fragColor = vec4(col, 1.0); } diff --git a/oscope-sphere/bin/data/shaders/sphere.vert b/oscope-sphere/bin/data/shaders/sphere.vert index 437ad55..87b407b 100644 --- a/oscope-sphere/bin/data/shaders/sphere.vert +++ b/oscope-sphere/bin/data/shaders/sphere.vert @@ -4,6 +4,7 @@ uniform mat4 modelViewProjectionMatrix; uniform sampler2D waveformTex; // width = samples, height = 2 (row0 CH1, row1 CH2) uniform float displaceAmount; uniform float baseRadius; +uniform int renderMode; // 0 = skin, 1 = points in vec4 position; @@ -21,5 +22,8 @@ void main() { float r = baseRadius * (1.0 + displaceAmount * wave); 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 dc6de46..500a878 100644 --- a/oscope-sphere/src/SphereViz.cpp +++ b/oscope-sphere/src/SphereViz.cpp @@ -74,6 +74,20 @@ void SphereViz::drawSkin() { shader_.setUniform1f("displaceAmount", displace_); shader_.setUniform1f("baseRadius", baseRadius_); shader_.setUniform1i("colormapId", colormapId_); + shader_.setUniform1i("renderMode", 0); mesh_.draw(); shader_.end(); } + +void SphereViz::drawPoints() { + shader_.begin(); + shader_.setUniformTexture("spectroTex", spectroTex_, 0); + shader_.setUniformTexture("waveformTex", waveTex_, 1); + shader_.setUniform1f("scrollOffset", scrollOffset_); + shader_.setUniform1f("displaceAmount", displace_); + shader_.setUniform1f("baseRadius", baseRadius_); + shader_.setUniform1i("colormapId", colormapId_); + shader_.setUniform1i("renderMode", 1); + mesh_.drawVertices(); + shader_.end(); +} diff --git a/oscope-sphere/src/SphereViz.h b/oscope-sphere/src/SphereViz.h index 7fefbff..d3b8674 100644 --- a/oscope-sphere/src/SphereViz.h +++ b/oscope-sphere/src/SphereViz.h @@ -18,6 +18,7 @@ public: const std::vector& ch2); void drawSkin(); + void drawPoints(); void setColormap(int id) { colormapId_ = id; } private: diff --git a/oscope-sphere/src/ofApp.cpp b/oscope-sphere/src/ofApp.cpp index ef8b450..3708b9c 100644 --- a/oscope-sphere/src/ofApp.cpp +++ b/oscope-sphere/src/ofApp.cpp @@ -56,6 +56,7 @@ void ofApp::draw() { ofPushMatrix(); ofRotateYDeg(ofGetElapsedTimef() * 6.0f); if (layerA_) sphere_.drawSkin(); + if (layerC_) sphere_.drawPoints(); if (layerB_) rings_.draw(); ofPopMatrix(); cam_.end();