• Advertisement
Sign in to follow this  

Question: Opacity with texture

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

is there any way to render a textured vertex buffer partially transparent (lets say with an opacity of 0.2?) [like in flash, setting _alpha to 0.2 so that you see 20% of the object and 80% of the other objects ty

Share this post


Link to post
Share on other sites
Advertisement
Yes.

Are you using shaders, or the fixed pipeline?

For a shader, simply set the output alpha value to whatever you'd like, or if you're mixing with the texture's alpha, multiply the two values.

For the fixed pipeline, use alphaops to choose the alpha values to use.

pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
pDev->SetRenderState(D3DRS_TEXTUREFACTOR, alpha * 0x01000000);

In both cases, you'll need to enable alpha blending

pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

And in both cases, you want to render all solids first, then alpha blended items sorted from back to front.

Share this post


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

  • Advertisement