How to film a background in a 3D world

Hi,

My project has to display a texture in background. And an other camera is filming a 3D scene with cube, sphere, etc.

I tried to use the GUI to have a background perfectly fitted to my screen but it’s above everything in my scene.

Maybe I don’t need two cameras, but I don’t know how can I do this.

Thx by advance,

Hi

There are different ways to handle this problem depending on the effect you want, but 2 cameras is certainly a valid approach. If you’ve been trying already, I will assume you have:

  • 2 cameras in your scene
  • 1 of the cameras is looking at your 3D stuff
  • the other camera is looking at your background (maybe a texture on a big quad or something?)

You will need to do a few things. I would open this page of documentation first, that describes some features of unity cameras:

First, set the camera depth of the cameras so that the background one gets rendered first. A camera with a larger depth value will be rendered on top of cameras with a smaller one.

Once you’ve made sure the foreground camera is rendered on top of the background, you’ll also need to tell it not to clear the screen before it renders. For this you’ll probably want to set the ‘clear flags’ to ‘Depth’, meaning clear out the depth information (that controls what objects are in front of other objects), but leave the colour information alone.

Your background camera will also probably be easier to configure to be in front of a full screen quad if you set the ‘Projection’ it to ‘orthographic’.

If your background quad is completely seperate from the rest of your scene, that should do it. However if it overlaps somehow with the rest of your scene, you’ll also need to look into using layers with the camera’s culling mask to tell unity you only want to render the background quad to the background camera, and want to render everything else to the foreground camera.

-Chris