View Full Version : fragment shader problem, tex1-tex2

07-04-2005, 08:41 AM
I wrote a very simple shader program which should subtract 2 textures:

uniform sampler2DRect vergleich;
uniform sampler2DRect fbo;

void main (void)
vec4 texcolor = textureRect( vergleich, gl_TexCoord[0].st );
vec4 texcolor2 = textureRect( fbo, gl_TexCoord[0].st );

vec4 color = texcolor - texcolor2;
gl_FragColor = color;
My problem is now that the result of this shader is equal to "texcolor".
If I write in gl_FragColor = texcolor2; I become the fbo texture. If I write gl_FragColor = texcolor; I become the vergleich texture which I become too if I write gl_FragColor = texcolor - texcolor2;.
So the textures are read right in the shader I don't know why the subtraction is ignored.
The fbo texture hast values from 0 to 255 and the vergleich from 0 to 4 so I wonder why I don't get some large negative values when I read my result. (It is rendered in an FBO Texture with float32 format.)


Java Cool Dude
07-04-2005, 11:37 PM
Can you post your textures setup right before you call your rendering routine?

07-06-2005, 11:41 PM
Hi, I solved my Problem. Was a silly mistake. One of the two textures was setup with a linear filter. so it seems that the shader ignored the subtraction between the different filters by 32bit float. After I changed both to a nearest filter now it works fine.