Hi I’m new to this board. I’ve tried searching the forum for previous post about this topic but can’t seem to find any.
here’s my problem, I have a pink background bmp file and I’ve set the alpha to 0 for those pink pixels, now major pink parts are gone but there appears to have a slight pink edge.
thanks!
but i’m still wondering, isn’t the pink edge caused by blending? so shouldn’t i be able to eliminate it by disabling blending? (i don’t mind the cut edges)
but when i tried that i got an even thicker pink outline…
No, it appears because of the bilinear filtering. Filtering works by sampling neighbooring texels and averaging them. As a result, if you only specify texels with an alpha of 0 (transparent) and 1 (opaque), you can still end up with pixels in the [0-1] range. Near the pink contour, you can have a pixel with 0.2 alpha (which passes the alpha test), but that’s still an average of a few pink texels and a few opaque texels… this leads to pink halos around your objects.
You can disable filtering, or replace the transparent pink texels with the closest opaque texels, as JustHanging suggests.
You might want to use only alpha testing, not alphablending, which is slower.
So, use something like:
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
(and remove the blending part)