Version: 2019.4
可编程渲染管线
创建自定义的可编程渲染管线

Scriptable Render Pipeline introduction

This page explains how the Scriptable Render Pipeline (SRP) works, and introduces some key concepts and terminology.

SRP is a thin API layer that lets you schedule and configure rendering commands using C# scripts. SRP passes these commands to Unity’s low-level graphics architecture, which then sends instructions to the graphics API.

The Render Pipeline Asset and Render Pipeline Instance

When you write C# rendering code in SRP, you must create and customise two key elements:

  • A Render Pipeline Asset is an asset in your Unity Project that stores configuration data about your SRP. You define a Render Pipeline Asset by creating a script that inherits from Rendering.RenderPipelineAsset, and then you create and configure instances of the Render Pipeline Asset in your Project.
  • A Render Pipeline Instance is a class with a Render() method that is the entry point to SRP. To define a Render Pipeline Instance, you create a script that inherits from RenderPipeline.

For information about creating these elements, see Creating a Render Pipeline Asset and a Render Pipeline Instance.

The Scriptable Render Context

The Scriptable Render Context is a class that acts as an interface between your C# SRP code and Unity’s low-level graphics code. You schedule and execute rendering commands using the ScriptableRenderContext API.

For information about using the Scriptable Render Context, see Scheduling and executing rendering commands in the Scriptable Render Pipeline.

Entry points and callbacks

In SRP, you can write C# rendering code that Unity calls at specific times.

  • The Render() method of the Render Pipeline Instance is the entry point to the SRP. Unity calls this method once per frame for each CameraType that is currently rendering. Customize this method to customize your SRP.
  • The RenderPipelineManager class has four events: beginFrameRendering, beginCameraRendering, endCameraRendering, and endFrameRendering. You can subscribe to these events to execute code at specific points in the render pipeline. Note that if you are writing your own custom SRP, you must ensure that your SRP raises these events at appropriate times.
可编程渲染管线
创建自定义的可编程渲染管线