Class MeshFallbackEffects
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
-
objectMeshFallbackEffects
- Extension Methods
Constructors
MeshFallbackEffects(GraphicsDevice, EffectSystem)
public MeshFallbackEffects(GraphicsDevice graphicsDevice, EffectSystem effectSystem)
Parameters
graphicsDeviceGraphicsDeviceeffectSystemEffectSystem
Fields
MaxSkinningBones
The most bones a fallback skins; a mesh with more falls back without skinning.
public const int MaxSkinningBones = 56
Field Value
Methods
ComputeFallbackEffect(RenderObject, RenderEffect, RenderEffectState)
Loads the fallback effect for renderEffect. Matches RootEffectRenderFeature.ComputeFallbackEffectDelegate.
public Effect ComputeFallbackEffect(RenderObject renderObject, RenderEffect renderEffect, RenderEffectState renderEffectState)
Parameters
renderObjectRenderObjectrenderEffectRenderEffectrenderEffectStateRenderEffectState
Returns
- Effect
The fallback effect, or
nullwhen 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
renderObjectRenderObjectrenderEffectRenderEffectrenderEffectStateRenderEffectStatecustomizeParametersAction<RenderEffect, RenderEffectState, CompilerParameters>
Returns
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
renderMeshRenderMeshThe mesh to draw.
renderEffectRenderEffectThe 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
hasDiffuseMapboolWhether the mesh has a diffuse map, or a color.
hasInstancingboolWhether the mesh is instanced.
modelTransformUsageintThe
ModelTransformUsageof the instances, as anint(0 Ignore, 1 PreMultiply, 2 PostMultiply). Ignored whenhasInstancingisfalse.hasSkinningPositionboolWhether the mesh skins its positions. A mesh with more than MaxSkinningBones bones falls back without skinning: pass
falsefor all three skinning values.hasSkinningNormalboolWhether the mesh skins its normals.
hasSkinningTangentboolWhether 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.