URP——摄像机

Unity中的相机就像现实世界中的相机一样工作:它捕捉三维空间中的物体,然后将其展平,显示在二维平面上。

通用渲染管线(URP)中的摄像头基于Unity的标准摄像头功能,但有一些显著的区别。URP相机与标准Unity相机最显著的区别是:

  • 通用附加相机数据组件,它扩展了相机组件的功能,并允许URP存储与相机相关的附加数据
  • 渲染类型设置,它定义了URP中的两种摄像机类型:基础和覆盖
  • 相机叠加系统,可将多个相机的输出叠加成单个组合输出
  • 体积系统,它允许你基于场景中给定的变换的位置对相机应用后处理效果
  • 摄像机组件,它在检查器中公开URP的特定属性

要了解相机在Unity中是如何工作的一般介绍,以及常见的相机工作流程示例,请参阅Unity手册中的相机部分。

The Universal Additional Camera Data component

摄像机通用附加数据组件是通用渲染管线(URP)用于内部数据存储的组件。摄像机通用附加的数据组件允许URP扩展和覆盖Unity的标准相机组件的功能和外观。

在URP中,一个拥有摄像机组件的游戏对象还必须有一个摄像机通用的附加数据组件。如果你的项目使用URP,当你创建一个相机游戏对象时,Unity会自动添加通用的额外相机数据组件。你不能从相机游戏对象中移除摄像机通用的附加数据组件。

如果你不使用脚本来控制和自定义URP,你不需要对摄像机通用附加数据组件做任何事。

如果你使用脚本来控制和定制URP,你可以在脚本中访问相机的通用附加相机数据组件,如下所示:

var cameraData = camera.GetUniversalAdditionalCameraData();

有关更多信息,请参见UniversalAdditionalCameraData API文档

如果您需要经常访问脚本中的通用附加相机数据组件,您应该缓存对它的引用,以避免不必要的CPU工作。

Render Type

在通用渲染管道(URP)中有两种类型的摄像机:

  • 基础摄像机是一个通用的用于渲染目标(一个屏幕,或者渲染纹理)的摄像机。
  • 一个覆盖的摄像机渲染在另一个摄像机的输出上。您可以将一个基本摄像机的输出与一个或多个覆盖摄像机的输出相结合。这叫做相机堆叠

使用相机的渲染类型属性使其成为基础相机或覆盖相机。

在Unity编辑器中改变相机的类型:

  1. 在场景中创建或选择一个摄像机。
  2. 在摄像机检查器中,使用渲染类型下拉菜单来选择不同类型的摄像机。选择:
  • Base 将相机转换为基础相机
  • Overlay 将相机转换为覆盖相机

你可以在脚本中改变相机的类型,通过设置相机的通用附加数据组件的renderType属性,如下所示:

var cameraData = camera.GetUniversalAdditionalCameraData();
cameraData.renderType = CameraRenderType.Base;

Base Camera

基础摄像机是URP中默认的摄像头类型。基础摄像机是一个通用的相机,它渲染给定的渲染目标。

要在URP中渲染任何东西,场景中必须至少有一个基础摄像机。你可以在一个场景中有多个基础摄像头。你可以单独使用基础摄像机,也可以在相机堆栈中使用。有关在URP中使用多个摄像机的详细信息,请参见使用多个摄像机

当场景中有一个活动的基础摄像头时,这个图标会出现在场景视图中摄像头小部件的旁边:

有关Unity在检查器中为基本摄像机公开的属性的信息,请参阅基础摄像机组件引用

Overlay Camera

覆盖式摄像机是一个将其视图渲染在另一个摄像机输出上的摄像机。您可以使用覆盖摄像机创建效果,如2D UI中的3D对象,或车辆中的驾驶舱。

您必须将叠加式相机与使用相机堆叠系统的一个或多个基础相机结合使用。你不能单独使用覆盖摄像头。不属于摄像机堆栈的覆盖摄像机不会执行渲染循环的任何步骤,被称为孤儿摄像机。

重要提示:在URP的这个版本中,只有在使用前向渲染器时才支持覆盖相机和相机堆叠

当你的场景中有一个活动的覆盖摄像头时,这个图标会出现在场景视图中摄像头小部件的旁边:

摄像机堆栈中的基础摄像机决定了摄像机堆栈的大部分属性。因为你只能在相机堆栈中使用覆盖相机,URP在渲染场景时只使用覆盖相机的以下属性:

  • Projection
  • FOV Axis
  • Field of View
  • Physical Camera properties
  • Clipping plans
  • Renderer
  • Clear Depth
  • Opaque Texture
  • Depth Texture
  • Render Shadows
  • Culling Mask
  • Occlusion Culling

Unity隐藏了检查器中所有其他未使用的属性。您可以使用脚本访问未使用的属性,但是您对这些未使用的属性所做的任何更改都不会影响使用Overlay Camera的任何摄像机堆栈的视觉输出。

不能对单个覆盖相机应用后期处理。您可以将后期处理应用于单个基础相机或相机堆栈。

有关Unity在覆盖摄像机的检查器中公开的属性的信息,请参阅覆盖摄像机组件的引用

Working with multiple cameras

