着色器与材质
- 通用渲染管线的着色方法:通用渲染管线使用了与Unity内置渲染管线不同的着色方法。因此,内置的Lit着色器和自定义的Lit着色器在URP中并不适用。
- URP的着色器:URP提供了一套新的标准着色器,以应对最常见的使用场景。这些着色器包括:Lit、Simple Lit、Baked Lit、Unlit、Particles Lit、Particles Simple Lit、Particles Unlit、SpeedTree、Autodesk Interactive、Autodesk Interactive Transparent和Autodesk Interactive Masked。
- 升级建议:如果你将当前的项目升级到URP,你可以将内置的着色器升级到新的URP着色器。但是,内置渲染管线中的Unlit着色器仍然可以在URP中使用。
SpeedTree着色器
- 材质生成:对于SpeedTree着色器,当你重新导入它们时,Unity不会重新生成材质,除非你点击了“Generate Materials”或“Apply & Generate Materials”按钮。
Note: Unlit Shaders from the Unity built-in render pipeline work in URP.
- 注意:Unity内置渲染管线中的无光照着色器在通用渲染管线中也能工作。
Choosing a Shader
- 选择着色器:这部分描述了如何在URP中选择着色器。
With the Universal Render Pipeline, you can have real-time lighting with either Physically Based Shaders (PBS) and non-Physically Based Rendering (PBR).
- 使用通用渲染管线,你可以使用基于物理的着色器(Physically Based Shaders, PBS)或非基于物理的渲染(non-Physically Based Rendering, PBR)来实现实时光照。
For PBS, use the Lit Shader. You can use it on all platforms. The Shader quality scales depending on the platform, but keeps physically based rendering on all platforms. This gives you realistic graphics across hardware. The Unity Standard Shader and the Standard (Specular setup) Shaders both map to the Lit Shader in URP. For a list of Shader mappings, see section Shader mappings.
- 对于基于物理的着色器,使用Lit Shader。你可以在所有平台上使用它。着色器的质量会根据平台的不同而调整,但所有平台上都会保持基于物理的渲染。这为你提供了跨硬件的逼真图形。Unity的Standard Shader和Standard (Specular setup) Shaders在URP中都映射到Lit Shader。要查看着色器映射的列表,请参见“着色器映射”部分。
If you are targeting less powerful devices, or your project has simpler shading, use the Simple Lit shader, which is non-PBR.
- 如果你正在针对性能较低的设备,或者你的项目有简单的着色,那么使用非基于物理的Simple Lit着色器。
If you don’t need real-time lighting, or would rather only use baked lighting and sample global illumination, choose a Baked Lit Shader.
- 如果你不需要实时光照,或者只想使用烘焙光照和采样全局光照,那么选择一个Baked Lit Shader。
If you don’t need lighting on a Material at all, you can choose the Unlit Shader.
- 如果你在一个材质上根本不需要光照,那么可以选择Unlit Shader。
SRP Batcher compatibility
- SRP Batcher兼容性:这部分描述了如何确保着色器与SRP Batcher兼容。
To ensure that a Shader is SRP Batcher compatible:
Declare all Material properties in a single CBUFFER called UnityPerMaterial.
- 在一个名为UnityPerMaterial的单个CBUFFER中声明所有材质属性。
Declare all built-in engine properties, such as unity_ObjectToWorld or unity_WorldTransformParams, in a single CBUFFER called UnityPerDraw.
- 在一个名为UnityPerDraw的单个CBUFFER中声明所有内置引擎属性,如unity_ObjectToWorld或unity_WorldTransformParams。
For more information on the SRP Batcher, see the page Scriptable Render Pipeline (SRP) Batcher.
- 有关SRP Batcher的更多信息,请参阅“可脚本化渲染管线(Scriptable Render Pipeline, SRP)Batcher”页面。