RenderStatePreset

Description

[Flags]
enum Tinman.Engine.Rendering.RenderStatePreset

Enumeration of commonly used render state blocks.

An implementation of IRenderEffect should provide helper methods for applying render state values based on the items of this enumeration. Those should be named as RenderStateApply. Unless stated otherwise, render state presets do not interfere with each other. When multiple presets are passed to that method, they are applied in the order in which they appear in this enumeration.

Public / Constants

None

public constant None → (0:int32)

No render state preset.

AlphaBlending

public constant AlphaBlending → (1:int32)

Transparent geometry using alpha-blending.

This preset enables order-dependent alpha compositing with the over operator:

A_out = A_src + A_dst * (1 - A_src)
C_out = (C_src * A_src + C_dst * A_dst * (1 - A_src)) / A_out

where (C_src,A_src) represents the fragment that is being rasterized, (C_dst,A_dst) represents the fragment that is present in the target buffer and (C_out,A_out) represents the resulting fragment that will be written to the buffer. All three tuples use straight alpha. Assuming that the target buffer stores fragments with premultiplied alpha, the following applies:

C_dstPre = C_dst * A_dst
C_outPre = C_out * A_out

This leads to the final equations that are actually performed by the GPU:

A_out    = A_src + A_dst * (1 - A_src)
C_outPre = C_src * A_src + C_dstPre * (1 - A_src)

Applying this state interferes with AlphaCoverage.

AlphaCoverage

public constant AlphaCoverage → (2:int32)

Solid geometry using alpha-to-coverage.

Rendering solid geometry with implicit transparency via alpha-to-coverage requires multisampling (see IGraphicsContext.IsMultiSample), where the number of samples (see MultiSampleType.Count) depicts the effective alpha values that may be used. For example:

1 sample:  0%,                                    100%
2 samples: 0%,                50%,                100%
4 samples: 0%,      25%,      50%,      75%,      100%
8 samples: 0%, 13%, 25%, 38%, 50%, 63%, 75%, 88%, 100%

Applying this state interferes with AlphaBlending.

AntiAliasing

public constant AntiAliasing → (4:int32)

Use anti-aliasing.

If available, multi-sampling will be used for anti-aliasing (see IGraphicsContext.IsMultiSample). Otherwise, line anti-aliasing will be used, if supported.

DepthEqual

public constant DepthEqual → (8:int32)

Render only those pixels that have the same depth value as in the depth buffer.

InverseCulling

public constant InverseCulling → (16:int32)

Sets the culling mode to the inverse of the default mode.

NoCulling

public constant NoCulling → (32:int32)

Disable triangle culling, which hides the effect of InverseCulling.

NoWriteAlpha

public constant NoWriteAlpha → (64:int32)

Disable writing to the alpha channel of the first render target.

NoWriteBlue

public constant NoWriteBlue → (128:int32)

Disable writing to the blue channel of the first render target.

NoWriteGreen

public constant NoWriteGreen → (256:int32)

Disable writing to the green channel of the first render target.

NoWriteRed

public constant NoWriteRed → (512:int32)

Disable writing to the red channel of the first render target.

NoWriteTarget

public constant NoWriteTarget → (960:int32)

Bitmask for writing to the channels of the first render target.

NoWriteZ

public constant NoWriteZ → (1024:int32)

Disable writing to the depth buffer.

Wireframe

public constant Wireframe → (2048:int32)

Perform wireframe rendering with a small depth bias.