Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLSL abs() broken?

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?

like image 785
dupersuper Avatar asked Nov 11 '12 21:11

dupersuper


1 Answers

Abs() start to support integers at 1.30 and doubles at 4.10 version. Might be an unobvious problem with versions and types. try to debug with floats instead of ints. If that does not help than isolate and debug abs() via screen-space shader and use it output as fragment color.

like image 178
JAre Avatar answered Oct 24 '22 05:10

JAre