Hi,
I need to preface saying I know very little about glsl. Still, I’ve narrowed down a behavior which any of you glsl gurus should be able to spot - and advice - very easily.
I have a glsl top with a 1x1 constant top as input.
this is the fragment shader:
[code]uniform sampler2D sInput1;
uniform vec4 res1;
void main()
{
float stepx = 1.0/res1.x;
float stepy = 1.0/res1.y;
float xc = 0;
float yc = 0;
for(xc=0.0; xc <= 1; xc+=stepx) {
for(yc=0.0; yc <= 1; yc+=stepy) {
}
}
gl_FragColor = vec4(.1,.2,.3,1);
}
[/code]
don’t worry about the utility of those empty loops (there used to be more… - this is the test case)
basically the issue is that with the above, the output 1x1 image is not .1 .2 .3, but
0, .851, 0, .8784
(keep in mind everything compiles without errors).
but if I comment the inside loop (for y) then the resulting image is correct…
My naive thinking is that the loops should have NO effect on the output image since I’m setting gl_FragColor explicitly…
In an attempt at semplification, I’ve changed the loops to go from 0 to 10 step 1 (instead of using stepx and stepy) and… the output image was correct, without the need to comment out the internal y loop…
I’m lost… how is it possible that even though I set gl_FragColor explicitly, it changes depending on what code I have above it???
Is this my computer, a bug, or…is it me?
d
(btw res1 is a uniform with the first two fields set to 640 480)
(also btw then the image comes out with the “right” values, the values have a .002 precision error).