Permalink
Browse files

fixed video and cam colorization in case of greenscreen use

  • Loading branch information...
1 parent 4efd9c1 commit 71324b31575aaba6f9ae40d2ee8864a3c7865ca6 @hvfrancesco committed Apr 10, 2012
Showing with 39 additions and 15 deletions.
  1. +21 −15 bin/data/shaders/chroma.frag
  2. +6 −0 lpmt.cbp
  3. +12 −0 src/quad.cpp
@@ -1,26 +1,32 @@
//#extension GL_ARB_texture_rectangle : enable
-
-uniform sampler2DRect tex;
-uniform float greenscreenR;
-uniform float greenscreenG;
-uniform float greenscreenB;
+
+uniform sampler2DRect tex;
+uniform float greenscreenR;
+uniform float greenscreenG;
+uniform float greenscreenB;
uniform float greenscreenT;
+uniform float tintR;
+uniform float tintG;
+uniform float tintB;
float factor;
-
+
vec4 color;
-
+
void main( void )
-
-{
- //vec2 xy = gl_TexCoord[0].xy;
- //vec4 sample = texture2DRect(tex, xy );
+
+{
+ //vec2 xy = gl_TexCoord[0].xy;
+ //vec4 sample = texture2DRect(tex, xy );
vec4 col = texture2DRect(tex,gl_TexCoord[0].st);
vec4 nullo = vec4(0.0,0.0,0.0,0.0);
- //gl_FragColor = sample;
- if((abs(col.x-greenscreenR) < greenscreenT) && (abs(col.y-greenscreenG) < greenscreenT) && (abs(col.z-greenscreenB) < greenscreenT)) {
+ //gl_FragColor = sample;
+ if((abs(col.x-greenscreenR) < greenscreenT) && (abs(col.y-greenscreenG) < greenscreenT) && (abs(col.z-greenscreenB) < greenscreenT)) {
//gl_FragColor.a = 0.0;
- factor = 1.0;
+ factor = 1.0;
}
else {factor=0.0;}
- gl_FragColor = mix(col, nullo, factor);
+ col.x = col.x*tintR;
+ col.y = col.y*tintG;
+ col.z = col.z*tintB;
+ gl_FragColor = mix(col, nullo, factor);
}
View
@@ -231,6 +231,12 @@
<Unit filename="bin/data/shaders/blend.vert">
<Option virtualFolder="shaders/" />
</Unit>
+ <Unit filename="bin/data/shaders/chroma.frag">
+ <Option virtualFolder="shaders/" />
+ </Unit>
+ <Unit filename="bin/data/shaders/chroma.vert">
+ <Option virtualFolder="shaders/" />
+ </Unit>
<Unit filename="bin/data/shaders/mask.frag">
<Option virtualFolder="shaders/" />
</Unit>
View
@@ -500,6 +500,10 @@ void quad::draw()
greenscreenShader->setUniform1f("greenscreenR", colorGreenscreen.r);
greenscreenShader->setUniform1f("greenscreenG", colorGreenscreen.g);
greenscreenShader->setUniform1f("greenscreenB", colorGreenscreen.b);
+ // we pass tint values too
+ greenscreenShader->setUniform1f("tintR", videoColorize.r);
+ greenscreenShader->setUniform1f("tintG", videoColorize.g);
+ greenscreenShader->setUniform1f("tintB", videoColorize.b);
greenscreenShader->setUniform1f("greenscreenT", (float)thresholdGreenscreen/255.0);
video.draw(0,0,videoWidth*videoMultX, videoHeight*videoMultY);
greenscreenShader->end();
@@ -519,6 +523,10 @@ void quad::draw()
greenscreenShader->setUniform1f("greenscreenR", colorGreenscreen.r);
greenscreenShader->setUniform1f("greenscreenG", colorGreenscreen.g);
greenscreenShader->setUniform1f("greenscreenB", colorGreenscreen.b);
+ // we pass tint values too
+ greenscreenShader->setUniform1f("tintR", videoColorize.r);
+ greenscreenShader->setUniform1f("tintG", videoColorize.g);
+ greenscreenShader->setUniform1f("tintB", videoColorize.b);
greenscreenShader->setUniform1f("greenscreenT", (float)thresholdGreenscreen/255.0);
video.draw(0,0,videoWidth*videoMultX, videoHeight*videoMultY);
greenscreenShader->end();
@@ -566,6 +574,10 @@ void quad::draw()
greenscreenShader->setUniform1f("greenscreenR", colorGreenscreen.r);
greenscreenShader->setUniform1f("greenscreenG", colorGreenscreen.g);
greenscreenShader->setUniform1f("greenscreenB", colorGreenscreen.b);
+ // we pass tint values too
+ greenscreenShader->setUniform1f("tintR", camColorize.r);
+ greenscreenShader->setUniform1f("tintG", camColorize.g);
+ greenscreenShader->setUniform1f("tintB", camColorize.b);
greenscreenShader->setUniform1f("greenscreenT", (float)thresholdGreenscreen/255.0);
cams[camNumber].getTextureReference().draw(0,0,camWidth*camMultX,camHeight*camMultY);
greenscreenShader->end();

0 comments on commit 71324b3

Please sign in to comment.