Hi, I'm completely new to DirectX (using SlimDX 11), and I have spend most evenings this past week simply trying to get something to show.
I'm trying to get alpha blending / transparency working, but I can can't figure out how to do it, and I can't find any exact example of what I'm trying to do.
Essentially I'm trying to be able to draw a box semi transparent. For test I have a blue triangle at z = -0.5, red at z = 0, green z = 0.5. I then rotate the view slightly and would now expect to see 'through' all the triangles, so I can see the green behind the red behind the blue.
In the shader I have just hardcoded the alpha value to 0.5f (this is just for testing)
float4 PShader(VertexOut vin) : SV_Target
{
vin.Color.a = 0.5f;
return vin.Color;
}
I then tried to set the BlendState through code, but kept getting a 'unspeificed error returned', so instead I added it to the technique
technique11 MyTest
{
pass P0
{
SetGeometryShader( 0 );
SetVertexShader( CompileShader( vs_4_0, VShader() ) );
SetPixelShader( CompileShader( ps_4_0, PShader() ) );
SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 1.0f, 1.0f, 1.0f ), 0xFFFFFFFF );
}
}
Now, this almost works, I can see the red behind the blue (blue at z=-0.5, read at 0), but the red is completely opaque and I do not see the green.
Looking at some other examples I noticed that Depth is turned off, so I tried that too, but that doesn't work either. With depth turned off, I do see all 3 of them semi transparent, but the green is now always in front.
Any suggestions or links will be appreciated.
Jesper






