I'm currently having some problems with alpha transparency in XNA and for anybody who has experience with the framework I'd appreciate some help. The code is below but in this code example note that:
ReadStencil = new DepthStencilState()
{
DepthBufferEnable = true,
DepthBufferWriteEnable = false
};
and...
WriteStencil = new DepthStencilState()
{
DepthBufferEnable = true,
DepthBufferWriteEnable = true
};
So here is the actual code:
SB.Begin();
GraphicsDevice.DepthStencilState = WriteStencil;
if (Scene != null) Scene.Draw();
Map.Draw();
SB.End();
SB.Begin();
GraphicsDevice.DepthStencilState = ReadStencil;
for (int i = 0; i < Players.Length; i++) if (Players[i] != null && Players[i].Active && Players[i].Respawn <= 0) Players[i].Draw();
if (Effects.Count > 0) for (int i = 0; i < Effects.Count; i++) Effects[i].Draw();
In this image, the depth is set to DepthStencilState.Default. Of course, the depth in this case is correct, but it appears as if is drawing the stage behind the transparency rather than the parts of the object behind it/other objects written in the "WriteStencil" state. Also note that on the fox character it does the same thing around the outlines of the hair on the tail and on the head/face.
In this image, the depth has been distorted once again, but the initial issue is fixed. There is no invisible border around the hair meshes.
I can imagine there is some way to fix this since it's one of those problems where one problem fixes the other, but I would appreciate help if possible!
Thanks much.