Alpha blending not working

Started by
4 comments, last by Calin 18 years, 4 months ago
Hello, I'm using those lines to enable alpha blending, but it doesn't work... lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE); My test consists of blitting a texture in the center of the screen while an object is rotating behind. Thanks in advance.
Advertisement
There are a couple of things that might be wrong. Can you describe what you see using the settings above.

Just a short check up list:

1. At the beginning of your draw function you have this settings:
SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
SetRenderState(D3DRS_ZWRITEENABLE, TRUE);

2. Draw all solid objects;

3. SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
SetRenderState(D3DRS_ZWRITEENABLE, FALSE);

4. Draw all transparent objects in a back to front order;

My project`s facebook page is “DreamLand Page”


Thank your for your reply.

SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
SetRenderState(D3DRS_ZWRITEENABLE, FALSE);

I've tried, it doesn't change anything...

Quote:
Can you describe what you see using the settings above.


You didn't answer this question. Let me rephrase it. How does that texture appear on screen? Is it solid, is it invisible?

Also what is the source of the alpha? Is it an alpha channel in the texture? are you using vertex alpha?

[Edited by - Calin on December 4, 2005 1:11:14 PM]

My project`s facebook page is “DreamLand Page”

The image is solid. The source is the alpha channel of the texture.

In this case two things come to my mind:

1. Make sure there is an alpha channel in the texture. I mean you saved the texture with an alpha channel.
2. I my memory doesn't fail me when you load the texture you must specify a certain format for the texture. It's the seventh parameter in the D3DXCreateTextureFromFileEx function. I don't remember the the exact format you must pass. Try D3DFMT_A8R8G8B8 or D3DFMT_A8B8G8R8. This topic has been discussed many times on this forum make a search on this site for 'alpha blending' you'll get a lot of hits.

My project`s facebook page is “DreamLand Page”

This topic is closed to new replies.

Advertisement