Jump to content
  • Advertisement
Sign in to follow this  
schupf

Tree (with alphatest) has black border

This topic is 2448 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!