color remapping

This commit is contained in:
micuat 2020-10-19 17:03:34 +02:00
parent 34dfbdd390
commit 4aa1d62480
4 changed files with 10 additions and 1 deletions

BIN
zoneb/bin/data/gradient.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View file

@ -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);
}

View file

@ -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);

View file

@ -43,4 +43,6 @@ private:
bool useColorSpace;
ofxV4L2 v4l2Cam;
ofTexture v4l2Tex;
ofImage gradient;
};