Overlapping Transparency issue

Hey I’m working on a 3D object that uses some 2D objects (basically, upright planes or quads).

However, when stacked on top of each issue I get this weird overlapping phenomenon with the transparency areas.

Is there some GraphicsDevice setting or some simple way to fix this?

The BlendState is AlphaBlend and the DepthStencilState is on Default. I’ve tried about every other setting.

This is known as Billboarding.

Take a gander here:

[XNA] Help billboard example (esotericsoftware.com)

Hmm you could avoid writing to the depth buffer, where the billboards are transparent. Or if you sort them by yourself, you could use depth read and draw them from far to near.

have you tried the AlphaTestEffect ?

Here’s the answer. I simply have to draw them in a different order, from the camera. I was under the impression that device.DepthStencilState = DepthStencilState.Default; already took care of that somehow, but it was made clear to me that this does something else.

So I just need to take all my objects and sort them based on distance from camera before drawing them. I was able to do this with this sort by comparison equation:

		roomCharacters.Sort(delegate (DuckEntity b1, DuckEntity b2)
		{
			return (Vector3.Distance(b2.duckPosition.Position, camera.Position)).CompareTo(Vector3.Distance(b1.duckPosition.Position, camera.Position));
		});

I was also told that I can use DistanceSquared instead of Distance and that this is faster.

Only you can mark your post as the solution.