Jump to content
  • Advertisement
Sign in to follow this  

Semi-transparent model

This topic is 4147 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, im using c++ and im trying to figure out how can i make a model on the screen 50% transparent of 75%. My end goal is being able to fade the model in and out of view. Thanks for any help, -Dave

Share this post

Link to post
Share on other sites
Huh, you need to be more specific ... do you use the old fixed pipeline or a pixel shader ?

First, you need to make sure you have alpha blending enabled with:

If you use a pixel shader, you can only add and set a constant and multiply the alpha component with it before returning the result.

If you use the old fixed pipeline (you should not because it's pretty much dead), you could do something like:

lpD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
lpD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
lpD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARGOP, D3DTOP_MODULATE);
lpD3DDevice->SetRenderState(D3DRS_TEXTUREFACTOR, fadeFactor << 24);
where fadeFactor is between 0 (completely transparent) and 255 (opaque)

Also, if you want to achieve good result, you'll need to render your model twice, once writing only in the z-buffer and once normally after with z testing on to avoid sorting problems:

lpD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
// render you mesh
// render your mesh again

hope I understood your question correcly ;) and it help

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!