Mesh with Alpha Texture doesn't blend properly
Posted
by
faulty
on Game Development
See other posts from Game Development
or by faulty
Published on 2011-02-26T16:25:28Z
Indexed on
2011/02/26
23:33 UTC
Read the original article
Hit count: 244
I've followed example from various place regarding setting OutputMerger's BlendState to enable alpha/transparent texture on mesh. The setup is as follows:
var transParentOp = new BlendStateDescription {
SourceBlend = BlendOption.SourceAlpha,
DestinationBlend = BlendOption.InverseDestinationAlpha,
BlendOperation = BlendOperation.Add,
SourceAlphaBlend = BlendOption.Zero,
DestinationAlphaBlend = BlendOption.Zero,
AlphaBlendOperation = BlendOperation.Add,
};
I've made up a sample that display 3 mesh A, B and C, where each overlaps one another. They are drawn sequentially, A to C. Distance from camera where A is nearest and C is furthest. So, the expected output is that A see through and saw part of B and C. B will see through and saw part of C.
But what I get was none of them see through in that order, but if I move C closer to the camera, then it will be semi transparent and see through A and B. B if move closer to camera will see A but not C. Sort of reverse.
So it seems that I need to draw them in reverse order where furthest from camera is drawn first then nearest to camera is drawn last.
Is it suppose to be done this way, or I can actually configure the blendstate so it works no matter in which order i draw them?
Thanks
© Game Development or respective owner