A scene can have multiple cameras. Different cameras can render the scene, webcam, or phone camera stream on different render textures.
This guide will help you understand how to correctly render your effect. If you want to render one object on top of the other or render some objects in one part of the screen, you must correctly set up the following in the scene:
- Layer of cameras and objects
- Render order of cameras
- Sorting order of objects
Add a Camera
You can add a Camera object by clicking the Add button [+] > Scene > Camera in the Hierarchy panel.
Learn more about how to configure a Camera object.
Configure Auto Sorting, Render Layer, and Render Order
The final render result is what you can see on your phone screen or in the Preview panel. The following three properties can affect the final result:
- The render order of objects and cameras in the scene.
- The render textures of the cameras used in the scene.
- The object’s visibility, which is affected by the object’s visibility setup and object’s position relative to the camera in the scene.
Layer determines which objects get rendered first on which cameras’ render textures. The layer order doesn’t affect the render order. It affects the visibility of objects in the rendering result.
The relative position of the cameras and objects in the 3D scene may also affect visibility.
Set a Layer
For a Camera
Camera components are set to render Default Layer upon creation. You can change this by selecting a new layer or multiple layers from the Layers dropdown. The camera will then render every object that is assigned to the selected layers.
For a Scene Object
You can select which layer you want this object to be on. An object can only have one layer.
Make sure you have one camera’s layer set up to the same layer the object is on. If not, the object will be invisible from the render result.
Rename a Layer
By default, there are 63 layers in a new effect. You can assign them new names by double-clicking the layer name in the dropdown.
Camera’s Render Order
To determine the render order of an object, first you need to check the Render Order property of the camera that is rendering the object. The camera’s render order determines the render order of the cameras in the Scene panel.
The camera with the largest render order value will render last.
Object’s Sorting Order
You must then set Sorting Order of the object to determine the render order of the objects that share the same camera. You can also use Auto Sorting, which determines the render order of objects that share the same camera based on their ordering in the Hierarchy panel.
The object with the largest sorting order value will render last.
If you want to render one object in different angles with multiple cameras, make sure you set different render textures to those cameras. Learn more about Render Texture.
For example, take a look at the following diagram:
In this case, the render order of these objects looks like this:
- Camera B
- Object D
- Object C
- Camera C
- Object E
- Camera A
- Object A
- Object B
Usage 1: 3D (Perspective) Camera + 2D (Orthographic) Camera
When cameras select the same render texture with different layers, the selected render texture will show views of both cameras. This approach is most commonly used with a perspective camera for 3D objects and an orthographic camera for 2D views.
Usage 2: Add a 3D Object in Front Of or Behind the Segmentation
You can add 3D objects in front of or behind the segmentation layer by manipulating the layers of each object. Learn more about Segmentation.