s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationRenderingShadersRender States
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Rendering
Rendering

Render States

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
DepthBiasConstant depth bias added to adjust depth values for rendering order.Integer
DepthBiasClampMaximum depth bias that can be applied.Float
SlopeScaleDepthBiasSlope-scaled depth bias for polygons.Float
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.Integer bitmask
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
BlendFactorThe constant blend factor, used by the BLEND_FACTOR blend modes.Four floats
HighPrecisionBlendEnableEnables high-precision blending.true, false
AlphaTestEnableEnables alpha testing.true, false
AlphaTestRefReference value for alpha testing.Float
AlphaTestFuncComparison function for alpha testing.NEVER, LESS, EQUAL, LESS_EQUAL, GREATER, NOT_EQUAL, GREATER_EQUAL, ALWAYS

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-08-03. Read it rendered on the official docs.

More in Rendering

AmbientLight
Animated Effects
Attributes and Variables
BeamEffect
Beams
Bindless API
C# Shader Nodes
Classes
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.