Jump to content
  • Advertisement
Sign in to follow this  
Andregolas

drawing .dds textures with alpha channel

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

Hi all, I have a question concerning the .dds file format and its alpha channel. When I load my .dds texture (saved WITH alpha channel!) and draw it to a sprite, the transparent areas are white. How can I get the alpha channel in my program to get transparent areas? Thanks for your answers.

Share this post


Link to post
Share on other sites
Advertisement
If you are using the photoshop export plugin try to disable the SRGB option and use the ARGB format ;)

Share this post


Link to post
Share on other sites
Have you enabled alpha blending?

pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); // color * alpha
pDev->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); // +
pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);// buffer * 1-alpha

I think the default TextureStageStates will use the alpha from your texture. If you've changed those states, make sure your alpha stages get the texture's alpha. For example:

pDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); // tex
pDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); // *
pDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); // lighting

pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); // tex alpha
pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); // *
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); // material or vertex alpha

pDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); // end
pDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); // end

Share this post


Link to post
Share on other sites
First of all: thanks for your answers =)

@51mon: I already saved my textures as A8R8G8B8 (DXT5)

@Namethatnobodyelsetook: Sorry we use C#. My Coder said that AlphaBlend IS enabled:

D3D_Device.RenderState.AlphaBlendEnable = true;

At texture loading he just uses the TextureLoader.FromFile(Device, PathToTexture) Method without any special parameters.

But we found a method to hide a color and I will replace the alpha channel with magenta to get a transparent background.

Although thanks for your efforts.

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!