The Camera component is used to display the objects in the Scene. Each effect requires at least one Camera to render out the Scene.
A project is able to have different objects render on different Layers, and the Camera will render everything in the selected Layer to the Render texture. This guide will walk you through how to add a Camera, the Camera settings, and how to work with multiple Cameras.
Add a camera entity
You can add a Camera entity by selecting the + Add object > Scene > Camera from the Hierarchy view. You can see your scene render in the Preview window.
Adjust the camera transform
Select the camera entity, and adjust the Transform component attached to this entity to specify the camera’s transform properties, including Position and Rotation.
You can either adjust the gizmo to manipulate the position and rotation, or type the value in the Transform component under the Inspector panel.
Certain settings cause the camera’s transform function to be overwritten. In this case, no matter how you adjust the camera transform or camera parameters, it won’t affect the final render. If a 3D Face Binding component has been assigned to the scene object, it can overwrite the camera settings.
Select the Camera in the Hierarchy panel, then in the Inspector panel under the Camera component, you will see the settings for your Camera.
- Layers: The Camera renders all objects that belong to the selected layers.
- Render texture: Sets the render output of this Camera to a Render texture. More information about Render texture can be found below.
- Render order: Controls the render order within the Camera’s Render texture. The lower the Render order, the earlier that this camera’s output texture will be added to the Render texture.
- Viewport: Indicates where on the screen of the camera view.
- X: The beginning horizontal position of the camera view.
- Y: The beginning vertical position of the camera view.
- W: Width of the camera output on the screen.
- H: Height of the camera output on the screen.
- Camera type:Choose between Perspective and Orthographic using the drop-down.
- Perspective camera: The Perspective Camera simulates how perspective and depth-perception work in the real world. Everything looks small in the distance and larger the closer they are to the Camera.
- Orthographic camera: The Orthographic Camera does not represent the object as it would be recorded photographically or perceived by a viewer observing it directly. It is a parallel projection, the lines will stay parallel in every circumstances.
- FOV (field of view): The view angle of the Camera (Perspective Camera only).
- Near: The closest distance the Camera can render.
- Far: The furthest distance the Camera can render.
- Clear type: Several Clear type options exist to allow you to customize your Render texture.
- Color: The Render texture will be filled by plain color if there is no input texture.
- Depth: Clears the depth buffer from a previous render texture.
- Depth-color: Clears the depth buffer and color buffer from a previous render texture.
- Don’t: Does not clear any buffer from previous render texture.
- Depth_stencil: Clear the depth buffer with a stencil buffer from a previous render texture.
- Color_depth_stencil: Clears the depth buffer with both a stencil buffer and a color buffer from a previous render texture.
- Clear color: If it exists and is enabled, the Render texture of this Camera will be filled by input texture, or plain color otherwise. As a reminder, Alpha is always 1.
Render Layer & Order
In some cases, you may want to group assets together and use more than one camera to render different entities simultaneously. This can be achieved through the Layer system.
Each entity in the hierarchy can be assigned to a layer, and each camera in the scene can be assigned to render one or more of those layers.
Initially, every entity is assigned to the Default Layer.
To change the layer that an entity is on, you can select a different layer from the Layer dropdown list.
Camera components also are set to render the Default Layer on creation. Again, we can change this by selecting a new layer from the dropdown list. We can also select additional layers. The camera will then render every entity that is assigned to the selected layers.
By default, there are seven layers in a new effect. We can assign them new names by double clicking the name in the dropdown menu.
There may be situations where multiple entities occupy a similar space, but you want to ensure that one appears on top of another. In these cases, we can assign Layers and change the Render order of different entities.
Let’s look at an example. In this scene, we have both a 3D Face and Face Mask. Both of these occupy the same space in 3D, but we want the makeup to always render on top of the face shape.
Right now, our scene looks like this:
First, we need to assign our 3D Face to Layer 1 and our Face Mask to Layer 2. Then we must duplicate our Camera, and assign the first camera to render Layer 1 and the second camera to Layer 2. We do this because we can change the order in which cameras render.
Navigate to the Camera component of the first camera. We can see that the default Render order for a new camera is 0. Lower values will render “on top” of higher values to determine the Render order.
Since we want our 3D Face to render underneath our Face Mask, we should change the Render order to something higher than 0.
Now, after refreshing our Preview window, we can see the new order.
Use multiple cameras
A Scene can have multiple Cameras. Depending on your needs, different cameras can render out in the same Render texture or in different render textures.
- When Cameras select the same render textures with different layers, the selected render texture will show views of both Camera renders. This approach is most commonly used with a Perspective Camera for 3D objects and an Orthographic Camera for 2D views.
- Cameras can also be chained together by using the render textures of one camera as the input to another Camera’s render texture. This approach is most commonly used with multiple Layers bearing different screen effects.