Tree (with alphatest) has black border

Started by
0 comments, last by Erik Rufelt 12 years, 7 months ago
Hello,

I am rendering a tree in DX9, where the texture has an alpha channel to define where the leaves are visible. The alpha channel only stores values 0 and 1 and alpha blending is used to skip parts of the texture where alpha is 0.

When I render this tree it exposes black edges at the borders of the leaves. I am loading the texture with D3DXCreateTextureFromFile and I guess MipMapping is the reason for this black border artifact since disabling MipMap creation makes the black border disappear.

Has anyone an idea what could cause this black border? Could it really be MipMapping? If yes, how can I fix this?
Advertisement
When the mip-maps are created pixels are averaged, causing your 0s and 1s of alpha to turn into 0.5 0.25 0.75 etc.
If you image has black pixels where the alpha is 0 (which may seem natural as they should be discarded anyway), you can get problems like that. Try painting the rest of the texture with the same color as the border of the tree. If you use bilinear filtering this can become a problem even without mip-maps, so textures with alpha-masks are often painted that way.
There are tools that do it automatically for you, for example Photoshop plugins and similar.


(Found the following with Google)
This page seems to have a tutorial for Photoshop: http://www.robinwood.com/Catalog/Technical/SL-Tuts/SLPages/WhiteHalo2.html
It uses the free plugin available here (search for solidify): http://www.flamingpear.com/download.html

Here's another way that perhaps works without plugins: http://unity3d.com/support/documentation/Manual/HOWTO-alphamaps.html

This topic is closed to new replies.

Advertisement