在通用渲染管线URP)中,你可以使用多个摄像机:

您可以结合使用这些方法来实现更复杂的效果。例如,您可以定义两个摄像机堆栈,然后将它们分别设置为渲染同一渲染目标的不同区域的摄像机堆栈。

有关使用多个摄像机时的摄像机渲染顺序的信息,请参见渲染顺序和过度绘制

Camera Stacking

在通用渲染管道(URP)中,使用摄像机堆叠将多个摄像机的输出分层,并创建一个组合输出。相机叠加允许您创建效果,如2D UI中的3D模型,或车辆的驾驶舱。

相机堆叠由一个基础相机和一个或多个叠加相机组成。相机堆栈使用相机堆栈中所有相机的组合输出覆盖基础相机的输出。因此,您可以通过基础摄像机的输出来完成的任何操作,都可以通过摄像机堆栈的输出来完成。例如,您可以将摄像机堆栈渲染到给定的渲染目标,应用后期处理效果,等等。

URP在相机内执行多个优化,包括渲染顺序优化以减少过度绘制。但是,在使用摄像机堆栈时,可以有效地定义渲染这些摄像机的顺序。因此,你必须小心,不要以导致过度绘制的方式排列相机。有关URP中透支的详细信息,请参阅高级信息

Adding a Camera to a Camera Stack

  1. 在你的场景中创建一个摄像机。它的渲染类型默认为Base,这使它成为一个Base摄像头。
  2. 在场景中创建另一个摄像机,并选择它。
  3. 在摄像机检查器中,将摄像机的渲染类型更改为Overlay。
  4. 再次选择基相机。在相机检查器中,滚动到堆栈部分,点击加号(+)按钮,然后点击叠加相机的名称。

覆盖相机现在是基础相机相机堆栈的一部分。Unity将叠加的摄像机输出置于基础摄像机输出之上。

通过直接操作基本摄像机的通用附加摄像机数据组件的cameraStack属性,你可以在脚本中添加一个摄像机到摄像机堆栈中,如下所示:

var cameraData = camera.GetUniversalAdditionalCameraData();
cameraData.cameraStack.Add(myOverlayCamera);

Removing a Camera from a Camera Stack

  1. 创建一个包含至少一个覆盖摄像机的摄像机堆栈。有关说明,请参见将相机添加到相机堆栈
  2. 选择相机堆栈的基础相机。
  3. 在相机检查器中,滚动到堆栈部分,单击您想要移除的覆盖相机的名称,然后单击减号(-)按钮。

覆盖相机仍然在场景中,但不再是相机堆栈的一部分。

通过直接操作基本摄像机的通用附加摄像机数据组件的cameraStack属性,您可以在脚本中从摄像机堆栈中删除一个摄像机,如下所示:

var cameraData = camera.GetUniversalAdditionalCameraData();
cameraData.cameraStack.Remove(myOverlayCamera);

Changing the order of Cameras in a Camera Stack

  1. 创建一个包含多个覆盖相机的相机堆栈。有关说明,请参见将相机添加到相机堆栈
  2. 选择相机堆栈中的基本相机。
  3. 在相机检查器中,滚动到堆栈部分。
  4. 使用覆盖相机名称旁边的手柄来重新排列覆盖相机列表。

基础摄像机渲染摄像机堆栈的基层,而堆栈中的叠加摄像机按照它们被列出的顺序,从上到下,在这个基础层上渲染。

通过直接操作基本摄像机的通用附加摄像机数据组件的cameraStack属性,可以在脚本中对摄像机堆栈重新排序。

Adding the same Overlay Camera to multiple stacks

添加叠加相机到多个相机堆栈:

  1. 创建一个包含至少一个覆盖摄像机的摄像机堆栈。有关说明,请参见将相机添加到相机堆栈
  2. 在你的场景中创建一个摄像机。它的渲染类型默认为Base,这使它成为一个Base摄像头。
  3. 选择新的基本相机。
  4. 在相机检查器中,滚动到堆栈部分,点击加号(+)按钮,然后点击你想在两个相机堆栈中使用的覆盖相机的名称。

叠加的摄像机现在在两个摄像机堆栈中渲染。

你也可以通过直接操作基本摄像头的通用附加摄像机数据组件的cameraStack属性,在脚本中添加一个摄像头到一个摄像头堆栈,如下所示:

var cameraData = camera.GetUniversalAdditionalCameraData();
cameraData.cameraStack.Add(myOverlayCamera);

Rendering from multiple Cameras to the same render target

在通用渲染管线(URP)中,多个基础摄像机摄像机堆栈可以渲染到同一个渲染目标。这允许您创建诸如拆分屏幕渲染之类的效果。

如果超过一个基础摄像机或摄像机堆栈渲染到一个渲染目标的相同区域,Unity将在重叠区域中绘制每个像素多次。Unity最后在之前绘制的像素之上绘制优先级最高的基本相机或相机堆栈。有关过度绘制的详细信息,请参阅高级信息

您可以使用基本摄像机的Output Target属性来定义渲染目标,使用Viewport Rect属性来定义要渲染的渲染目标区域。有关视口坐标的更多信息,请参阅Unity手册API文档

Setting up split screen rendering

