Class ScriptableRenderer
Class ScriptableRenderer implements a rendering strategy. It describes how culling and lighting works and
the effects supported.
TODO RENDERGRAPH: UPDATE THIS DOC FOR THE RENDERGRAPH PATH
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> |
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 |
supportsGPUOcclusion
Used to determine if this renderer supports the use of GPU occlusion culling.
Declaration
public virtual bool supportsGPUOcclusion { get; }
Property Value
| Type | Description |
|---|---|
| bool |
unsupportedGraphicsDeviceTypes
List of unsupported Graphics APIs for this renderer. unsupportedGraphicsDeviceTypes
Declaration
public GraphicsDeviceType[] unsupportedGraphicsDeviceTypes { get; set; }
Property Value
| Type | Description |
|---|---|
| GraphicsDeviceType[] |
Methods
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. |
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
GetCameraClearFlag(UniversalCameraData)
Returns a clear flag based on CameraClearFlags.
Declaration
protected static ClearFlag GetCameraClearFlag(UniversalCameraData cameraData)
Parameters
| Type | Name | Description |
|---|---|---|
| UniversalCameraData | cameraData | The Camera data. |
Returns
| Type | Description |
|---|---|
| ClearFlag | A clear flag that tells if color and/or depth should be cleared. |
See Also
OnBeginRenderGraphFrame()
Override this method to initialize before recording the render graph, such as resources.
Declaration
public virtual void OnBeginRenderGraphFrame()
OnEndRenderGraphFrame()
Override this method to cleanup things after recording the render graph, such as resources.
Declaration
public virtual void OnEndRenderGraphFrame()
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. |
SetCameraMatrices(CommandBuffer, UniversalCameraData, 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, UniversalCameraData cameraData, bool setInverseMatrices)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | CommandBuffer to submit data to GPU. |
| UniversalCameraData | cameraData | CameraData containing camera matrices information. |
| bool | setInverseMatrices | Set this to true if you also need to set inverse camera matrices. |
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. |
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
Declaration
public virtual int SupportedCameraStackingTypes()
Returns
| Type | Description |
|---|---|
| int | The bitmask of the supported camera render types in the renderer's current state. |
SupportsCameraNormals()
Check if the ScriptableRenderer implements a camera normal pass.
Declaration
protected virtual bool SupportsCameraNormals()
Returns
| Type | Description |
|---|---|
| bool | Returns true if the ScriptableRenderer implements a camera normal pass. False otherwise. |
SupportsCameraOpaque()
Check if the ScriptableRenderer implements a camera opaque pass.
Declaration
protected virtual bool SupportsCameraOpaque()
Returns
| Type | Description |
|---|---|
| bool | Returns true if the ScriptableRenderer implements a camera opaque pass. False otherwise. |
SupportsCameraStackingType(CameraRenderType)
Check 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. |
SupportsMotionVectors()
Check if the ScriptableRenderer implements a motion vector pass for temporal techniques. The Camera will check this to enable/disable features and/or apply jitter when required.
For example, Temporal Anti-aliasing in the Camera settings is enabled only if the ScriptableRenderer can support motion vectors.
Declaration
protected virtual bool SupportsMotionVectors()
Returns
| Type | Description |
|---|---|
| bool | Returns true if the ScriptableRenderer implements a motion vector pass. False otherwise. |