Jump to content
  • Advertisement
Sign in to follow this  
john_t

alpha problems

This topic is 4728 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

I'm using Direct3D for 2D programming, using textured quads, and have been having trouble getting alpha levels to work correctly. I do get an alphablend, but there are aberrations around the edges of the quad. For instance, I'm trying to render a tree that has a transparent black bounding rectangle. The background color of my screen is set to blue. When I display the tree, the transparency works (the tree is surrounded by the background blue, not black) but at the edges of the quad the tree is textured on to there are little, slightly differently colored blue lines. Anyone know a fix for this problem?

Share this post


Link to post
Share on other sites
Advertisement
This is most likely to be caused by the tree having slighty blurred edges. If you made it in Photoshop then this is most definately the reason. How are you achieving this. Are you using D3DXLoadTextureFromFileEx() or whatever it is and then setting the alpha value in the parameter or are you creating the alpha channel in photoshop and loading it as normal?

ace

Share this post


Link to post
Share on other sites
Thanks for the fast reply. I made the image with GIMP, so I might be seeing the same problem that you described with photoshop, and have been loading it in with D3DXCreateTextureFromFile. However, I just tried drawing up a new image with MS Paint, using D3DXCreateTextureFromFileEx to color key replace opaque black with transparent black: I still have the same problem with the bounding edges being off-color, and this attempt also left a black line tracing the outside edge of my tree. I'm not much of an artist, but I would assume MS Paint isn't going to do anything fancy like blurring the edges of my image so I'm not sure that could be the problem. I've set (D3DRS_SRCBLEND, D3DBLEND_SRCALPHA), (D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA), and (D3DRS_ALPHABLENDENABLE, true) for alphablending, is it possible there's some other render state I need to set?

Share this post


Link to post
Share on other sites
There are no other render states that you need to set.

What does the texture come out like with blending turned off.

ace

Share this post


Link to post
Share on other sites
I'm in a hurry to go cook dinner so I'm keeping this brief [smile]

This sounds to me like it could be a filtering issue.

If you have LINEAR or ANISOTROPIC filtering enabled then on some hardware (note: some I've used doesn't have this issue!) it will sample the transparent pixels as well as the opaque ones, meaning that you end up with a bit of blur...

You can either solve this by removing the filtering (not necessarily a good thing) or sometimes by setting up alpha testing such that only fully opaque pixels are rendered and it drops ANYTHING else.

hth
Jack

Share this post


Link to post
Share on other sites
Thanks for all the help. I got it. The problem was with filtering; I took the quick and easy solution and disabled the filtering and now there's no problem at the edges.

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!