Version: 2019.2
着色器:顶点和片元程序
可编程渲染管线 SRP Batcher

可编程渲染管线

A Scriptable Render Pipeline (SRP) is an alternative to the Unity built-in render pipeline. With an SRP, you can control and tailor rendering via C# scripts. This way, you can either slightly modify or completely build and customize the render pipeline to your needs.

An SRP gives you more granularity and customization options than the built-in Unity render pipeline. And you can use one of the pre-built SRPs to target your specific needs.

Using an SRP is different from using the built-in Unity render pipeline. For example, the pre-built SRPs use their own Shader library. This is because the Lit shaders from the built-in render pipeline, and custom Lit shaders, do not work with SRPs. You can upgrade the built-in Lit shaders to both LWRP and HDRP.

Unity has built two Scriptable Render Pipelines: the High Definition Render Pipeline (HDRP) and the Lightweight Render Pipeline (LWRP). Each render pipeline targets a specific set of use-case scenarios and hardware needs. The pre-built render pipelines are available as Project Templates.

Both of these render pipelines are delivered as packages via the Package Manager window in Unity. They both include the Shader Graph and Post-processing packages.

Note: HDRP and LWRP are not compatible with each other because they use different lighting models. Your Project must use one or the other. You can, however, use different Assets with the same render pipeline. This means that you can test different settings using different Assets by swapping between them, instead of changing individual settings.

If you are an advanced user, and you want to modify the SRP scripts to directly, see Creating a custom SRP.

Lightweight Render Pipeline (LWRP)

You can use LWRP across a wide range of hardware, from mobile platforms to higher-end consoles and PCs. LWRP uses simplified, physically-based Lighting and Materials to achieve quick rendering at a high quality. LWRP uses single-pass forward rendering, for optimized real-time performance on several platforms.

LWRP is available via two templates: LWRP and LWRP-VR. The LWRP-VR comes with pre-enabled VR settings.

注意:内置和自定义的光照着色器不适用于轻量级渲染管线。相反,LWRP 有一组新的标准着色器。如果将当前项目升级到 LWRP,可以将内置着色器升级到新的着色器。

For more information, see the LWRP documentation. Tip: You can also access the documentation via the Package Manager in Unity ( the Lightweight Render Pipeline package, and click View Documentation).

High Definition Render Pipeline (HDRP)

HDRP targets high-end hardware like consoles and PCs. With HDRP, you’re able to achieve realistic graphics in demanding scenarios. HDRP uses Compute Shader technology and therefore requires compatible GPU hardware.

Use HDRP for AAA quality games, automotive demos, architectural applications and anything that requires high-fidelity graphics over performance. HDRP uses physically-based Lighting and Materials, and supports both Forward and Deferred rendering.

To start using HDRP, create a Project using the HDRP Template.

For more information, see the HDRP documentation. Tip: You can also access the documentation via the Package Manager in Unity, find the High Definition Render Pipeline package, and click View Documentation.

Setting up LWRP or HDRP

To use LWRP or HDRP, you can either:

Creating a new Project with LWRP or HDRP

If you want to use HDRP or LWRP in a new Project, and you don’t need to customise the render pipeline, you can create a new Project using a Template.

To create a Project using a Template:

1.打开 Unity。在主页上,单击 New 启动一个新项目。 2.在 Template 下,选择其中一个渲染管线模板。 3.单击 Create Project。Unity 会自动为您创建一个新项目,并具备所含内置管线的所有功能。

有关使用模板的更多信息,请参阅项目模板

Converting an existing Project to LWRP or HDRP

You can download and install the latest version of LWRP or HDRP to your existing Project via the Package Manager system.

Switching to LWRP or HDRP from an existing Project consumes a lot of time and resources. LWRP and HDRP use custom shaders. They are not compatible with the built-in Unity shaders. You have to manually change or convert many elements. Instead, consider starting a new Project and using your render pipeline of choice.

To install LWRP or HDRP into an existing Project:

1.在 Unity 中,打开您的项目。 2.在 Unity 菜单栏中,选择 Window > Package Manager 以打开 Package Manager 窗口。 3.选择 All 选项卡。此选项卡显示当前运行的 Unity 版本的可用资源包列表。 4.从包列表中选择要使用的渲染管线。在该窗口的右上角,单击 Install。这会将渲染管线直接安装到项目中。

Preparing to use LWRP or HDRP

Before you can use LWRP or HDRP, you must create a Render Pipeline Asset and add it to your Project settings.

To create a Render Pipeline Asset for your render pipeline, see either the:

To assign the Render Pipeline Asset to your Project:

  1. Select Edit > Project Settings > Graphics, and locate the Scriptable Render Pipeline Settings property at the top.
  2. Either drag and drop the Render Pipeline Asset into the property field, or use the object picker (located on the right of the field) to select it from a list of all Assets in your Project.

Creating a custom SRP

可编程渲染管线在 GitHub 中作为开源项目提供。您可以克隆 SRP 并在本地版本中进行修改。

要为新的或现有的 Unity 项目配置本地脚本文件,请执行以下操作:

1.创建 SRP 代码仓库的克隆体。将克隆体放在项目目录的根目录中(_Assets_ 文件夹旁边)。有关克隆代码仓库的信息,请参阅 GitHub 中有关克隆代码仓库 (Cloning a repository) 的帮助。 2.签出与您的 Unity 版本兼容的分支。使用 git checkout 命令,并键入分支名称。 3.使用 git submodule update --init 命令查找并初始化与 SRP 相关的所有子模块。 4.在项目清单中,更新 dependencies 以便这些依赖项指向 SRP 包。要了解与项目清单相关的更多信息,请参阅 Package Manager 文档。您的脚本应该如以下示例所示:

```

{

   "dependencies": {
       "com.unity.postprocessing": "file:../ScriptableRenderPipeline/com.unity.postprocessing",

       "com.unity.render-pipelines.core": "file:../ScriptableRenderPipeline/com.unity.render-pipelines.core",

       "com.unity.shadergraph": "file:../ScriptableRenderPipeline/com.unity.shadergraph",

       "com.unity.render-pipelines.lightweight": "file:../ScriptableRenderPipeline/com.unity.render-pipelines.lightweight"

   }
}
```

5.在 Unity 中,打开您的项目。您的包现在已在本地安装。在集成开发环境中打开项目解决方案时,可以直接调试和修改脚本。


  • 2019–05–06 页面已修订

  • 2018.1 版中添加了可编程渲染管线的预览 NewIn20181

  • Scriptable Render Pipeline added in 2019.1 NewIn20191

着色器:顶点和片元程序
可编程渲染管线 SRP Batcher