Sign in to follow this  
gael

Alpha blending not working

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites

Thank your for your reply.

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

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this