1. 在你的场景中创建一个摄像机。它的渲染模式默认为Base,这使它成为一个Base Camera。

2. 选择相机。在检查器中,滚动到Output部分。确保输出目标设置为Camera,并将Viewport rect的值更改为:

  • X: 0
  • Y: 0
  • W: 0.5
  • H: 1

3. 在场景中创建另一个摄像机。它的渲染模式默认为Base,这使它成为一个Base Camera。

4. 选择相机。在检查器中,滚动到Output部分。确保输出目标设置为Camera,并将Viewport rect的值更改为:

  • X: 0.5
  • Y: 0
  • W: 0.5
  • H: 1

Unity将第一个摄像机渲染在屏幕的左边,第二个摄像机呈现在屏幕的右边。

你可以在脚本中通过设置摄像头的rect属性来改变摄像头的Viewport rect,像这样:

myUniversalAdditionalCameraData.rect = new Rect(0.5f, 0f, 0.5f, 0f);

Rendering to a Render Texture

在通用渲染管线(URP),摄像机可以渲染到屏幕或渲染纹理。渲染到屏幕是默认的,也是最常见的方式,但是渲染到渲染纹理允许您创建像CCTV摄像机监视器这样的效果。

如果你有一个正在渲染纹理的相机,你必须有第二个相机来渲染纹理到屏幕上。在URP中,所有为渲染纹理而渲染的摄像机在所有渲染到屏幕的摄像机之前执行渲染循环。这确保渲染纹理准备好渲染到屏幕上。有关URP中摄像机渲染顺序的更多信息,请参见渲染顺序和过度绘制

Rendering to a Render Texture, and then rendering that Render Texture to the screen

使用Assets > CreateRender Texture在你的项目中创建一个渲染纹理资产。在你的场景中创建一个矩形面。在项目中创建一个材质,并选择它。在检查器中,拖动渲染纹理到材质的基础贴图字段。在场景视图中,将材质拖放到矩形上。在你的场景中创建一个摄像机。它的渲染模式默认为Base,这使它成为一个Base Camera。选择基相机。在检查器中,滚动到Output部分。将摄像机的输出目标设置为纹理,并将渲染纹理拖放到纹理域中。在场景中创建另一个摄像机。它的渲染模式默认为Base,这使它成为一个Base Camera。将矩形面放置在新相机的视角内。

第一个摄像机将其视图渲染到渲染纹理中。第二个摄像机渲染场景,包括渲染纹理到屏幕。

通过设置相机通用附加相机数据组件的cameraOutput属性,可以在脚本中设置相机的输出目标,如下所示:

myUniversalAdditionalCameraData.cameraOutput = CameraOutput.Texture;
myCamera.targetTexture = myRenderTexture;

Clearing, rendering order and overdraw

Clearing

在通用渲染管道(URP)中,相机的清除行为取决于相机的渲染类型。

Base Camera

Color buffer


在渲染循环的开始,一个基础相机可以清除它的颜色缓冲到一个Skybox,清除它的颜色缓冲到一个纯色,或者使用一个未初始化的颜色缓冲。您可以使用基础摄像机检查器中的背景类型属性来选择此行为。

请注意,未初始化的颜色缓冲区的内容因平台而异。在一些平台上,统一的颜色缓冲区将包含来自前一帧的数据。在其他平台上,unitialized color buffer将包含unintialized memory。只有当您的相机绘制到颜色缓冲区的每个像素时,您才应该选择使用单一化颜色缓冲区,并且您不希望产生不必要的清除操作的成本。

Depth buffer


基础相机总是在每次渲染循环开始时清除它的深度缓冲区。

Overlay Camera

Color buffer


在渲染循环的开始,覆盖摄像机接收一个颜色缓冲区,其中包含来自摄像机堆栈中以前的摄像机的颜色数据。它不清除颜色缓冲区的内容。

Depth buffer


在渲染循环的开始,覆盖摄像机接收一个深度缓冲区,其中包含来自摄像机堆栈中的前一个摄像机的深度数据。你可以使用覆盖相机检查器中的Clear Depth属性来选择这个行为。

当Clear Depth设置为true时,Overlay Camera会清除Depth buffer,并将视图绘制到任何现有颜色数据的颜色buffer上。当Clear Depth设置为false时,覆盖相机在将视图绘制到颜色缓冲区之前会对深度缓冲区进行测试。

Camera culling and rendering order

如果你的URP场景包含多个摄像机,Unity会按照可预测的顺序执行它们的剔除和渲染操作。

Unity每帧执行一次操作:

  • Unity获取场景中所有活动基础摄像头的列表。
  • Unity将活动的基础摄像机分成两组:渲染视图来渲染纹理的摄像机和渲染视图到屏幕上的摄像机。
  • Unity将渲染纹理的基础相机按优先级排序,因此具有较高优先级值的相机会被最后绘制。
  • 对于每个渲染到渲染纹理的基础摄像机,Unity执行以下步骤:
  1. 选择基础摄像机
  2. 将基础摄像机渲染到渲染纹理中
  3. 对于属于基础摄像机摄像机堆栈的每个覆盖摄像机,按照摄像机堆栈中定义的顺序:

   1. 选择覆盖相机

   2. 将叠加的摄像机渲染到渲染纹理中

  • Unity将渲染到屏幕上的基础相机按优先级排序,因此具有较高优先级值的相机被绘制到最后。
  • 对于渲染到屏幕上的每个基础摄像头,Unity执行以下步骤:
  1. 选择基础摄像机
  2. 将基础摄像机渲染到屏幕上
  3. 对于属于基础摄像机摄像机堆栈的每个覆盖摄像机,按照摄像机堆栈中定义的顺序:

   1. 选择覆盖相机

   2. 将覆盖的摄像机渲染到屏幕上

Unity可以在一个帧中多次渲染一个叠加摄像机的视图——要么是因为叠加摄像机出现在多个摄像机堆栈中,要么是因为叠加摄像机出现在同一个摄像机堆栈中不止一次。当发生这种情况时,Unity不会重用裁剪或渲染操作中的任何元素。这些操作按照上面详细描述的顺序完全重复。

重要提示:在URP的这个版本中,只有在使用前向渲染器时才支持覆盖相机和相机堆叠。如果使用2D渲染器,覆盖相机将不会执行渲染循环的任何部分。

Overdraw

URP在相机内执行多个优化,包括渲染顺序优化以减少过度绘制。但是,在使用摄像机堆栈时,可以有效地定义渲染这些摄像机的顺序。因此,你必须小心,不要以导致过度绘制的方式订制相机。

当一个摄像机堆栈中的多个摄像机渲染到相同的渲染目标时,Unity为摄像机堆栈中的每个摄像机绘制渲染目标中的每个像素。此外,如果有多个基础摄像机或摄像机堆栈渲染到相同渲染目标的相同区域,Unity将在重叠区域再次绘制任何像素,次数视每个基本摄像机或摄像机堆栈的需要而定。

你可以使用Unity的框架调试器,或者特定于平台的框架捕获和调试工具,来了解在你的场景中过度绘制发生在哪里。然后你可以相应地优化你的相机堆栈。

Camera component reference

在通用渲染管线(URP)中,Unity在检查器中根据不同的摄像机类型公开不同的摄像机组件属性。

Base Camera component reference

当相机的渲染模式设置为Base时,相机检查器有以下部分。点击下面相应的链接,或在页面上向下滚动:

Projection

PropertyDescription
Render Mode

Controls which type of Camera this is.

控制这是哪一种相机。

Projection

Toggles the camera's capability to simulate perspective.

切换相机模拟透视的能力。

        Perspective

Camera will render objects with perspective intact.

相机将使用完整透视渲染对象。

        Orthographic

Camera will render objects uniformly, with no sense of perspective.

相机会均匀地渲染物体,没有透视感。

Size

The viewport size of the Camera when set to Orthographic.

设置为正投影时相机的视口大小。

FOV Axis

Field of view axis.

视场轴。

Field of view

The width of the Camera's view angle, measured in degrees along the selected axis.

相机视角的宽度,以沿选定轴的角度为单位进行测量。

Physical Camera

Tick this box to enable the Physical Camera properties for this camera. 

When the Physical Camera properties are enabled, Unity calculates the Field of Viewusing the properties that simulate real-world camera attributes: Focal LengthSensor Size, and Lens Shift

Physical Camera properties are not visible in the Inspector until you tick this box.

勾选此框以启用此相机的物理相机属性。

 

当启用物理相机属性时,Unity会使用模拟真实相机属性的属性来计算视场:焦距、传感器大小和镜头位移。

 

物理相机属性在检查器中是不可见的,直到你勾选这个框。

        Focal Length

Set the distance, in millimeters, between the camera sensor and the camera lens.

Lower values result in a wider Field of View, and vice versa. 

When you change this value, Unity automatically updates the Field of Viewproperty accordingly.

设置相机传感器和相机镜头之间的距离,以毫米为单位。

 

值越低,视场越宽,反之亦然。

 

当你改变这个值时,Unity会自动相应地更新Viewproperty的字段。

        Sensor Type

Specify the real-world camera format you want the camera to simulate. Choose the desired format from the list. 

When you choose a camera format, Unity sets the the Sensor Size > X and Y properties to the correct values automatically. 

If you change the Sensor Size values manually, Unity automatically sets this property to Custom.

指定您希望摄像机模拟的真实摄像机格式。从列表中选择所需的格式。
当你选择相机格式时,Unity会自动将传感器大小> X和Y设置为正确的值。
如果你手动改变传感器的尺寸值,Unity会自动将此属性设置为自定义。

        Sensor Size

Set the size, in millimeters, of the camera sensor. 

Unity sets the X and Y values automatically when you choose the Sensor Type. You can enter custom values if needed.

设置相机传感器的大小,以毫米为单位。
当您选择传感器类型时,Unity会自动设置X和Y值。如果需要,您可以输入自定义值。

                X

The width of the sensor.

传感器的宽度。

                Y

The height of the sensor.

传感器的高度。

        Lens Shift

Shift the lens horizontally or vertically from center. Values are multiples of the sensor size; for example, a shift of 0.5 along the X axis offsets the sensor by half its horizontal size. 

You can use lens shifts to correct distortion that occurs when the camera is at an angle to the subject (for example, converging parallel lines). 

Shift the lens along either axis to make the camera frustum oblique.

将镜头从中心水平或垂直移动。值为传感器尺寸的倍数;例如,沿着X轴移动0.5会使传感器的水平尺寸偏移一半。
你可以使用镜头移位来纠正相机与被摄主体成一定角度时发生的畸变(例如,趋同平行线)。
沿任何一个轴移动镜头,使相机的视锥架倾斜。

                X

The horizontal sensor offset.

水平传感器偏移。

                Y

The vertical sensor offset.

垂直传感器偏移。

        Gate Fit

Options for changing the size of the resolution gate (size/aspect ratio of the game view) relative to the film gate (size/aspect ratio of the Physical Camera sensor). 

For further information about resolution gate and film gate, see documentation on Physical Cameras.

改变分辨率门(游戏视图的大小/宽高比)相对于胶片门(物理相机传感器的大小/宽高比)的选项。
有关分辨率门和胶片门的进一步信息,请参阅物理相机的文档。

                Vertical

Fits the resolution gate to the height of the film gate. 

If the sensor aspect ratio is larger than the game view aspect ratio, Unity crops the rendered image at the sides. 

If the sensor aspect ratio is smaller than the game view aspect ratio, Unity overscans the rendered image at the sides. 

When you choose this setting, changing the sensor width (Sensor Size > X property) has no effect on the rendered image.

将分辨率门与胶片门的高度匹配。
如果传感器的高宽比大于游戏视图的高宽比,Unity就会在侧面裁剪渲染的图像。
如果传感器的高宽比小于游戏视图的高宽比,Unity就会在侧面扫描渲染的图像。
当您选择此设置时,改变传感器宽度(传感器大小> X属性)对渲染的图像没有影响。

                Horizontal

Fits the resolution gate to the width of the film gate. 

If the sensor aspect ratio is larger than the game view aspect ratio, Unity overscans the rendered image on the top and bottom. 

If the sensor aspect ratio is smaller than the game view aspect ratio, Unity crops the rendered image on the top and bottom. 

When you choose this setting, changing the sensor height (Sensor Size > Y property) has no effect on the rendered image.

将分辨率门与胶片门的宽度匹配。
如果传感器的纵横比大于游戏视图的纵横比,Unity就会在顶部和底部扫描渲染的图像。
如果传感器的高宽比小于游戏视图的高宽比,Unity将在顶部和底部裁剪渲染图像。
当您选择此设置时,改变传感器高度(传感器大小> Y属性)对渲染的图像没有影响。

                Fill

Fits the resolution gate to either the width or height of the film gate, whichever is smaller. This crops the rendered image.

使分辨率门与胶片门的宽度或高度匹配,以较小的为准。这样可以裁剪渲染的图像。

                Overscan

Fits the resolution gate to either the width or height of the film gate, whichever is larger. This overscans the rendered image.

使分辨率门适应胶片门的宽度或高度,以较大的为准。这将扫描渲染的图像。

                None

Ignores the resolution gate and uses the film gate only. This stretches the rendered image to fit the game view aspect ratio.

忽略分辨率门,只使用胶片门。这将拉伸渲染的图像以适应游戏视图的高宽比。

Clipping Planes

Distances from the camera to start and stop rendering.

从相机开始和停止渲染的距离。

        Near

The closest point relative to the Camera that drawing will occur.

相对于摄像机最近的绘制点。

        Far

The furthest point relative to the Camera that drawing will occur.

相对于相机的最远的绘制点。

Rendering

PropertyDescription
Renderer

Controls which renderer this Camera uses.

控制这个相机使用哪个渲染器。

Post Processing

Enables post-processing effects.

激活后期处理效果。

Anti-aliasing

Use the drop-down to select the method that this Camera uses for post-process anti-aliasing. A Camera can still use multisample anti-aliasing (MSAA), which is a hardware feature, at the same time as post-process anti-aliasing.
• None: This Camera can process MSAA but does not process any post-process anti-aliasing.
• Fast Approximate Anti-aliasing (FXAA): Smooths edges on a per-pixel level. This is the least resource intensive anti-aliasing technique in URP.
• Subpixel Morphological Anti-aliasing (SMAA): Finds patterns in borders of the image and blends the pixels on these borders according to the pattern.

使用下拉菜单选择此相机用于后期反锯齿的方法。相机仍然可以使用多重抗混叠(MSAA),这是一个硬件特性,同时进行后期抗混叠。

无:这款相机可以处理MSAA,但不处理任何后期反锯齿。

•快速近似抗锯齿(FXAA):按像素级平滑边缘。这是URP中资源消耗最少的反混叠技术。

•亚像素形态反走样(SMAA):在图像的边界中找到模式,并根据模式在这些边界上混合像素。

        Quality

Use the drop-down to select the quality of SMAA. The difference in resource intensity is fairly small between Low and High.
• Low: The lowest SMAA quality. This is the least resource-intensive option.
• Medium: A good balance between SMAA quality and resource intensity.
• High: The highest SMAA quality. This is the most resource-intensive option.

This property only appears when you select Subpixel Morphological Anti-aliasing (SMAA) from the Anti-aliasing drop-down.

使用下拉菜单选择SMAA的质量。低、高资源强度的差异比较小。

低:最低的SMAA质量。这是资源密集度最低的选择。

•中等:SMAA质量和资源强度之间的良好平衡。

高:最高的SMAA质量。这是最耗费资源的选择。

 

此属性仅在从“抗锯齿”下拉菜单中选择“亚像素形态抗锯齿”(SMAA)时出现。

Stop NaN

Enable the checkbox to make this Camera replace values that are Not a Number (NaN) with a black pixel. This stops certain effects from breaking, but is a resource-intensive process. Only enable this feature if you experience NaN issues that you can not fix.

启用复选框使该摄像机将非数字(NaN)的值替换为黑色像素。这阻止了某些效应的破坏,但这是一个资源密集的过程。只有在遇到无法修复的NaN问题时才启用此特性。

Dithering

Enable the checkbox to apply 8-bit dithering to the final render. This can help reduce banding on wide gradients and low light areas.

复选框应用8位抖动到最终渲染。这可以帮助减少宽梯度和低光区域的带。

Render Shadows

Enables shadow rendering.

允许阴影渲染。

Priority

A Camera with a higher priority is drawn on top of a Camera with a lower priority. [-100, 100]

具有较高优先级的照相机绘制在具有较低优先级的照相机之上。(-100、100)

Opaque Texture

Controls whether the Camera creates a CameraOpaqueTexture, which is a copy of the rendered view.

控制摄像机是否创建CameraOpaqueTexture,它是已渲染视图的副本。

        On

Camera creates a CameraOpaqueTexture.

相机创建相机不透明贴图。

        Off

Camera does not create a CameraOpaqueTexture.

相机不会创建相机不透明贴图。

        Use Pipeline Settings

The value of this setting is determined by the Render Pipeline Asset.

该设置的值由渲染管线资产决定。

Depth Texture

Controls whether the Camera creates CameraDepthTexture, which is a copy of the rendered depth values.

控制相机是否创建CameraDepthTexture,它是渲染的深度值的副本。

        On

The Camera creates a CameraDepthTexture.

相机创建了一个CameraDepthTexture。

        Off

The Camera does not create a CameraDepthTexture.

相机不会创建CameraDepthTexture。

        Use Pipeline Settings

The value of this setting is determined by the Render Pipeline Asset.

该设置的值由渲染管线资产决定。

Culling Mask

Which Layers the Camera renders to.

相机渲染到的图层。

Occlusion Culling

Enables Occlusion Culling.

使用遮挡剔除

Environment

PropertyDescription
Background Type

Controls how to initialize the color buffer at the start of this Camera's render loop. For more information, see the documentation on clearing.

控制如何在相机的渲染循环开始时初始化颜色缓冲区。有关更多信息,请参阅有关清除的文档。

        Skybox

Initializes the color buffer by clearing to a Skybox. Defaults to a background color if no Skybox is found.

初始化颜色缓冲区清除到一个天空盒。如果没有找到Skybox,默认为背景色。

        Solid Color

Initializes the color buffer by clearing to a given color.

通过清除到给定的颜色来初始化颜色缓冲区。

        Uninitialized

Does not initialize the color buffer. Choose this option only if your Camera or Camera Stack will draw to every pixel in the color buffer.

不初始化颜色缓冲区。只有当您的相机或相机堆栈将绘制到颜色缓冲区中的每个像素时,才选择此选项。

Background

The Camera clears its color buffer to this colour before rendering.
This property only appears when you select Solid Color from the Background Type drop-down.

照相机在渲染前将其颜色缓冲清除为这种颜色。
此属性仅在从“背景类型”下拉菜单中选择“纯色”时出现。

Volume Mask

Use the drop-down to set the Layer Mask that defines which Volumes affect this Camera.

使用下拉菜单设置图层蒙版,定义影响相机的音量。

Volume Trigger

Assign a Transform that the Volume system uses to handle the position of this Camera. For example, if your application uses a third person view of a character, set this property to the character's Transform. The Camera then uses the post-processing and Scene settings for Volumes that the character enters. If you do not assign a Transform, the Camera uses its own Transform instead.

指定一个Transform ,体积系统使用它来处理这个摄像机的位置。例如,如果应用程序使用角色的第三人称视图,则将此属性设置为角色的Transform 。然后,相机使用后期处理和场景设置的体积,处理角色进入。如果你不分配Transform ,相机会使用它自己的Transform 。

Output

注意,当一个相机的渲染模式被设置为Base,而它的渲染目标被设置为Texture时,Unity不会在相机的检查器中暴露以下属性:

  • HDR
  • MSAA
  • Allow Dynamic Resolution
  • Target Display

这是因为渲染纹理决定了这些属性。要更改它们,请在渲染纹理资产上这样做。

PropertyDescription
Output Texture

Renders this Camera's output to a RenderTexture if this field is assigned, otherwise renders to screen.

如果这个字段被分配,将这个摄像机的输出渲染到渲染纹理,否则渲染到屏幕上。

HDR

Enables High Dynamic Range rendering for this camera.
This property only appears when you select Screenfrom the Output Target drop-down.

为这个相机启用高动态范围渲染。
此属性仅在从输出目标下拉列表中选择screen时出现。

MSAA

Enables multi sample antialiasing for this camera.
This property only appears when you select Screenfrom the Output Target drop-down.

为该相机启用多样本反锯齿。
此属性仅在从输出目标下拉列表中选择screen时出现。

Viewport Rect

Four values that indicate where on the screen this camera view will be drawn. Measured in Viewport Coordinates (values 0-1). This property only appears when you select Screen from the Output Target drop-down.

四个值,表示这个摄像机视图将在屏幕上绘制的位置。以视口坐标(值0-1)测量。此属性仅在从输出目标下拉列表中选择Screen时出现。

        X

The beginning horizontal position that the camera view will be drawn.

摄像机视图将被绘制的开始水平位置。

        Y

The beginning vertical position that the camera view will be drawn.

摄像机视图将被绘制的开始垂直位置。

        W(Width)

Width of the camera output on the screen.

摄像机在屏幕上输出的宽度。

        H(Height)

Height of the camera output on the screen.

屏幕上显示相机输出的高度。

Allow Dynamic Resolution

Enables Dynamic Resolution rendering for this Camera.
This property only appears when you select Screenfrom the Output Target drop-down.

启用此相机的动态分辨率渲染。
此属性仅在从输出目标下拉列表中选择screen时出现。

Target Display

Defines which external device to render to. Between 1 and 8.
This property only appears when you select Screenfrom the Output Target drop-down.

定义要渲染到的外部设备。在1到8之间。
此属性仅在从输出目标下拉列表中选择screen时出现。

Stack

相机堆栈允许将多个相机的结果组合在一起。相机堆栈由一个基础相机和任意数量的附加覆盖相机组成。

您可以使用堆栈属性向堆栈添加叠加摄像机,它们将按照堆栈中定义的顺序渲染。有关配置和使用相机堆栈的详细信息,请参阅相机堆栈

Overlay Camera component reference

当你使用相机堆叠时,相机堆叠的基础相机决定了相机堆叠的大部分属性。因为覆盖相机只能作为相机堆栈的一部分使用,你只能在覆盖相机上配置有限数量的设置。未分配到摄像机堆栈的叠加摄像机将跳过渲染。

当相机的渲染模式设置为叠加时,相机检查器有以下部分。点击下面相应的链接,或在页面上向下滚动:

Projection

PropertyDescription
Render Mode

Controls which type of Camera this is.

控制这是哪一种相机。

Projection

Toggles the camera's capability to simulate perspective.

切换相机模拟透视的能力。

        Perspective

Camera will render objects with perspective intact.

相机将使用完整透视渲染对象。

        Orthographic

Camera will render objects uniformly, with no sense of perspective.

相机会均匀地渲染物体,没有透视感。

Size (when Orthographic is selected)

The viewport size of the Camera when set to Orthographic.

设置为正投影时相机的视口大小。

FOV Axis (when Perspective is selected)

Field of view axis.

视场轴。

Field of view(when Perspective is selected)

The width of the Camera's view angle, measured in degrees along the selected axis.

相机视角的宽度,以沿选定轴的角度为单位进行测量。

Physical Camera

Tick this box to enable the Physical Camera properties for this camera. 

When the Physical Camera properties are enabled, Unity calculates the Field of Viewusing the properties that simulate real-world camera attributes: Focal LengthSensor Size, and Lens Shift

Physical Camera properties are not visible in the Inspector until you tick this box.

勾选此框以启用此相机的物理相机属性。

 

当启用物理相机属性时,Unity会使用模拟真实相机属性的属性来计算视场:焦距、传感器大小和镜头位移。

 

物理相机属性在检查器中是不可见的,直到你勾选这个框。

        Focal Length

Set the distance, in millimeters, between the camera sensor and the camera lens.

Lower values result in a wider Field of View, and vice versa. 

When you change this value, Unity automatically updates the Field of Viewproperty accordingly.

设置相机传感器和相机镜头之间的距离,以毫米为单位。

 

值越低,视场越宽,反之亦然。

 

当你改变这个值时,Unity会自动相应地更新Viewproperty的字段。

        Sensor Type

Specify the real-world camera format you want the camera to simulate. Choose the desired format from the list. 

When you choose a camera format, Unity sets the the Sensor Size > X and Y properties to the correct values automatically. 

If you change the Sensor Size values manually, Unity automatically sets this property to Custom.

指定您希望摄像机模拟的真实摄像机格式。从列表中选择所需的格式。
当你选择相机格式时,Unity会自动将传感器大小> X和Y设置为正确的值。
如果你手动改变传感器的尺寸值,Unity会自动将此属性设置为自定义。

        Sensor Size

Set the size, in millimeters, of the camera sensor. 

Unity sets the X and Y values automatically when you choose the Sensor Type. You can enter custom values if needed.

设置相机传感器的大小,以毫米为单位。
当您选择传感器类型时,Unity会自动设置X和Y值。如果需要,您可以输入自定义值。

                X

The width of the sensor.

传感器的宽度。

                Y

The height of the sensor.

传感器的高度。

        Lens Shift

Shift the lens horizontally or vertically from center. Values are multiples of the sensor size; for example, a shift of 0.5 along the X axis offsets the sensor by half its horizontal size. 

You can use lens shifts to correct distortion that occurs when the camera is at an angle to the subject (for example, converging parallel lines). 

Shift the lens along either axis to make the camera frustum oblique.

将镜头从中心水平或垂直移动。值为传感器尺寸的倍数;例如,沿着X轴移动0.5会使传感器的水平尺寸偏移一半。
你可以使用镜头移位来纠正相机与被摄主体成一定角度时发生的畸变(例如,趋同平行线)。
沿任何一个轴移动镜头,使相机的视锥架倾斜。

                X

The horizontal sensor offset.

水平传感器偏移。

                Y

The vertical sensor offset.

垂直传感器偏移。

        Gate Fit

Options for changing the size of the resolution gate (size/aspect ratio of the game view) relative to the film gate (size/aspect ratio of the Physical Camera sensor). 

For further information about resolution gate and film gate, see documentation on Physical Cameras.

改变分辨率门(游戏视图的大小/宽高比)相对于胶片门(物理相机传感器的大小/宽高比)的选项。
有关分辨率门和胶片门的进一步信息,请参阅物理相机的文档。

                Vertical

Fits the resolution gate to the height of the film gate. 

If the sensor aspect ratio is larger than the game view aspect ratio, Unity crops the rendered image at the sides. 

If the sensor aspect ratio is smaller than the game view aspect ratio, Unity overscans the rendered image at the sides. 

When you choose this setting, changing the sensor width (Sensor Size > X property) has no effect on the rendered image.

将分辨率门与胶片门的高度匹配。
如果传感器的高宽比大于游戏视图的高宽比,Unity就会在侧面裁剪渲染的图像。
如果传感器的高宽比小于游戏视图的高宽比,Unity就会在侧面扫描渲染的图像。
当您选择此设置时,改变传感器宽度(传感器大小> X属性)对渲染的图像没有影响。

                Horizontal

Fits the resolution gate to the width of the film gate. 

If the sensor aspect ratio is larger than the game view aspect ratio, Unity overscans the rendered image on the top and bottom. 

If the sensor aspect ratio is smaller than the game view aspect ratio, Unity crops the rendered image on the top and bottom. 

When you choose this setting, changing the sensor height (Sensor Size > Y property) has no effect on the rendered image.

将分辨率门与胶片门的宽度匹配。
如果传感器的纵横比大于游戏视图的纵横比,Unity就会在顶部和底部扫描渲染的图像。
如果传感器的高宽比小于游戏视图的高宽比,Unity将在顶部和底部裁剪渲染图像。
当您选择此设置时,改变传感器高度(传感器大小> Y属性)对渲染的图像没有影响。

                Fill

Fits the resolution gate to either the width or height of the film gate, whichever is smaller. This crops the rendered image.

使分辨率门与胶片门的宽度或高度匹配,以较小的为准。这样可以裁剪渲染的图像。

                Overscan

Fits the resolution gate to either the width or height of the film gate, whichever is larger. This overscans the rendered image.

使分辨率门适应胶片门的宽度或高度,以较大的为准。这将扫描渲染的图像。

                None

Ignores the resolution gate and uses the film gate only. This stretches the rendered image to fit the game view aspect ratio.

忽略分辨率门,只使用胶片门。这将拉伸渲染的图像以适应游戏视图的高宽比。

Clipping Planes

Distances from the camera to start and stop rendering.

从相机开始和停止渲染的距离。

        Near

The closest point relative to the Camera that drawing will occur.

相对于摄像机最近的绘制点。

        Far

The furthest point relative to the Camera that drawing will occur.

相对于相机的最远的绘制点。

Rendering

PropertyDescription
Renderer

Controls which renderer this Camera uses.

控制这个相机使用哪个渲染器。

Post Processing

Enables post-processing effects.

激活后期处理效果。

Clear Depth

If enabled, the depth buffer from the previous Camera will be cleared at the start of this Camera's render loop. For more information, see the documentation on clearing.

如果启用,前一个相机的深度缓冲将在这个相机的渲染循环开始时被清除。有关更多信息,请参阅有关清除的文档。

Render Shadows

Enables shadow rendering.

激活阴影渲染。

Culling Mask

Which Layers the Camera renders to.

相机渲染到的图层。

Occlusion Culling

Enables Occlusion Culling.

使用遮挡剔除

Environment

PropertyDescription
Volume Mask

Use the drop-down to set the Layer Mask that defines which Volumes affect this Camera.

使用下拉菜单设置图层蒙版,定义影响相机的体积。

Volume Trigger

Assign a Transform that the Volume system uses to handle the position of this Camera. For example, if your application uses a third person view of a character, set this property to the character's Transform. The Camera then uses the post-processing and Scene settings for Volumes that the character enters. If you do not assign a Transform, the Camera uses its own Transform instead.

指定一个Transform ,体积系统使用它来处理这个摄像机的位置。例如,如果应用程序使用角色的第三人称视图,则将此属性设置为角色的Transform 。然后,相机使用后期处理和场景设置的体积,处理角色进入。如果你不分配Transform ,相机会使用它自己的Transform 。

  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值