Sign in to follow this  
Hurp

HLSL Transparency

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this