Version: 2021.3
LanguageEnglish
  • C#

RenderStateBlock

struct in UnityEngine.Rendering

/

Implemented in:UnityEngine.CoreModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

A set of values that Unity uses to override the GPU's render state.

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 mask to tell Unity which parts of the render state to override to apply. For example, to apply the values in blendState, 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(); } }

Properties

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.

Constructors

RenderStateBlockCreates a new render state block with the specified mask.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961