Version: 2021.1
Creating a simple render loop in a custom render pipeline


A Unity scene represents GameObjects in a three-dimensional space. Since the viewer’s screen is two-dimensional, Unity needs to capture a view and “flatten” it for display. It does this using cameras. In Unity, you create a camera by adding a Camera component to a GameObject.

Defining what a camera sees

What a camera sees is defined by its transform and its Camera component. The transform position defines the viewpoint, its forward (Z) axis defines the view direction, and its and upward (Y) axis defines the top of the screen. Settings on the Camera component define the size and shape of the region that falls within the view. With these parameters set up, the camera can display what it currently “sees” to the screen. As the GameObject moves and rotates, the displayed view moves and rotates accordingly.

Perspective and orthographic cameras


现实世界中的摄像机(实际相当于人眼)在观察外界事物时,物体距离视点越远,看起来越小。这种众所周知的_透视_效果在艺术和计算机图形领域广泛应用,对于创建现实场景至关重要。当然,Unity 支持透视摄像机,有时需要专门在没有这种效果的条件下渲染视图。例如,需要创建一种与真实世界的对象不完全相同的地图或信息显示效果。显示的对象不随距离变远而缩小的摄像机称为正交摄像机;Unity 摄像机也有这样的选项。在透视和正交模式下观察场景称为摄像机投影。(上述场景来自于 BITGEM

The shape of the viewed region

对于从当前位置能“观察”的最远距离方面,透视和正交摄像机都存在一定的限制。该限制由垂直于摄像机向前 (Z) 方向的平面定义。此平面称为远裁剪面,因为与摄像机距离较远的对象将被“裁剪”(即,不在渲染范围内)。摄像机附近还有一个相应的近裁剪面;可观察的距离范围位于这两个平面之间。


When perspective is used, objects appear to diminish in size as the distance from camera increases. This means that the width and height of the viewable part of the scene grows with increasing distance. The viewing volume of a perspective camera, then, is not a box but a pyramidal shape with the apex at the camera’s position and the base at the far clipping plane. The shape is not exactly a pyramid, however, because the top is cut off by the near clipping plane; this kind of truncated pyramid shape is known as a frustum. Since its height is not constant, the frustum is defined by the ratio of its width to its height (known as the aspect ratio) and the angle between the top and bottom at the apex (known as the field of view or FOV). See the page about understanding the view frustum for a more detailed explanation.

The background to the camera view

You can set what a camera does before it renders the scene, which the background that you see in the empty areas between objects.

For example, you can choose to fill the background with a flat color before rendering the scene on top of it, or draw the sky or a distant background, or even leave the contents of the previous frame there. For information on configuring this setting, see the Background property in the Camera Inspector reference. For information on drawing sky, see Sky.

Creating a simple render loop in a custom render pipeline