• Advertisement
Sign in to follow this  

Textures transparency and surfaces

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement