Problem with transparent planes behind each other

Hi. I have planes with a transparent vertex shader to cutout some black shapes. In front of it, a little bit closer to the camera, is a rotating plane that should illustrate fog. It has also a transparent vertex shader, but the color is white gray. If i move with the player, sometimes the one whole black cutoutplane gets a brighter color than the others because of the ‘fog’ in front. Why is that? Is there a problem with rendering two tansparent planes behind one other?

“Is there a problem with rendering two t[r]ansparent planes behind one other?” Yes, if the system can’t always tell which is in front of the other. For transparent objects, the draw order matters (if you draw the cutout after the fog, the solid parts aren’t foggy.)

Suppose you have planes like this, where the O is the center (transform.position):

----large--- O ---plane-------
                ---small-O-plane--

  C3               C2              C1

Unity (and probably everything) measures to object 000. The camera at C1 clearly thinks small is in front of large. At C2 it probably also does (since it uses Z-distance, not real distance,) but at C3 it thinks large is in front of small. So moving from C1 to C3 gives a “pop” as the draw order flips (nothing moves, but color changes.)

One fix is just to move them further apart. Or use more, smaller planes.

The “real” fix is to look at the RenderQueue in the shader. Copy the fog’s particle shader and add the “+10” to the queue (the shader docs show how to do this.) Use that in the fog material, and now it will always go “over” regular stuff (even if it should be behind.)