Z-index issues

Update 4 - Solution/Workaround

It seems like this issue occurs when you have multiple objects with the Transparent shaders. In my case - the player and the column. When I changed the shader of the column to Transparent/Cutout the problem disappeared. The drawback is that now the column has jagged edges, but I think it’s much better than jagged edges on the player, since he’s animated.

I hope this helps anyone.

Update 3

It seems like this is a known limitation of the Transparent shader. From the Unity docs:

Transparent Cutout Properties

Cutout shader is an alternative way of displaying transparent objects. Differences between Cutout and regular Transparent shaders are:

  • This shader cannot have partially transparent areas. Everything will be either fully opaque or fully transparent.
  • Objects using this shader can cast and receive shadows!
  • The graphical sorting problems normally associated with Transparent shaders do not occur when using this shader.

Link: Unity - Manual: Transparent Cutout Bumped Specular

Update 2

When I switch to the Transparent/Cutout/Diffuse shader the Z-index problem is gone and I have transparency, but also jagged edges around my sprite. What can I do about those jagged edges?

Update 1

I’m using a Transparent/Diffuse material for the player’s plane. When I change it to just Diffuse, the Z-index problem is gone, but the transparency is gone.

Question

I’m getting this weird issue - see the shot below. You can clearly see that the character plane is in front of the column, but the column gets rendered in front of it. I have tried searching for similar issues, they are all about Z fighting, which I understand is something different.

So as you can see there is plenty of space between the planes. A couple of things to note:

  • the column is using a billboarding script, which rotates it on the Y axis towards the camera. Turning off the script makes no difference.
  • I tried playing with the camera. Changing the clip planes makes no difference. The only think that sort of fixed it is when I got the camera super close to the plane with a really wide viewing angle. Obviously, that’s not an option :slight_smile:
  • the character can walk next to the wall (on the left of the screenshot) without any z-index issues and the planes even intersect.

Any ideas?

Here is the hierarchy in the scene as well as all affected objects’ positions at the time of the glitch.

It seems like this is a known limitation of the Transparent shader. From the Unity docs:

Transparent Cutout Properties

Cutout shader is an alternative way of displaying transparent objects. Differences between Cutout and regular Transparent shaders are:

  • This shader cannot have partially transparent areas. Everything will be either fully opaque or fully transparent.
  • Objects using this shader can cast and receive shadows!
  • The graphical sorting problems normally associated with Transparent shaders do not occur when using this shader.

Link: Unity - Manual: Transparent Cutout Bumped Specular

This issue occurs when you have multiple objects with the Transparent shaders. In my case - the player and the column. When I changed the shader of the column to Transparent/Cutout the problem disappeared. The drawback is that now the column has jagged edges, but I think it’s much better than jagged edges on the player, since he’s animated.

I hope this helps anyone.

Under the SubShader section, add +1 to the item in the “Queue” section. For me, this became “Queue” = “Transparent+1”.

	SubShader
	{
	Tags{"Queue" = "Transparent+1"}
		Cull Off ZWrite Off ZTest Always