Jump to content
  • Advertisement
Sign in to follow this  
TLAK1001

Texture Transparency

This topic is 4325 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 GameDev Community, I am having trouble with transparency. I am trying to omit the pink background of my bmp textures upon rendering. I am loading the textures with a call to D3DXCreateTextureFromFileEx() with all default values and D3DCOLOR_ARGB(255,240,100,240) as the color key. Every render pass, I call pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); before doing anything else. For some reason, the pink is replaced with black. How do I make it transparent? Thank you for your help, tlak

Share this post


Link to post
Share on other sites
Advertisement
I don't know how to use D3D, but what you describe sounds like you either forgot to 'enable blending' (if there is a D3D equivalent to this OGL concept), or have your 'blend mode' setup wrong.

Share this post


Link to post
Share on other sites
A few things,

1) If the pink is replaced with black, the color-keying operation is likely succeeding. This means that the alpha should be set to 0 in pixels that were previosly pink.

2) Make sure you use a format with an alpha channel. If you're not specifying a texture format, try specifying one that includes an alpha channel (A8R8G8B8 is a good choice, usually).

3) If you're doing color-keying, you most likely want to enable Alpha Testing, and not Alpha Blending. Testing has the added benifit of not writing to the z-buffer, and thus not ocluding things behind the transparent area of the texture, which might be what's happening here.

4) Make sure you set the Source Blend and Destination Blend renderstates to Source, and InvSource respectively.

Anyhow, hope this helps.

Share this post


Link to post
Share on other sites
You could try disabling ZBuffer writes. It might fix the blackness problem, but may introduce problems where some things appear ontop of others when they shouldn't. But you might get lucky, so its worth a shot.

pd3dDevice->SetRenderState( D3DRS_ZBUFFERWRITEENABLE, FALSE);
should do the trick.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!