10
I'm making a Gaussian blur shader in GLSL. Since the convolution kernel is symmetrical, I store one half of it. I write:
vec3 glow = vec3(0.0);
for (int i = -WIDTH; i <= WIDTH; i++) {
uint j = abs(i);
glow += kernel[j] + texelFetch(u_glowTexture, coord + ivec2(i, 0), 0);
}
Strangely, this is drawing the blur slightly to the left of what it should be. But then I replace that third line with:
uint j = i * sign(i);
And now it's working like I expect. Have I broken abs()? Have I really found a driver bug?