View Full Version : about trimming a texture

04-03-2003, 08:32 PM
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.

i've used the following function

glAlphaFunc(GL_GREATER, 0);

Can anyone tell me what my problem is?

04-03-2003, 09:15 PM
Set the new color values of all your pink texels to tha average of their adjacent non-pink texels. If there aren't any, just make the texel black.


04-04-2003, 05:50 AM
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...

please correct me if i'm wrong

04-04-2003, 06:11 AM
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.


04-04-2003, 12:21 PM
You might want to use only alpha testing, not alphablending, which is slower.
So, use something like:
glAlphaFunc(GL_GREATER, 0.1f);
(and remove the blending part)

04-06-2003, 10:27 AM
thanks alot!
that really helps!

[This message has been edited by dbsboy (edited 04-06-2003).]