Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


RenderStateBlock

A set of values that Unity uses to override the GPU's render state.
Read time 1 minuteLast updated 4 days ago

Definition

public struct RenderStateBlock : IEquatable<RenderStateBlock>

Remarks

When you call ScriptableRenderContext.DrawRenderers, you can use this to override the render state for some or all of the geometry.
Note: You must set RenderStateBlock.mask to tell Unity which parts of the render state to override to apply. For example, to apply the values in RenderStateBlock.blendState, RenderStateBlock.mask must include RenderStateMask.Blend.
using UnityEngine;using UnityEngine.Rendering;public class OverrideRenderStateExample{ ScriptableRenderContext scriptableRenderContext; // Placeholder data DrawingSettings exampleDrawingSettings; CullingResults exampleCullingResults = new CullingResults(); FilteringSettings exampleFilteringSettings = new FilteringSettings(); public void OverrideRenderState() { // Tell Unity how to override the render state when it draws the geometry. var stateBlock = new RenderStateBlock(RenderStateMask.Depth); stateBlock.depthState = new DepthState(true, CompareFunction.LessEqual); // Schedule the drawing operation. scriptableRenderContext.DrawRenderers(exampleCullingResults, ref exampleDrawingSettings, ref exampleFilteringSettings, ref stateBlock); // Perform all scheduled tasks, in the order that they were scheduled. scriptableRenderContext.Submit(); }}

Constructors

Constructor

Description

RenderStateBlock(UnityEngine.Rendering.RenderStateMask)Creates a new render state block with the specified mask.

Properties

Property

Description

blendStateSpecifies the new blend state.
depthStateSpecifies the new depth state.
maskSpecifies which parts of the GPU's render state to override.
rasterStateSpecifies the new raster state.
stencilReferenceThe value to be compared against and/or the value to be written to the buffer, based on the stencil state.
stencilStateSpecifies the new stencil state.