Fragment shader problem, tex1-tex2

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.)


Can you post your textures setup right before you call your rendering routine?

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.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.