diff --git a/zonebb/bin/data/shaders/main.frag b/zonebb/bin/data/shaders/main.frag index ee4cac1..12486e3 100644 --- a/zonebb/bin/data/shaders/main.frag +++ b/zonebb/bin/data/shaders/main.frag @@ -8,6 +8,11 @@ uniform sampler2DRect uV4l2cam; uniform sampler2DRect u_buffer0; uniform sampler2DRect u_buffer1; +uniform sampler2DRect u_warm1; +uniform sampler2DRect u_warm2; +uniform sampler2DRect u_cold1; +uniform sampler2DRect u_cold2; + uniform bool uCalib; uniform vec2 uCalibXY; uniform float uCalibScale; @@ -150,10 +155,17 @@ void main() { gl_FragColor = depth + v4l2; } else { - // vec4 bufColor = texture(u_buffer1, st); - vec4 color = vec4(st/1000,1,1); + vec4 color; color = texture(uFluid, st); + vec2 palette = vec2(color.r*3425, 1); + vec3 remapedColorW = texture(u_warm1, palette).xyz; + vec3 remapedColorC = texture(u_cold2, palette).xyz; + + // vec4 bufColor = texture(u_buffer1, st); + color.rgb = remapedColorW; + // color.rg = palette.st; + gl_FragColor = color; } #endif diff --git a/zonebb/src/ofApp.cpp b/zonebb/src/ofApp.cpp index d006fd1..fa1d182 100644 --- a/zonebb/src/ofApp.cpp +++ b/zonebb/src/ofApp.cpp @@ -135,6 +135,12 @@ void ofApp::setup() fbos.insert({s, ofFbo()}); fbos.at(s).allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB); } + + for (auto s : gradientNames) + { + gradients.insert({s, ofFloatImage()}); + gradients.at(s).load("images/" + s + ".png"); + } } ofVec3f ofApp::getDepthAt(int x, int y) @@ -239,7 +245,7 @@ void ofApp::updateFluid() oldM = m; ofPoint c = ofPoint(640 * 0.5, 480 * 0.5) - m; c.normalize(); - fluid.addTemporalForce(toGlm(m), toGlm(d), ofFloatColor(0,0,0), 15.0f, 20); + fluid.addTemporalForce(toGlm(m), toGlm(d), ofFloatColor(0, 0, 0), 15.0f, 20); // Update // @@ -295,6 +301,15 @@ void ofApp::drawMain() mainShader.setUniform2f("uCalibXY", registrationXY); mainShader.setUniform1f("uCalibScale", registrationScale); + // for (int i = 0; i < gradientNames.size(); i++) + // { + // mainShader.setUniformTexture("u_" + gradientNames.at(i), gradients.at(gradientNames.at(i))); + // } + mainShader.setUniformTexture("u_warm1", gradients.at("warm1")); + mainShader.setUniformTexture("u_warm2", gradients.at("warm2")); + mainShader.setUniformTexture("u_cold1", gradients.at("cold1")); + mainShader.setUniformTexture("u_cold2", gradients.at("cold2")); + mainShader.setUniformTexture("uFluid", fbos.at("fluid")); mainShader.render(); mainShader.draw(0, 0);