Rendering order???

Hello,
I have 4 spheres inside each other. The first sphere is the ocean floor. The second sphere is the water level. The third sphere is the clouds and the fourth sphere is the sky. The ocean floor has a shader called, “outer” to render the outside of the sphere. All the other spheres have a shader called, “inner” which renders from the inside of the sphere and are also transparent (which uses the alpha channel). I also have ZTEST set to ALWAYS meaning to render spheres that are inside or outside of other spheres (to render always), but I don’t know how to tell Unity to render the sky first, the clouds second, the water level third, and the ocean floor last. I get flickering when I move the camera around in my game window (as the 4 spheres render randomly in random order depending on the camera’s position). Is there any way to fix that?

Thank you,
Michael S. Lowe

Hi there, if you’re using specialized shaders you can set the Queue tag in the sub shader
http://docs.unity3d.com/Documentation/Components/SL-SubshaderTags.html
( below where it says Rendering Order - Queue tag )

otherwise you could set the queue in the material, though make sure to read the documentation of the side effects here:

So in the shader if all this is suppose to be like a skybox replacement you’d wanna use queues
“Background-4”
“Background-3”
“Background-2”
“Background-1”

Where the -4 will be drawn first. ( also you’ll want to set the camera clear flags to depth only, and most likely you’ll want to disable zwrite as well as ztest in each shader.

Thank you. It worked.