Sign in to follow this  
gael

Textures transparency and surfaces

Recommended Posts

Hello, I'm using a textured font with alpha blending to hide the black pixels of characters (0x00000000). It works with 3D objects behind the text but, when I blit a Direct3D surface as scene background the transparency doesn't work. Can someone explain why and how I can fix this? Thanks a lot in advance, Gael

Share this post


Link to post
Share on other sites
I'm not sure I follow your description...

How and when are you rendering this background surface?

Alpha blending is draw-order dependent, thus you have to draw all opaque/background objects *before* you render the semi-transparent ones.

hth
Jack

Share this post


Link to post
Share on other sites
Hi Jack,

I use StretchRect() to blit the surface on the screen, then I draw the 3D objects, then I draw the text. When a 3D object (a spaceship for example) is
behind the text, you don't see the black pixels of the text (textured quads), but when there is no object, the black pixels are visible.

Gael

Share this post


Link to post
Share on other sites
I've solved my problem. You simply have to set alpha test to greater or equal to 1 and pixel with alpha 0 are ignored. It works perfectly!

pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, true );
pd3dDevice->SetRenderState( D3DRS_ALPHAREF, 0x01 );
pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );

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