diff --git a/zoneb/bin/data/gradient.png b/zoneb/bin/data/gradient.png new file mode 100644 index 0000000..c425900 Binary files /dev/null and b/zoneb/bin/data/gradient.png differ diff --git a/zoneb/bin/data/shaders/render.frag b/zoneb/bin/data/shaders/render.frag index 4cd307c..9008a1f 100644 --- a/zoneb/bin/data/shaders/render.frag +++ b/zoneb/bin/data/shaders/render.frag @@ -6,6 +6,7 @@ precision mediump float; uniform sampler2D uColorTex; // Sampler for the color registered data uniform sampler2D u_v4l2cam; +uniform sampler2D u_gradient; in vec2 gTexCoord; @@ -18,7 +19,8 @@ void main() st += vec2(0.5); st.s += 0.15; st.t += 0.16; - gl_FragColor = texture2D(u_v4l2cam, st); + float thermo = texture2D(u_v4l2cam, st).r; + gl_FragColor = vec4(texture2D(u_gradient, vec2(thermo, 0.5)).rgb, 1); // gl_FragColor = texture2D(uColorTex, gTexCoord); // gl_FragColor = vec4(1); } \ No newline at end of file diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index 2b5cd23..2833a29 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -68,6 +68,8 @@ void ofApp::setup() // we use a texture because the ofxV4L2 class has no draw method (yet) // we use GL_LUMINANCE because the ofxV4L2 class supports only grayscale (for now) v4l2Tex.allocate(camWidth, camHeight, GL_LUMINANCE); + + gradient.load("gradient.png"); } //-------------------------------------------------------------- @@ -121,6 +123,7 @@ void ofApp::draw() shader.setUniformTexture("uWorldTex", kinectDevice.getColorToWorldTex(), 2); shader.setUniformTexture("uColorTex", kinectDevice.getColorTex(), 3); shader.setUniformTexture("u_v4l2cam", v4l2Tex, 4); + shader.setUniformTexture("u_gradient", gradient, 5); shader.setUniform2i("uFrameSize", kinectDevice.getColorTex().getWidth(), kinectDevice.getColorTex().getHeight()); shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthInColorTex().getWidth(), kinectDevice.getDepthInColorTex().getHeight()); @@ -132,6 +135,7 @@ void ofApp::draw() shader.setUniformTexture("uWorldTex", kinectDevice.getDepthToWorldTex(), 2); shader.setUniformTexture("uColorTex", kinectDevice.getColorInDepthTex(), 3); shader.setUniformTexture("u_v4l2cam", v4l2Tex, 4); + shader.setUniformTexture("u_gradient", gradient, 5); shader.setUniform2i("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); @@ -149,6 +153,7 @@ void ofApp::draw() boundShader.setUniformTexture("u_depth", tex); boundShader.setUniformTexture("u_ofcam", fbos.at("ofcam")); boundShader.setUniformTexture("u_v4l2cam", v4l2Tex); + boundShader.setUniformTexture("u_gradient", gradient); boundShader.setUniform1i("u_init", 1); boundShader.render(); boundShader.setUniform1i("u_init", 0); diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index b4cd475..03b4596 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -43,4 +43,6 @@ private: bool useColorSpace; ofxV4L2 v4l2Cam; ofTexture v4l2Tex; + + ofImage gradient; };