Original Post
I'm having a very strange problem with my fragment shader. Let me show you what's working:
Things like this make the shader go hay-wire:
I just can't figure it out. By the way, my shader runs totally fine on windows, but on my macbook pro, this bizarre problem cropped up. Basically, I can't ever increment i, otherwise things just go nuts. What actually gets displayed on screen is nothing like what it should, even if all the rest of the shader is is simply gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);.
I'm at the end of my rope here... is there something about the shaders I should know about?
p.s.: one final thing, I add a #version 120 at the top of the shaders, and the windows and mac shader files are identical (everything is identical, the code it totally cross-platform).
// this works:
if (gl_LightSource[0].position.w >= 0.0)
att = 1.0;
if (gl_LightSource[1].position.w >= 0.0)
att = 1.0;
// so does this:
int i = 0;
if (gl_LightSource.position.w >= 0.0)
att = 1.0;
int j = 1;
if (gl_LightSource[j].position.w >= 0.0)
att = 1.0;
// no problems here either:
int i;
for (i=0; i<1; i++)
if (gl_LightSource.position.w >= 0.0)
att = 1.0;
for (i=1; i<2; i++)
if (gl_LightSource.position.w >= 0.0)
att = 1.0;
Things like this make the shader go hay-wire:
// shader goes bonkers:
int i;
for (i=0; i<2; i++)
if (gl_LightSource.position.w >= 0.0)
att = 1.0;
// shader goes bonkers with this, too:
int i = 0;
if (gl_LightSource.position.w >= 0.0)
att = 2.0;
int j = i + 1;
if (gl_LightSource[j].position.w >= 0.0)
att = 2.0;
I just can't figure it out. By the way, my shader runs totally fine on windows, but on my macbook pro, this bizarre problem cropped up. Basically, I can't ever increment i, otherwise things just go nuts. What actually gets displayed on screen is nothing like what it should, even if all the rest of the shader is is simply gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);.
I'm at the end of my rope here... is there something about the shaders I should know about?
p.s.: one final thing, I add a #version 120 at the top of the shaders, and the windows and mac shader files are identical (everything is identical, the code it totally cross-platform).