• Advertisement

Archived

This topic is now archived and is closed to further replies.

D3D8 Alpha Blending

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

I want to make sure that my method for alpha blending in D3D8 is a good one, and should be widely compatible with graphics hardware, so please do comment! What I''m doing is drawing my transparent user interface (alpha blended) panel AFTER drawing the scene (after the endscene statement). Note that these are 2D screen coordiantes polygons (I''ve heard that drawing these types after the endscene is more reliable). The settings I''m using for the blending are:
  
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND,   D3DBLEND_SRCALPHA );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND,  D3DBLEND_INVSRCALPHA );
  
Is this the correct method? For some reason I have the feeling I should be drawing my transparent polygons FIRST, and using (obviously) different parameters for the SetRenderState calls. Comments? Thanks! Mal.

Share this post


Link to post
Share on other sites
Advertisement
You should be drawing your transparent polys/geometry after you have drawn all your other non-transparent polys/geometry. For example:

BeginScene()
Draw non-transparent polys
Draw transparent (alpha-blended) polys
EndScene()

As you are using alpha blending for your user interface you simply do the following...

BeginScene()
Draw non-transparent polys
Draw transparent (alpha-blended) polys
Draw user interface elements
EndScene()

Generally you will be rendering your user interface components after everything else. To increase rendering performance you can turn off features such as z-buffering, lighting,z-writes etc. when it comes to rendering your user interface.

Share this post


Link to post
Share on other sites

  • Advertisement