Struct RasterizerStateDescription
A description of a Rasterizer State, which defines how primitives are rasterized to the Render Targets.
[DataContract]
public struct RasterizerStateDescription : IEquatable<RasterizerStateDescription>
- Implements
- Inherited Members
- Extension Methods
Remarks
This structure controls fill mode, primitive culling, multisampling, depth bias, and clipping.
Constructors
RasterizerStateDescription()
Initializes a new instance of the RasterizerStateDescription structure with default values.
public RasterizerStateDescription()
Remarks
<ul><li><xref href="Stride.Graphics.RasterizerStateDescription.FillMode" data-throw-if-not-resolved="false"></xref>: Rasterize filled triangles (<xref href="Stride.Graphics.FillMode.Solid" data-throw-if-not-resolved="false"></xref>).</li><li><xref href="Stride.Graphics.RasterizerStateDescription.CullMode" data-throw-if-not-resolved="false"></xref>: Cull back-facing primitives (<xref href="Stride.Graphics.CullMode.Back" data-throw-if-not-resolved="false"></xref>).</li><li><xref href="Stride.Graphics.RasterizerStateDescription.FrontFaceCounterClockwise" data-throw-if-not-resolved="false"></xref>: Consider front-facing the primitives whose vertices are ordered clockwise (<a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>).</li><li><xref href="Stride.Graphics.RasterizerStateDescription.DepthClipEnable" data-throw-if-not-resolved="false"></xref>: Clip primitives outside the near and far clipping planes (<a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a>).</li><li>Scissor testing disabled.</li><li>No multisampling (<xref href="Stride.Graphics.MultisampleCount.None" data-throw-if-not-resolved="false"></xref>) and no antialiased lines.</li><li>No <xref href="Stride.Graphics.RasterizerStateDescription.DepthBias" data-throw-if-not-resolved="false"></xref>, <xref href="Stride.Graphics.RasterizerStateDescription.DepthBiasClamp" data-throw-if-not-resolved="false"></xref>, or <xref href="Stride.Graphics.RasterizerStateDescription.SlopeScaleDepthBias" data-throw-if-not-resolved="false"></xref>.</li></ul>
</remarks>
RasterizerStateDescription(CullMode)
Initializes a new instance of the RasterizerStateDescription structure with default values, and with the specified culling mode.
public RasterizerStateDescription(CullMode cullMode)
Parameters
cullModeCullModeThe cull mode.
Remarks
<ul><li><xref href="Stride.Graphics.RasterizerStateDescription.FillMode" data-throw-if-not-resolved="false"></xref>: Rasterize filled triangles (<xref href="Stride.Graphics.FillMode.Solid" data-throw-if-not-resolved="false"></xref>).</li><li><xref href="Stride.Graphics.RasterizerStateDescription.CullMode" data-throw-if-not-resolved="false"></xref>: Cull back-facing primitives (<xref href="Stride.Graphics.CullMode.Back" data-throw-if-not-resolved="false"></xref>).</li><li><xref href="Stride.Graphics.RasterizerStateDescription.FrontFaceCounterClockwise" data-throw-if-not-resolved="false"></xref>: Consider front-facing the primitives whose vertices are ordered clockwise (<a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>).</li><li><xref href="Stride.Graphics.RasterizerStateDescription.DepthClipEnable" data-throw-if-not-resolved="false"></xref>: Clip primitives outside the near and far clipping planes (<a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a>).</li><li>Scissor testing disabled.</li><li>No multisampling (<xref href="Stride.Graphics.MultisampleCount.None" data-throw-if-not-resolved="false"></xref>) and no antialiased lines.</li><li>No <xref href="Stride.Graphics.RasterizerStateDescription.DepthBias" data-throw-if-not-resolved="false"></xref>, <xref href="Stride.Graphics.RasterizerStateDescription.DepthBiasClamp" data-throw-if-not-resolved="false"></xref>, or <xref href="Stride.Graphics.RasterizerStateDescription.SlopeScaleDepthBias" data-throw-if-not-resolved="false"></xref>.</li></ul>
</remarks>
Fields
CullMode
Specifies which triangle facing direction should be culled (not rendered) during rasterization. The facing direction is determined by the FrontFaceCounterClockwise setting.
public CullMode CullMode
Field Value
Remarks
This property determines whether front-facing or back-facing triangles are culled.
A triangle's facing is defined by the winding order of its vertices and the value of FrontFaceCounterClockwise.
For example, if FrontFaceCounterClockwise is false (clockwise is front-facing),
and CullMode is set to Back, then counter-clockwise triangles will be culled.
Default
A Rasterizer State description with default values.
public static readonly RasterizerStateDescription Default
Field Value
Remarks
The default values are:
- FillMode: Rasterize filled triangles (Solid).
- CullMode: Cull back-facing primitives (Back).
- FrontFaceCounterClockwise: Consider front-facing the primitives whose vertices are ordered clockwise (false).
- DepthClipEnable: Clip primitives outside the near and far clipping planes (true).
- Scissor testing disabled.
- No multisampling (None) and no antialiased lines.
- No DepthBias, DepthBiasClamp, or SlopeScaleDepthBias.
DefaultCullMode
The default value for CullMode.
public const CullMode DefaultCullMode = Back
Field Value
DefaultDepthBias
The default value for DepthBias.
public const int DefaultDepthBias = 0
Field Value
DefaultDepthBiasClamp
The default value for DepthBiasClamp.
public const float DefaultDepthBiasClamp = 0
Field Value
DefaultDepthClipEnable
The default value for DepthClipEnable.
public const bool DefaultDepthClipEnable = true
Field Value
DefaultFillMode
The default value for FillMode.
public const FillMode DefaultFillMode = Solid
Field Value
DefaultFrontFaceCounterClockwise
The default value for FrontFaceCounterClockwise.
public const bool DefaultFrontFaceCounterClockwise = false
Field Value
DefaultMultisampleAntiAliasLine
The default value for MultisampleAntiAliasLine.
public const bool DefaultMultisampleAntiAliasLine = false
Field Value
DefaultMultisampleCount
The default value for MultisampleCount.
public const MultisampleCount DefaultMultisampleCount = None
Field Value
DefaultScissorTestEnable
The default value for ScissorTestEnable.
public const bool DefaultScissorTestEnable = false
Field Value
DefaultSlopeScaleDepthBias
The default value for SlopeScaleDepthBias.
public const float DefaultSlopeScaleDepthBias = 0
Field Value
DepthBias
Constant depth bias added to each pixel's depth value.
public int DepthBias
Field Value
Remarks
This value is added to the depth of each pixel and is typically used to resolve Z-fighting, such as when rendering decals or wireframe overlays on top of solid geometry. The actual depth offset depends on the Depth Buffer format and the slope of the primitive.
DepthBiasClamp
Maximum depth bias that can be applied to a pixel.
public float DepthBiasClamp
Field Value
Remarks
Clamps the total depth bias applied to a pixel, after combining DepthBias and SlopeScaleDepthBias. This is useful to prevent excessive biasing on steep slopes or when using large bias values.
DepthClipEnable
Enables or disables clipping of geometry based on the depth (Z) value. When enabled, primitives outside the near and far clip planes are discarded.
public bool DepthClipEnable
Field Value
Remarks
When enabled, geometry outside the near and far clip planes is discarded. Disabling this can be useful for special effects like infinite projection or stencil shadows, but may lead to incorrect depth ordering if not handled carefully.
FillMode
Specifies how primitives are filled during rasterization (e.g., solid or wireframe).
public FillMode FillMode
Field Value
Remarks
Common values include Solid for standard rendering and Wireframe for debugging geometry. Wireframe mode is especially useful for visualizing mesh topology or detecting overdraw.
FrontFaceCounterClockwise
Determines the winding order used to identify front-facing triangles.
- If true, triangles with vertices ordered counter-clockwise on the render target are considered front-facing.
- If false, triangles with clockwise winding are considered front-facing.
This setting affects how CullMode determines which triangles to cull.
public bool FrontFaceCounterClockwise
Field Value
Remarks
This setting defines the convention for front-facing triangles. Combined with the CullMode value,
it determines whether front-facing or back-facing triangles are culled during rasterization.
For example, if FrontFaceCounterClockwise is false (the default in Direct3D),
and CullMode is set to Front, then triangles with clockwise winding will be culled.
MultisampleAntiAliasLine
Enables antialiasing for lines when MSAA is disabled. Only affects line rendering.
public bool MultisampleAntiAliasLine
Field Value
Remarks
This only affects line primitives, and has no effect when MultisampleCount is greater than 1.
MultisampleCount
Specifies the number of samples used for multisample anti-aliasing (MSAA).
public MultisampleCount MultisampleCount
Field Value
Remarks
Higher sample counts improve edge smoothness but increase memory and processing cost.
ScissorTestEnable
Enables scissor testing. Pixels outside the active scissor rectangle are culled.
public bool ScissorTestEnable
Field Value
Remarks
When enabled, only pixels inside the active scissor rectangle are rendered. This is commonly used for UI rendering, partial redraws, or performance optimization.
SlopeScaleDepthBias
Scalar applied to a primitive's slope to compute a variable depth bias. Helps offset depth values based on surface angle.
public float SlopeScaleDepthBias
Field Value
Remarks
This value is multiplied by the maximum slope of the primitive to compute a variable depth bias. It helps reduce Z-fighting on surfaces that are nearly parallel to the view direction. Often used in conjunction with DepthBias for shadow mapping or coplanar geometry.
Methods
Equals(RasterizerStateDescription)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(RasterizerStateDescription other)
Parameters
otherRasterizerStateDescriptionAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Operators
operator ==(RasterizerStateDescription, RasterizerStateDescription)
public static bool operator ==(RasterizerStateDescription left, RasterizerStateDescription right)
Parameters
Returns
operator !=(RasterizerStateDescription, RasterizerStateDescription)
public static bool operator !=(RasterizerStateDescription left, RasterizerStateDescription right)