feat: add toggleable wireframe layer

A fourth layer draws the icosphere as a wireframe, displaced by the
same relief and rendered as bright unlit colormap lines just above
the skin. Toggled with key 4.
This commit is contained in:
L'électron rare
2026-05-18 18:43:31 +02:00
parent 7fc4f41f4e
commit 914e52deaf
6 changed files with 21 additions and 0 deletions
@@ -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);
@@ -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);
+8
View File
@@ -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();
}
+1
View File
@@ -19,6 +19,7 @@ public:
void drawSkin();
void drawPoints();
void drawWireframe();
void setColormap(int id) { colormapId_ = id; }
private:
+3
View File
@@ -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;
+1
View File
@@ -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;