s&box docs

Render States

You can control render states in your shaders using this syntax anywhere outside of functions.

You can control render states in your shaders using this syntax anywhere outside of functions.

RenderState( BlendEnable, true );
NameDescriptionValues
FillModeDetermines how polygons are rendered (solid faces or wireframe edges).WIREFRAME, SOLID
CullModeSpecifies which faces (front, back, or none) are culled from rendering.NONE, BACK, FRONT
DepthBiasEnables or disables depth bias to adjust depth values for rendering order.true, false
DepthBiasClampEnables or disables clamping of depth bias to a set range.true, false
SlopeScaleDepthBiasEnables or disables slope-scaled depth bias for polygons.true, false
DepthClipEnableEnables or disables clipping of geometry against the near/far depth planes.true, false
MultisampleEnableEnables or disables multisample anti-aliasing.true, false
SampleMaskControls which samples in a multisample target are updated.true, false
DepthEnableEnables or disables depth testing.true, false
DepthWriteEnableEnables or disables writing to the depth buffer.true, false
DepthFuncComparison function for depth testing.NEVER, LESS, EQUAL, LESS_EQUAL, GREATER, NOT_EQUAL, GREATER_EQUAL, ALWAYS
StencilEnableEnables or disables stencil testing.true, false
StencilReadMaskMask for reading stencil buffer values.0 โ†’ 255
StencilWriteMaskMask for writing stencil buffer values.0 โ†’ 255
StencilFailOpAction when stencil test fails.KEEP, ZERO, REPLACE, INCR_SAT, DECR_SAT, INVERT, INCR, DECR
StencilDepthFailOpAction when stencil test passes but depth test fails.KEEP, ZERO, REPLACE, INCR_SAT, DECR_SAT, INVERT, INCR, DECR
StencilPassOpAction when both stencil and depth tests pass.KEEP, ZERO, REPLACE, INCR_SAT, DECR_SAT, INVERT, INCR, DECR
StencilFuncComparison function for front-face stencil test.NEVER, LESS, EQUAL, LESS_EQUAL, GREATER, NOT_EQUAL, GREATER_EQUAL, ALWAYS
BackStencilFailOpAction for back-facing polygons when stencil test fails.KEEP, ZERO, REPLACE, INCR_SAT, DECR_SAT, INVERT, INCR, DECR
BackStencilDepthFailOpAction for back-facing polygons when depth test fails.KEEP, ZERO, REPLACE, INCR_SAT, DECR_SAT, INVERT, INCR, DECR
BackStencilPassOpAction for back-facing polygons when both tests pass.KEEP, ZERO, REPLACE, INCR_SAT, DECR_SAT, INVERT, INCR, DECR
BackStencilFuncComparison function for back-face stencil test.NEVER, LESS, EQUAL, LESS_EQUAL, GREATER, NOT_EQUAL, GREATER_EQUAL, ALWAYS
StencilRefReference value used in stencil tests.0 โ†’ 255
AlphaToCoverageEnableEnables alpha-to-coverage for multisampling.true, false
BlendEnableEnables or disables blending.true, false
IndependentBlendEnableAllows blending settings to differ between render targets.true, false
SrcBlendSource factor for RGB blend.ZERO, ONE, SRC_COLOR, INV_SRC_COLOR, SRC_ALPHA, INV_SRC_ALPHA, DEST_ALPHA, INV_DEST_ALPHA, DEST_COLOR, INV_DEST_COLOR, SRC_ALPHA_SAT, BLEND_FACTOR, SRC1_COLOR, INV_SRC1_COLOR, SRC1_ALPHA, INV_SRC1_ALPHA
DstBlendDestination factor for RGB blend.ZERO, ONE, SRC_COLOR, INV_SRC_COLOR, SRC_ALPHA, INV_SRC_ALPHA, DEST_ALPHA, INV_DEST_ALPHA, DEST_COLOR, INV_DEST_COLOR, SRC_ALPHA_SAT, BLEND_FACTOR, SRC1_COLOR, INV_SRC1_COLOR, SRC1_ALPHA, INV_SRC1_ALPHA
BlendOpOperation applied to RGB blend factors.ADD, SUBTRACT, REV_SUBTRACT, MIN, MAX
SrcBlendAlphaSource factor for alpha blending.ZERO, ONE, SRC_COLOR, INV_SRC_COLOR, SRC_ALPHA, INV_SRC_ALPHA, DEST_ALPHA, INV_DEST_ALPHA, DEST_COLOR, INV_DEST_COLOR, SRC_ALPHA_SAT, BLEND_FACTOR, SRC1_COLOR, INV_SRC1_COLOR, SRC1_ALPHA, INV_SRC1_ALPHA
DstBlendAlphaDestination factor for alpha blending.ZERO, ONE, SRC_COLOR, INV_SRC_COLOR, SRC_ALPHA, INV_SRC_ALPHA, DEST_ALPHA, INV_DEST_ALPHA, DEST_COLOR, INV_DEST_COLOR, SRC_ALPHA_SAT, BLEND_FACTOR, SRC1_COLOR, INV_SRC1_COLOR, SRC1_ALPHA, INV_SRC1_ALPHA
BlendOpAlphaOperation applied to alpha blend factors.ADD, SUBTRACT, REV_SUBTRACT, MIN, MAX
ColorWriteEnable0Channels to write for render target 0.false, R, G, B, A, RG, RB, RA, GB, GA, BA, GBA, RBA, RGA, RGB, RGBA
ColorWriteEnable1Channels to write for render target 1.false, R, G, B, A, RG, RB, RA, GB, GA, BA, GBA, RBA, RGA, RGB, RGBA
ColorWriteEnable2Channels to write for render target 2.false, R, G, B, A, RG, RB, RA, GB, GA, BA, GBA, RBA, RGA, RGB, RGBA
ColorWriteEnable3Channels to write for render target 3.false, R, G, B, A, RG, RB, RA, GB, GA, BA, GBA, RBA, RGA, RGB, RGBA
SrgbWriteEnable0Enables sRGB write conversion for render target 0.true, false
SrgbWriteEnable1Enables sRGB write conversion for render target 1.true, false
SrgbWriteEnable2Enables sRGB write conversion for render target 2.true, false
SrgbWriteEnable3Enables sRGB write conversion for render target 3.true, false
BlendFactorEnables use of a constant blend factor.true, false
HighPrecisionBlendEnableEnables high-precision blending.true, false
AlphaTestEnableEnables alpha testing.true, false
AlphaTestRefReference value for alpha testing.true, false (likely meant to be a numeric range instead)
AlphaTestFuncComparison function for alpha testing.NEVER, LESS, EQUAL, LESS_EQUAL, GREATER, NOT_EQUAL, GREATER_EQUAL, ALWAYS

Referenced API

Canonical API pages mentioned in this guide.

Created at:
Updated at: