Render Type

请尊重原作者的工作,转载时请务必注明转载自:www.xionggf.com

URP版本:8.2.0

源参考网页

通用渲染管线(URP)中有两种类型的相机:

  • Base Camera: 通用的相机,其拍摄到的内容将会绘制到一个render target上,比如绘制到屏幕上,或者绘制到一个rendered texture。
  • Overlay Camera:覆盖式相机:其拍摄的内容将会绘制到某一个相机拍摄的内容之上。可以将Base Camera的输出,与一个或多个Overlay Camera的输出组合在一起。这称为相机堆叠(camera stack)

可以在Camera组件的 【Render Type】 选项菜单中指定摄像机为Base或者Overlay。可以通过照相机的通用附加照相机数据组件的属性,来在脚本中更改照相机的类型,如下所示:

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

Base Camera

Base Camera是URP中默认的摄像机类型。Base Camera是可渲染到给定渲染目标的通用相机。要在URP中渲染任何东西,您的场景中必须至少有一个Base Camera。一个场景中可以有多个Base Camera。您可以单独使用Base Camera,也可以在相机堆栈中使用它。有关在URP中使用多个摄像机的更多信息,请参阅使用多个摄像机

Overlay Camera

叠加摄影机是一种将其视图呈现在另一个摄影机的输出之上的摄影机。您可以使用“叠加相机”来创建效果,例如2D UI中的3D对象或车辆的驾驶舱。

您必须使用“摄像机堆叠”系统将“叠加摄像机”与一个或多个“基本摄像机”结合使用。您不能单独使用覆盖式摄像机。不属于“摄影机堆栈”的“重叠摄影机”不会执行其渲染循环的任何步骤,因此称为“孤立摄影机”。

重要说明:在此版本的URP中,仅当使用正向渲染器时才支持“叠加摄影机”和“摄影机堆叠”。

当您的场景中有活动的“覆盖相机”时,此图标将在“场景”视图中的“相机小控件”旁边显示:

叠加相机图标

摄像机堆栈中的基本摄像机确定了摄像机堆栈的大多数属性。由于只能在摄像机堆栈中使用叠加摄像机,因此在渲染场景时,URP仅使用叠加摄像机的以下属性:

投影 FOV轴 视场 物理相机属性 剪裁计划 渲染器 清除深度 不透明的纹理 深度纹理 渲染阴影 剔骨面具 咬合剔除 Unity在检查器中隐藏了所有其他未使用的属性。您可以使用脚本来访问未使用的属性,但是对这些未使用的属性进行的任何更改都不会影响使用“覆盖相机”的任何“相机堆栈”的视觉输出。

您不能将后期处理应用于单个“叠加式相机”。您可以将后处理应用于单个基本相机或相机堆栈。

有关Unity在重叠式摄像机的检查器中公开的属性的信息,请参见重叠式摄像机组件参考。

A Base Camera is a general purpose Camera that renders to a render target (a screen, or a Render Texture). An Overlay Camera renders on top of another Camera’s output. You can combine the output of a Base Camera with the output of one or more Overlay Cameras. This is called Camera stacking. Use a Camera’s Render Type property to make it a Base Camera or an Overlay Camera.

To change the type of a Camera in the Unity Editor:

Create or select a Camera in your Scene.

In the Camera Inspector, use the Render Type drop-down menu to select a different type of Camera. Select either:

Base to change the Camera to a Base Camera

Overlay to change the Camera to an Overlay Camera

Render Type in the Camera component Inspector

You can change a Camera’s type in a script, by setting the renderType property of the Camera’s Universal Additional Camera Data component, like this:

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

Base Camera Base Camera is the default type of Camera in URP. A Base Camera is a general purpose Camera that renders to a given render target.

To render anything in URP, you must have at least one Base Camera in your Scene. You can have multiple Base Cameras in a Scene. You can use a Base Camera on its own, or you can use it in a Camera stack. For more information on working with multiple Cameras in URP, see Working with multiple cameras.

When you have an active Base Camera in your Scene, this icon appears next to the Camera Gizmo in the Scene view:

Overlay Camera icon

For information on the properties that Unity exposes in the Inspector for a Base Camera, see the Base Camera component reference.

Overlay Camera An Overlay Camera is a Camera that renders its view on top of another Camera’s output. You can use Overlay Cameras to create effects such as 3D objects in a 2D UI, or a cockpit in a vehicle.

You must use Overlay Cameras in conjunction with one or more Base Cameras using the Camera Stacking system. You cannot use Overlay Cameras on their own. An Overlay Camera that is not part of a Camera Stack does not perform any steps of its render loop, and is known as an orphan Camera.

Important note: In this version of URP, Overlay Cameras and Camera Stacking are supported only when using the Forward Renderer.

When you have an active Overlay Camera in your Scene, this icon appears next to the Camera Gizmo in the Scene view:

Overlay Camera icon

The Base Camera in a Camera Stack determines most of the properties of the Camera Stack. Because you can only use Overlay Cameras in a Camera Stack, URP uses only the following properties of an Overlay Camera when rendering the Scene:

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 hides all of the other unused properties in the Inspector. You can access unused properties using a script, but any changes you make to these unused properties will not affect the visual output of any Camera Stacks that use the Overlay Camera.

You cannot apply post-processing to an individual Overlay Camera. You can apply post-processing to an individual Base Camera, or to a Camera Stack.

For information on the properties that Unity exposes in the Inspector of an Overlay Camera, see the Overlay Camera component reference.