Table of Contents

Class MeshFallbackEffects

Namespace
Stride.Rendering
Assembly
Stride.Rendering.dll

Builds the effect a MeshRenderFeature draws with while a mesh's real effect is still compiling or failed to compile. It keeps the mesh's diffuse texture or color with Lambert shading, its skinning and its instancing, and drops every other material feature, so all meshes share a few permutations that are usually already compiled and never depend on user shaders.

public class MeshFallbackEffects
Inheritance
object
MeshFallbackEffects
Extension Methods

Constructors

MeshFallbackEffects(GraphicsDevice, EffectSystem)

public MeshFallbackEffects(GraphicsDevice graphicsDevice, EffectSystem effectSystem)

Parameters

graphicsDevice GraphicsDevice
effectSystem EffectSystem

Fields

MaxSkinningBones

The most bones a fallback skins; a mesh with more falls back without skinning.

public const int MaxSkinningBones = 56

Field Value

int

Methods

ComputeFallbackEffect(RenderObject, RenderEffect, RenderEffectState)

Loads the fallback effect for renderEffect. Matches RootEffectRenderFeature.ComputeFallbackEffectDelegate.

public Effect ComputeFallbackEffect(RenderObject renderObject, RenderEffect renderEffect, RenderEffectState renderEffectState)

Parameters

renderObject RenderObject
renderEffect RenderEffect
renderEffectState RenderEffectState

Returns

Effect

The fallback effect, or null when it could not be loaded, in which case the render effect is flagged as errored.

ComputeFallbackEffect(RenderObject, RenderEffect, RenderEffectState, Action<RenderEffect, RenderEffectState, CompilerParameters>)

Same as ComputeFallbackEffect(RenderObject, RenderEffect, RenderEffectState), with a hook to adjust the compiler parameters before the effect is loaded.

public Effect ComputeFallbackEffect(RenderObject renderObject, RenderEffect renderEffect, RenderEffectState renderEffectState, Action<RenderEffect, RenderEffectState, CompilerParameters> customizeParameters)

Parameters

renderObject RenderObject
renderEffect RenderEffect
renderEffectState RenderEffectState
customizeParameters Action<RenderEffect, RenderEffectState, CompilerParameters>

Returns

Effect

CreateCompilerParameters(RenderMesh, RenderEffect)

Creates the compiler parameters of the fallback effect for renderMesh, with the instancing renderEffect was validated with.

public CompilerParameters CreateCompilerParameters(RenderMesh renderMesh, RenderEffect renderEffect = null)

Parameters

renderMesh RenderMesh

The mesh to draw.

renderEffect RenderEffect

The real effect of the mesh. When null, the fallback is not instanced.

Returns

CompilerParameters

CreateCompilerParameters(bool, bool, int, bool, bool, bool)

Creates the compiler parameters of a fallback effect without a mesh, to load it ahead of its first draw.

public CompilerParameters CreateCompilerParameters(bool hasDiffuseMap, bool hasInstancing = false, int modelTransformUsage = 0, bool hasSkinningPosition = false, bool hasSkinningNormal = false, bool hasSkinningTangent = false)

Parameters

hasDiffuseMap bool

Whether the mesh has a diffuse map, or a color.

hasInstancing bool

Whether the mesh is instanced.

modelTransformUsage int

The ModelTransformUsage of the instances, as an int (0 Ignore, 1 PreMultiply, 2 PostMultiply). Ignored when hasInstancing is false.

hasSkinningPosition bool

Whether the mesh skins its positions. A mesh with more than MaxSkinningBones bones falls back without skinning: pass false for all three skinning values.

hasSkinningNormal bool

Whether the mesh skins its normals.

hasSkinningTangent bool

Whether the mesh skins its tangents.

Returns

CompilerParameters

The compiler parameters to load the fallback effect with.

Remarks

Pass the result to LoadEffect(string, CompilerParameters) once per effect name that draws the mesh, since each render stage has its own (the .ShadowMapCaster variants, for example). The keys are the ones CreateCompilerParameters(RenderMesh, RenderEffect) gives for a mesh of the same traits, in the same order, which the effect system's early cache compares.