• Advertisement
Sign in to follow this  

HLSL Transparency

This topic is 3571 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 am trying to render a sphere with transparency in HLSL and I honestly can not figure out how it is done (none the less see a resource to learn it). Can anyone explain this to me?

Share this post


Link to post
Share on other sites
Advertisement
I figured that much, however, isn't there a way to set how much transparency I would like. Isn't there also different types of alpha blending also?

Share this post


Link to post
Share on other sites
You can of course set also all other render states (affecting the alpha blending) in HLSL, just put out the D3DRS_
You can also modify the alpha values in vertex or pixel shaders in HLSL to either simply change the amount of transparency or to create more interesting effects like for example alpha varying with angle between vertex normal and camera direction (bubble effect)...

Share this post


Link to post
Share on other sites
I haven't experimented much with transparency in HLSL but to set how much transparency you edit the alpha from your pixel shader ( return float4(colour, 0.5f); )

Share this post


Link to post
Share on other sites
The alpha value of the pixel you render is the 4th component of the float4 you return from your pixel shader (like smally said). What this alpha value means depends on how you set your blending states. For example if you set D3DRS_SRCBLEND to D3DBLEND_SRCALPHA and D3DRS_DESTBLEND to D3DBLEND_INVSRCALPHA, you get a color that's determined like this:


pixelColor = psOutput.rgb * psOutput.a + backBufferPixel.rgb * (1.0 - psOutput.a)

Share this post


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

  • Advertisement