I'm having a problem getting the BlendState on the graphics device to work properly and display the alpha blending correctly.
In some cases you can see the leaves through other leaves, in other cases you cannot. And the trunk is also always obscured.
I've tried so many different combinations of setting up the BlendState. At the moment it looks like this:
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
//GraphicsDevice.BlendState = BlendState.AlphaBlend;
GraphicsDevice.BlendState = new BlendState()
{
AlphaBlendFunction = BlendFunction.Add,
AlphaDestinationBlend = Blend.InverseSourceAlpha,
AlphaSourceBlend = Blend.One,
BlendFactor = new Color(1.0F, 1.0F, 1.0F, 1.0F),
ColorBlendFunction = BlendFunction.Add,
ColorDestinationBlend = Blend.InverseSourceAlpha,
ColorSourceBlend = Blend.One,
ColorWriteChannels = ColorWriteChannels.All,
ColorWriteChannels1 = ColorWriteChannels.All,
ColorWriteChannels2 = ColorWriteChannels.All,
ColorWriteChannels3 = ColorWriteChannels.All,
MultiSampleMask = -1
};
The shader code are as follows:
float alpha = 1.0F; if (HasAlphaTexture) alpha = tex2D(AlphaSampler, IN.UV).xyz;
//... //determine color values etc.. ///...
return float4(result.xyz,alpha);
The maps I'm using for this looks like the following: