Efficient camera rendering order not working?

Hello,

In my scene I have 2 cameras:

  • background camera (ortho) - renders background image that should be the farest seen thing in the scene
  • game camera (perspective) - renders everything else

Since I am doing an Iphone/Adroid game I figured that the most efficient way to render (avoid overdraw) is to first draw the perspective (game) camera and then the background camera without clearing the z-buffer or anything else. This should render the background only in pixels that were not already drawn by the main camera.

The settings are:

  • background camera - depth 5 and clear flags “don’t clear”
  • game camera - depth 1 and clear flags “solid color”

So I think I have set up the background camera to render after the main camera and the Z-buffer data from main camera should be used by the background camera. Also the image on the background camera is almost at the far clipping plane so it should not overwrite anything in the scene.

The effect, however, is not what I have expected. The background is drawn on top of everything else. Maybe someone has any idea why?

To quote from the Component Reference:

Depth The camera’s position in the draw order. Cameras with a larger value will be drawn on top of cameras with a smaller value.”

Flip the Depth values of your cameras so that the background is on a lower depth and you should be fine.