Show / Hide Table of Contents

Class RenderStateSet

Use instances of this class to store a set of render states that need to be applied as a whole. Instances are used in the effects system to set a couple of states before a render pass is performed.

Inheritance
System.Object
RenderStateSet
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Fusee.Engine.Core
Assembly: Fusee.Engine.Core.dll
Syntax
public class RenderStateSet

Constructors

RenderStateSet()

Returns a new instance of type RenderStateSet.

Declaration
public RenderStateSet()

Properties

AlphaBlendEnable

Set to true to enable alpha-blended transparency, or false to disable it. The type of alpha blending is determined by the SourceBlend and DestinationBlend render states.

Declaration
public bool AlphaBlendEnable { get; set; }
Property Value
Type Description
System.Boolean
Remarks

Blending describes the process how the pixel generated by the pixel shader is written into the render target buffer. Typically it is just copied at its respective pixel position, but several operations are possible to perform a calculation between the pixel value (rgb and a) already in the buffer and the pixel value (rgb and a) created by the pixel shader. The general blending assignment is (always independent for rgb and alpha):

     OUTrgb = SRCrgb * SourceBlend       {BlendOperation: [+|-|-inv|min|max]}        DSTrgb * DestinationBlend;
     OUTa   = SRCa   * SourceBlendAlpha  {BlendOperationAlpha: [+|-|-inv|min|max]}   DSTa   * DestinationBlendAlpha;

where:

  • OUT: The new pixel written to the output buffer
  • SRC: The pixel generated by the pixel shader
  • DST: The pixel already in the output buffer
  • SourceBlend: See the SourceBlend attribute
  • DestinationBlend: See the DestinationBlend attribute
  • SourceBlendAlpha: See the SourceBlendAlpha attribute
  • DestinationBlendAlpha: See the DestinationBlendAlpha attribute
The following example shows how to set-up the combiner to use the alpha value passed to gl_FragColor.a in the pixel shader as the opacity of the resulting pixel's color. The color is blended between the pixel shader's RGB output and the RGB color already in the output buffer.
    // Switch alpha blending ON
    RC.SetRenderState(new RenderStateSet
    {
        AlphaBlendEnable = true,
        SourceBlend = Blend.SourceAlpha,
        DestinationBlend = Blend.InvSourceAlpha,
        BlendOperation = BlendOperation.Add,
        // In case of particles:
        ZEnable = true,
        ZWriteEnable = false,
    });
// Switch alpha blending OFF
RC.SetRenderState(RenderState.AlphaBlendEnable, 0);</code></pre>

BlendFactor

A Fusee.Math.float4 object representing a color used for a constant blend factor during alpha blending.

Declaration
public float4 BlendFactor { get; set; }
Property Value
Type Description
float4
See Also
AlphaBlendEnable

BlendOperation

The blend operation to perform for blending rgb values (one of add, subtract, inverted subtract, max, or min).

Declaration
public BlendOperation BlendOperation { get; set; }
Property Value
Type Description
BlendOperation
See Also
AlphaBlendEnable

BlendOperationAlpha

The blend operation to perform for blending alpha values (one of add, subtract, inverted subtract, max, or min).

Declaration
public BlendOperation BlendOperationAlpha { get; set; }
Property Value
Type Description
BlendOperation
See Also
AlphaBlendEnable

Clipping

Enables or disables primitive (triangle) clipping. Set to true to enable primitive clipping, or false to disable it.

Declaration
public bool Clipping { get; set; }
Property Value
Type Description
System.Boolean

CullMode

A value from the Fusee.Engine.Cull enumeration specifying if and how to cull the two different sides of a triangle.

Declaration
public Cull CullMode { get; set; }
Property Value
Type Description
Cull

Default

OpenGL defaults for the render states.

Declaration
public static RenderStateSet Default { get; }
Property Value
Type Description
RenderStateSet

DestinationBlend

Contains a member of the Fusee.Engine.Blend enumeration that represents the destination.

Declaration
public Blend DestinationBlend { get; set; }
Property Value
Type Description
Blend
See Also
AlphaBlendEnable

DestinationBlendAlpha

A member of the Blend enumeration that represents the destination.

Declaration
public Blend DestinationBlendAlpha { get; set; }
Property Value
Type Description
Blend
See Also
AlphaBlendEnable

FillMode

A value from the Fusee.Engine.FillMode enumeration that represents the fill mode to apply when rendering triangles.

Declaration
public FillMode FillMode { get; set; }
Property Value
Type Description
FillMode

SourceBlend

Contains a member of the Fusee.Engine.Blend enumeration that represents the source.

Declaration
public Blend SourceBlend { get; set; }
Property Value
Type Description
Blend
See Also
AlphaBlendEnable

SourceBlendAlpha

A member of the Blend enumeration that represents the source.

Declaration
public Blend SourceBlendAlpha { get; set; }
Property Value
Type Description
Blend
See Also
AlphaBlendEnable

States

Enumerate this set of render states for its contents

Declaration
public Dictionary<RenderState, uint> States { get; }
Property Value
Type Description
System.Collections.Generic.Dictionary<RenderState, System.UInt32>

An enumerator to be used in loops returning a key and its respective value.

Examples

Use this enumerator in loops to query a RenderStateSet's contents.

RenderStateSet aRenderStateSet = ...;
foreach (var state in aRenderStateSet.States)
    DoSomethingWithState(state.Key, state.Value);

ZEnable

Enables or disables z-buffering (depth buffering).

Declaration
public bool ZEnable { get; set; }
Property Value
Type Description
System.Boolean

ZFunc

Determines the comparison function for the z-buffer test. Valid values are members of the Fusee.Engine.Compare enumeration. The depth value of the pixel is compared to the z-buffer value. If the depth value of the pixel passes the comparison function, the pixel is written.

Declaration
public Compare ZFunc { get; set; }
Property Value
Type Description
Compare

ZWriteEnable

Enables or disables depth buffer writing.

Declaration
public bool ZWriteEnable { get; set; }
Property Value
Type Description
System.Boolean

Methods

Copy()

Returns a new RenderStateSet with the same states as this instance.

Declaration
public RenderStateSet Copy()
Returns
Type Description
RenderStateSet

Merge(RenderStateSet)

Returns a new RenderStateSet which merges this instance (A) and a given RenderStateSet (B) by overwriting differing values with the ones from B.

Declaration
public RenderStateSet Merge(RenderStateSet otherSet)
Parameters
Type Name Description
RenderStateSet otherSet
Returns
Type Description
RenderStateSet
Generated by DocFX
GitHub Repo
Back to top