0
votes

I'm learning GLSL with ES 2.0 and I'm trying to write a glow fragment shader.

This is what I have right now:

for(float x = startX; x < endX; x += w) {
    for(float y = startY; y < endY; y += h) {
        px = texture2D(u_texture, vec2(x, y));
        extra += px;
        count++;
    }
}
extra = clamp(extra / count, 0.0, 1.0);

The problem I'm getting is that I'm getting dark pixels near the edge of the texture. I believe it's because the pixel counts as (0.0, 0.0, 0.0, 0.0), which is a transparent black pixel, which darkens my image on the edges. Would it be possible to treat transparent pixels as white? Or is there a better way of implementing a glow?

Thanks!

1
Are you using premultiplied alpha?AshleysBrain
Ahh that was it. Should have known :<Xzhsh

1 Answers

1
votes

Looks like I was using premultiplied alpha. Switched to a normal texture and it worked fine

Sorry for the trouble!