HLSL Transparency

Started by
4 comments, last by MJP 15 years, 11 months ago
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?
Advertisement
AlphaBlendEnable = true;
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?
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)...
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); )
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)

This topic is closed to new replies.

Advertisement