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.
The renderer resources are serialized in ScriptableRendererData.
ScriptableRendererData
ScriptableRendererFeature
ScriptableRenderPass
Implements
Inherited Members
Namespace: UnityEngine.Rendering.Universal
Assembly: Unity.RenderPipelines.Universal.Runtime.dll
Syntax
public abstract class ScriptableRenderer : IDisposable
Constructors
ScriptableRenderer(ScriptableRendererData)
Creates a new ScriptableRenderer instance.
Declaration
public ScriptableRenderer(ScriptableRendererData data)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptableRendererData | data | The |
See Also
Fields
k_CameraTarget
The RTHandle for the Camera Target.
Declaration
protected static readonly RTHandle k_CameraTarget
Field Value
| Type | Description |
|---|---|
| RTHandle |
Properties
activeRenderPassQueue
Returns a list of render passes scheduled to be executed by this renderer. ScriptableRenderPass
Declaration
protected List<ScriptableRenderPass> activeRenderPassQueue { get; }
Property Value
| Type | Description |
|---|---|
| List<ScriptableRenderPass> |
cameraColorTargetHandle
Returns the camera color target for this renderer.
It's only valid to call cameraColorTarget in the scope of ScriptableRenderPass.
ScriptableRenderPass.
Declaration
public RTHandle cameraColorTargetHandle { get; }
Property Value
| Type | Description |
|---|---|
| RTHandle |
cameraDepthTargetHandle
Returns the camera depth target for this renderer.
It's only valid to call cameraDepthTarget in the scope of ScriptableRenderPass.
ScriptableRenderPass.
Declaration
public RTHandle cameraDepthTargetHandle { get; }
Property Value
| Type | Description |
|---|---|
| RTHandle |
profilingExecute
Override to provide a custom profiling name
Declaration
protected ProfilingSampler profilingExecute { get; set; }
Property Value
| Type | Description |
|---|---|
| ProfilingSampler |
rendererFeatures
Returns a list of renderer features added to this renderer. ScriptableRendererFeature
Declaration
protected List<ScriptableRendererFeature> rendererFeatures { get; }
Property Value
| Type | Description |
|---|---|
| List<ScriptableRendererFeature> |
supportedRenderingFeatures
Supported rendering features by this renderer. SupportedRenderingFeatures
Declaration
public ScriptableRenderer.RenderingFeatures supportedRenderingFeatures { get; set; }
Property Value
| Type | Description |
|---|---|
| ScriptableRenderer.RenderingFeatures |
unsupportedGraphicsDeviceTypes
List of unsupported Graphics APIs for this renderer. unsupportedGraphicsDeviceTypes
Declaration
public GraphicsDeviceType[] unsupportedGraphicsDeviceTypes { get; set; }
Property Value
| Type | Description |
|---|---|
| GraphicsDeviceType[] |
Methods
ConfigureCameraTarget(RTHandle, RTHandle)
Configures the camera target.
Declaration
public void ConfigureCameraTarget(RTHandle colorTarget, RTHandle depthTarget)
Parameters
| Type | Name | Description |
|---|---|---|
| RTHandle | colorTarget | Camera color target. Pass k_CameraTarget if rendering to backbuffer. |
| RTHandle | depthTarget | Camera depth target. Pass k_CameraTarget if color has depth or rendering to backbuffer. |
Dispose()
Disposable pattern implementation. Cleans up resources used by the renderer.
Declaration
public void Dispose()
Dispose(bool)
Called by Dispose(). Override this function to clean up resources in your renderer. Be sure to call this base dispose in your overridden function to free resources allocated by the base.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
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 rendering the camera stack. You can release any resources created by the renderer here.
Declaration
public virtual void FinishRendering(CommandBuffer cmd)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd |
GetCameraClearFlag(ref CameraData)
Returns a clear flag based on CameraClearFlags.
Declaration
protected static ClearFlag GetCameraClearFlag(ref CameraData cameraData)
Parameters
| Type | Name | Description |
|---|---|---|
| CameraData | cameraData | The Camera data. |
Returns
| Type | Description |
|---|---|
| ClearFlag | A clear flag that tells if color and/or depth should be cleared. |
See Also
SetCameraMatrices(CommandBuffer, ref CameraData, bool)
Set camera matrices. This method will set UNITY_MATRIX_V, UNITY_MATRIX_P, UNITY_MATRIX_VP to camera matrices.
Additionally this will also set unity_CameraProjection and unity_CameraProjection.
If setInverseMatrices is set to true this function will also set UNITY_MATRIX_I_V and UNITY_MATRIX_I_VP.
This function has no effect when rendering in stereo. When in stereo rendering you cannot override camera matrices.
If you need to set general purpose view and projection matrices call SetViewAndProjectionMatrices(CommandBuffer, Matrix4x4, Matrix4x4, bool) instead.
Declaration
public static void SetCameraMatrices(CommandBuffer cmd, ref CameraData cameraData, bool setInverseMatrices)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | CommandBuffer to submit data to GPU. |
| CameraData | cameraData | CameraData containing camera matrices information. |
| bool | setInverseMatrices | Set this to true if you also need to set inverse camera matrices. |
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. |
SetupRenderPasses(in RenderingData)
Calls Setup for each feature added to this renderer.
SetupRenderPasses(ScriptableRenderer, in RenderingData)
Declaration
protected void SetupRenderPasses(in RenderingData renderingData)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderingData | renderingData |
SupportedCameraStackingTypes()
This setting controls if the camera editor should display the camera stack category. If your renderer is not supporting stacking this one should return 0. For the UI to show the Camera Stack widget this must support CameraRenderType.Base. CameraRenderType Returns the bitmask of the supported camera render types in the renderer's current state.
Declaration
public virtual int SupportedCameraStackingTypes()
Returns
| Type | Description |
|---|---|
| int | The bitmask of the supported camera render types in the renderer's current state. |
SupportsCameraStackingType(CameraRenderType)
Returns true if the given camera render type is supported in the renderer's current state.
Declaration
public bool SupportsCameraStackingType(CameraRenderType cameraRenderType)
Parameters
| Type | Name | Description |
|---|---|---|
| CameraRenderType | cameraRenderType | The camera render type that is checked if supported. |
Returns
| Type | Description |
|---|---|
| bool | True if the given camera render type is supported in the renderer's current state. |