AnsweredAssumed Answered

strange "if" behaviour in fragment shaders

Question asked by nilsk on Oct 25, 2012
Latest reply on Oct 25, 2012 by gsellers

I was trying to do a simple stipple pattern in a glsl fragment shader via

doesn't work

ivec2 pixel = ivec2(gl_FragCoord.xy);

if( ((pixel.x+pixel.y)%2)) discard;

but this doesn't discard any fragments at all. The silly thing is that if I add a not it works as expected. It also works if I explicitly convert the expression in the if clause to a bool.

does work

ivec2 pixel = ivec2(gl_FragCoord.xy);

if( !((pixel.x+pixel.y)%2)) discard;

//if( bool((pixel.x+pixel.y)%2)) discard;//works too

This happens pretty much in any shader I tried regardless of the other GL-state.


Os: Windows 7 64

Graphics Chipset    ATI Radeon HD 5800 Series

Device ID    6898

Driver Packaging Version    8.982-120727a-145524C-ATI

Catalyst Version: 12.8

OpenGL Version: