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
Inherited Members
Namespace: UnityEngine.Rendering.Universal
Syntax
[MovedFrom("UnityEngine.Rendering.LWRP")]
public abstract class ScriptableRenderer : IDisposable
Constructors
ScriptableRenderer(ScriptableRendererData)
Declaration
public ScriptableRenderer(ScriptableRendererData data)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptableRendererData | data |
Properties
activeRenderPassQueue
Returns a list of render passes schedules to be executed by this renderer. ScriptableRenderPass
Declaration
protected List<ScriptableRenderPass> activeRenderPassQueue { get; }
Property Value
| Type | Description |
|---|---|
| List<ScriptableRenderPass> |
cameraColorTarget
Returns the camera color target for this renderer.
It's only valid to call cameraColorTarget in the scope of ScriptableRenderPass.
ScriptableRenderPass.
Declaration
public RenderTargetIdentifier cameraColorTarget { get; }
Property Value
| Type | Description |
|---|---|
| RenderTargetIdentifier |
cameraDepthTarget
Returns the camera depth target for this renderer.
It's only valid to call cameraDepthTarget in the scope of ScriptableRenderPass.
ScriptableRenderPass.
Declaration
public RenderTargetIdentifier cameraDepthTarget { get; }
Property Value
| Type | Description |
|---|---|
| RenderTargetIdentifier |
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
AddRenderPasses(ref RenderingData)
Calls AddRenderPasses for each feature added to this renderer.
AddRenderPasses(ScriptableRenderer, ref RenderingData)
Declaration
protected void AddRenderPasses(ref RenderingData renderingData)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderingData | renderingData |
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. |
Dispose()
Declaration
public void Dispose()
Implements
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | 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 |
Returns
| Type | Description |
|---|---|
| ClearFlag | A clear flag that tells if color and/or depth should be cleared. |
SetCameraMatrices(CommandBuffer, ref CameraData, Boolean)
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
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. |
| Boolean | 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. |