Hello, I'm trying to invert the colors for a single sprite and I can't seem to get it right. How do I receive the current pixel's color (from the sprite) in the shader? At first I tried gl_Color to no avail:
uniform bool invert;
void main()
{
if(invert)
gl_FragColor = vec4(255.0 - gl_Color.r, 255.0 - gl_Color.g, 255.0 - gl_Color.b, 1.0);
else
gl_FragColor = gl_Color;
}
I also tried another google-inspired solution:
uniform bool invert;
uniform sampler2D screenColorBuffer;
void main()
{
vec4 color = gl_TexCoord[0];
if(invert)
{
gl_FragColor = 1.0-texture2D(screenColorBuffer,gl_TexCoord[0].st);
gl_FragColor.a = 1.0;
}
else
gl_FragColor = color;
}
Maybe I'm just not sure what to search for... this GLSL stuff is impossible to sort out for some reason. Is there a certain variable I should use in this scenario?
Thanks