drawing .dds textures with alpha channel

Started by
2 comments, last by Andregolas 16 years, 8 months ago
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.
Advertisement
If you are using the photoshop export plugin try to disable the SRGB option and use the ARGB format ;)
Have you enabled alpha blending?
pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, true);pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);    // color * alphapDev->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); // texpDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); // *pDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); // lightingpDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); // tex alphapDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); // *pDev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); // material or vertex alphapDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); // endpDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); // end
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.

This topic is closed to new replies.

Advertisement