diff --git a/oscope-sphere/bin/data/shaders/sphere.frag b/oscope-sphere/bin/data/shaders/sphere.frag index fb73cc3..e22ab9d 100644 --- a/oscope-sphere/bin/data/shaders/sphere.frag +++ b/oscope-sphere/bin/data/shaders/sphere.frag @@ -46,6 +46,12 @@ void main() { return; } + if (renderMode == 2) { + // wireframe: bright unlit colormap lines + fragColor = vec4(col * 1.4 + vec3(0.06), 1.0); + return; + } + // skin: light the displaced relief with a screen-space face normal vec3 N = normalize(cross(dFdx(vViewPos), dFdy(vViewPos))); vec3 V = normalize(-vViewPos); diff --git a/oscope-sphere/bin/data/shaders/sphere.vert b/oscope-sphere/bin/data/shaders/sphere.vert index 140fa99..caac742 100644 --- a/oscope-sphere/bin/data/shaders/sphere.vert +++ b/oscope-sphere/bin/data/shaders/sphere.vert @@ -34,6 +34,8 @@ void main() { if (renderMode == 1) { r *= 1.06; // float the point cloud outside the skin gl_PointSize = 6.0; + } else if (renderMode == 2) { + r *= 1.01; // wireframe sits just above the lit skin } vec4 viewPos = modelViewMatrix * vec4(dir * r, 1.0); diff --git a/oscope-sphere/src/SphereViz.cpp b/oscope-sphere/src/SphereViz.cpp index cc25d4d..cba09d6 100644 --- a/oscope-sphere/src/SphereViz.cpp +++ b/oscope-sphere/src/SphereViz.cpp @@ -98,3 +98,11 @@ void SphereViz::drawPoints() { pointsMesh_.draw(); shader_.end(); } + +void SphereViz::drawWireframe() { + shader_.begin(); + bindUniforms(); + shader_.setUniform1i("renderMode", 2); + mesh_.drawWireframe(); + shader_.end(); +} diff --git a/oscope-sphere/src/SphereViz.h b/oscope-sphere/src/SphereViz.h index 316f488..a0c6e69 100644 --- a/oscope-sphere/src/SphereViz.h +++ b/oscope-sphere/src/SphereViz.h @@ -19,6 +19,7 @@ public: void drawSkin(); void drawPoints(); + void drawWireframe(); void setColormap(int id) { colormapId_ = id; } private: diff --git a/oscope-sphere/src/ofApp.cpp b/oscope-sphere/src/ofApp.cpp index e591423..119a695 100644 --- a/oscope-sphere/src/ofApp.cpp +++ b/oscope-sphere/src/ofApp.cpp @@ -72,6 +72,7 @@ void ofApp::draw() { ofRotateXDeg(16.0f * std::sin(t * 0.27f)); // slow tumble ofScale(pulse_, pulse_, pulse_); // audio pulse if (layerA_) sphere_.drawSkin(); + if (layerD_) sphere_.drawWireframe(); if (layerC_) sphere_.drawPoints(); if (layerB_) rings_.draw(); ofPopMatrix(); @@ -86,6 +87,7 @@ void ofApp::drawHud() { hud += std::string("[1] skin ") + (layerA_ ? "on" : "off") + "\n"; hud += std::string("[2] rings ") + (layerB_ ? "on" : "off") + "\n"; hud += std::string("[3] points ") + (layerC_ ? "on" : "off") + "\n"; + hud += std::string("[4] wire ") + (layerD_ ? "on" : "off") + "\n"; hud += std::string("[c] colormap [space] ") + (frozen_ ? "frozen" : "live"); ofDrawBitmapString(hud, 16, 24); @@ -97,6 +99,7 @@ void ofApp::keyPressed(int key) { case '1': layerA_ = !layerA_; break; case '2': layerB_ = !layerB_; break; case '3': layerC_ = !layerC_; break; + case '4': layerD_ = !layerD_; break; case 'c': case 'C': colormap_ = (colormap_ + 1) % 2; break; case ' ': frozen_ = !frozen_; break; diff --git a/oscope-sphere/src/ofApp.h b/oscope-sphere/src/ofApp.h index e2d5c6d..c74a06d 100644 --- a/oscope-sphere/src/ofApp.h +++ b/oscope-sphere/src/ofApp.h @@ -35,6 +35,7 @@ private: bool layerA_ = true; bool layerB_ = true; bool layerC_ = true; + bool layerD_ = true; int colormap_ = 0; float scopeSr_ = 16.0e6f; float spin_ = 0.0f;