Shader Render State

The state of the rendering pipeline (TODO) can only be set through shaders (TODO). There is no way to change its state other than to select a shader which includes that specific state.

Use shader permutations to create variants of a shader. Each variant may incorporate a different render state. By setting shader permutation variables at runtime, you select the specific shader variant (permutation) and thus also get its render state.

This design follows what rendering APIs such as DirectX 12 and Vulkan require.

The Shader Render State Section

Each shader is made up of several sections.

[PLATFORMS]

ALL
DEBUG

[PERMUTATIONS]

ALPHATEST
WIREFRAME

[RENDERSTATE]

#if WIREFRAME == 1
  WireFrame = true
#endif

[VERTEXSHADER]

VS_OUT main(VS_IN Input)
{
  ...
}

[PIXELSHADER]

...

The render pipeline state associated with the shader is defined in the [RENDERSTATE] section. It may use permutation variables just like the shader code. To have different state for different permutations, use standard C preprocessor syntax.

Render States

The following variables are available in the [RENDERSTATE] section. Simply overwrite them with the desired value.

Rasterizer States

Depth-Stencil State

Blend State

The following variables exist with suffix 0 to 7. If IndependentBlend is disabled, only the ones with suffix 0 are used.

See Also