Class ScriptableRenderer
Class ScriptableRenderer
implements a rendering strategy. It describes how culling and lighting works and
the effects supported.
A renderer can be used for all cameras or be overridden on a per-camera basis. It will implement light culling and setup
and describe a list of ScriptableRenderPass
to execute in a frame. The renderer can be extended to support more effect with additional
ScriptableRendererFeature
. Resources for the renderer are serialized in ScriptableRendererData
.
he renderer resources are serialized in ScriptableRendererData
.
ScriptableRendererData
ScriptableRendererFeature
ScriptableRenderPass
Inheritance
Namespace: UnityEngine.Rendering.Universal
Syntax
public abstract class ScriptableRenderer
Constructors
ScriptableRenderer(ScriptableRendererData)
Declaration
public ScriptableRenderer(ScriptableRendererData data)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRendererData | data |
Properties
activeRenderPassQueue
Declaration
protected List<ScriptableRenderPass> activeRenderPassQueue { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ScriptableRenderPass> |
cameraColorTarget
Declaration
public RenderTargetIdentifier cameraColorTarget { get; }
Property Value
Type | Description |
---|---|
RenderTargetIdentifier |
cameraDepth
Declaration
public RenderTargetIdentifier cameraDepth { get; }
Property Value
Type | Description |
---|---|
RenderTargetIdentifier |
rendererFeatures
Declaration
protected List<ScriptableRendererFeature> rendererFeatures { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ScriptableRendererFeature> |
Methods
ConfigureCameraTarget(RenderTargetIdentifier, RenderTargetIdentifier)
Configures the camera target.
Declaration
public void ConfigureCameraTarget(RenderTargetIdentifier colorTarget, RenderTargetIdentifier depthTarget)
Parameters
Type | Name | Description |
---|---|---|
RenderTargetIdentifier | colorTarget | Camera color target. Pass BuiltinRenderTextureType.CameraTarget if rendering to backbuffer. |
RenderTargetIdentifier | depthTarget | Camera depth target. Pass BuiltinRenderTextureType.CameraTarget if color has depth or rendering to backbuffer. |
EnqueuePass(ScriptableRenderPass)
Enqueues a render pass for execution.
Declaration
public void EnqueuePass(ScriptableRenderPass pass)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderPass | pass | Render pass to be enqueued. |
Execute(ScriptableRenderContext, ref RenderingData)
Execute the enqueued render passes. This automatically handles editor and stereo rendering.
Declaration
public void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderContext | context | Use this render context to issue any draw commands during execution. |
RenderingData | renderingData | Current render state information. |
FinishRendering(CommandBuffer)
Called upon finishing camera rendering. You can release any resources created on setup here.
Declaration
public virtual void FinishRendering(CommandBuffer cmd)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd |
GetCameraClearFlag(CameraClearFlags)
Returns a clear flag based on CameraClearFlags.
Declaration
protected static ClearFlag GetCameraClearFlag(CameraClearFlags cameraClearFlags)
Parameters
Type | Name | Description |
---|---|---|
CameraClearFlags | cameraClearFlags | Camera clear flags. |
Returns
Type | Description |
---|---|
ClearFlag | A clear flag that tells if color and/or depth should be cleared. |
Setup(ScriptableRenderContext, ref RenderingData)
Configures the render passes that will execute for this renderer. This method is called per-camera every frame.
Declaration
public abstract void Setup(ScriptableRenderContext context, ref RenderingData renderingData)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderContext | context | Use this render context to issue any draw commands during execution. |
RenderingData | renderingData | Current render state information. |
See Also
SetupCullingParameters(ref ScriptableCullingParameters, ref CameraData)
Override this method to configure the culling parameters for the renderer. You can use this to configure if lights should be culled per-object or the maximum shadow distance for example.
Declaration
public virtual void SetupCullingParameters(ref ScriptableCullingParameters cullingParameters, ref CameraData cameraData)
Parameters
Type | Name | Description |
---|---|---|
ScriptableCullingParameters | cullingParameters | Use this to change culling parameters used by the render pipeline. |
CameraData | cameraData | Current render state information. |
SetupLights(ScriptableRenderContext, ref RenderingData)
Override this method to implement the lighting setup for the renderer. You can use this to compute and upload light CBUFFER for example.
Declaration
public virtual void SetupLights(ScriptableRenderContext context, ref RenderingData renderingData)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderContext | context | Use this render context to issue any draw commands during execution. |
RenderingData | renderingData | Current render state information. |