Jump to content
  • Advertisement
Sign in to follow this  
Sante05

Question on alpha blending

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

Hi. I'm trying to draw my polygons blended with the alpha value stored in the frame buffer, the render states I'm using are:
g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTALPHA);
g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
The polygons I'm drawing have alpha=0, and I'm clearing the frame buffer with D3DCOLOR_ARGB(0,0,0,0). My problem is the polygon still shows up in screen. Correct me if I'm wrong, but if the alpha formula was: Final Color = (ObjectColor * SourceBlendFactor) plus (PixelColor * DestinationBlendFactor) My dest blend factor is zero. So the final color only depends on the object color blended with the source blend, which is in fact the dest alpha (the framebuffer), which I cleared to be zero as well. So the object shouldn't be appearing in screen, right? It seems to me as if the framebuffer was not correctly cleared and still had 1.0 as alpha value. If I use D3DBLEND_INVDESTALPHA the object disappears. Any ideas of what I could be doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Namethatnobodyelsetook
I'm guessing your backbuffer is X8R8G8B8 not A8R8G8B8.


Yep, that was it. Really stupid for me using an old initialization code and assuming it was correct. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!