Class MaterialGeneratorContext
Main entry point class for generating shaders from a MaterialDescriptor
public class MaterialGeneratorContext : ShaderGeneratorContext, IDisposable, IComponent, IReferencable, ICollectorHolder
- Inheritance
-
MaterialGeneratorContext
- Implements
- Inherited Members
- Extension Methods
Constructors
MaterialGeneratorContext(Material, GraphicsDevice)
Initializes a new instance of MaterialGeneratorContext.
public MaterialGeneratorContext(Material material = null, GraphicsDevice graphicsDevice = null)
Parameters
material
MaterialgraphicsDevice
GraphicsDevice
Fields
DefaultFinalCallbackOrder
public const int DefaultFinalCallbackOrder = 0
Field Value
Properties
CurrentMaterialDescriptor
The current material descriptor on the material stack
public IMaterialDescriptor CurrentMaterialDescriptor { get; }
Property Value
GraphicsProfile
The graphics profile this material will be compatiable with.
public GraphicsProfile GraphicsProfile { get; set; }
Property Value
Material
Gets the compiled Material.
public Material Material { get; }
Property Value
MaterialPass
Gets the compiled MaterialPass. Only valid during GenerateShader.
public MaterialPass MaterialPass { get; set; }
Property Value
PassCount
In case of multi pass materials, this describe the number of passes.
public int PassCount { get; }
Property Value
PassIndex
The current pass (used by multipass materials). Only valid during GenerateShader.
public int PassIndex { get; set; }
Property Value
Step
The current step of material generation.
public MaterialGeneratorStep Step { get; set; }
Property Value
Methods
AddFinalCallback(MaterialShaderStage, MaterialGeneratorCallback, int)
public void AddFinalCallback(MaterialShaderStage stage, MaterialGeneratorContext.MaterialGeneratorCallback callback, int order = 0)
Parameters
stage
MaterialShaderStagecallback
MaterialGeneratorContext.MaterialGeneratorCallbackorder
int
AddShaderSource(MaterialShaderStage, ShaderSource)
public void AddShaderSource(MaterialShaderStage stage, ShaderSource shaderSource)
Parameters
stage
MaterialShaderStageshaderSource
ShaderSource
AddShading<T>(T)
public ShadingModelShaderBuilder AddShading<T>(T shadingModel) where T : class, IMaterialShadingModelFeature
Parameters
shadingModel
T
Returns
Type Parameters
T
AddStreamInitializer(MaterialShaderStage, string)
public void AddStreamInitializer(MaterialShaderStage stage, string streamInitilizerSource)
Parameters
stage
MaterialShaderStagestreamInitilizerSource
string
ComputeShaderSource(MaterialShaderStage)
public ShaderSource ComputeShaderSource(MaterialShaderStage stage)
Parameters
stage
MaterialShaderStage
Returns
GenerateStreamInitializers(MaterialShaderStage)
public ShaderSource GenerateStreamInitializers(MaterialShaderStage stage)
Parameters
stage
MaterialShaderStage
Returns
GetShading<T>(T)
public ShadingModelShaderBuilder GetShading<T>(T shadingModel) where T : class, IMaterialShadingModelFeature
Parameters
shadingModel
T
Returns
Type Parameters
T
GetStreamBlendShaderSource(string)
public ShaderSource GetStreamBlendShaderSource(string stream)
Parameters
stream
string
Returns
GetStreamFinalModifier<T>(MaterialShaderStage)
public ShaderSource GetStreamFinalModifier<T>(MaterialShaderStage stage)
Parameters
stage
MaterialShaderStage
Returns
Type Parameters
T
HasShaderSources(MaterialShaderStage)
public bool HasShaderSources(MaterialShaderStage stage)
Parameters
stage
MaterialShaderStage
Returns
PopLayer()
Pops the current layer.
public void PopLayer()
PopMaterial()
public IMaterialDescriptor PopMaterial()
Returns
PopPass()
public void PopPass()
PushLayer(IComputeScalar)
Pushes a new layer with the specified blend map.
public void PushLayer(IComputeScalar blendMap)
Parameters
blendMap
IComputeScalarThe blend map used by this layer.
PushMaterial(IMaterialDescriptor, string)
Push a material for processing.
public bool PushMaterial(IMaterialDescriptor materialDescriptor, string materialName)
Parameters
materialDescriptor
IMaterialDescriptorThe material descriptor.
materialName
stringFriendly name of the material.
Returns
- bool
true
if the material is valid and can be visited,false
otherwise.
Exceptions
- ArgumentNullException
materialDescriptor
PushPass()
public MaterialPass PushPass()
Returns
SetMultiplePasses(string, int)
Register this material with multiple passes. This is only possible once.
public void SetMultiplePasses(string module, int passCount)
Parameters
SetStream(MaterialShaderStage, string, IComputeNode, ObjectParameterKey<Texture>, ParameterKey, Color?)
public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey<Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color? defaultTextureValue = null)
Parameters
stage
MaterialShaderStagestream
stringcomputeNode
IComputeNodedefaultTexturingKey
ObjectParameterKey<Texture>defaultValueKey
ParameterKeydefaultTextureValue
Color?
SetStream(MaterialShaderStage, string, MaterialStreamType, ShaderSource)
public void SetStream(MaterialShaderStage stage, string stream, MaterialStreamType streamType, ShaderSource shaderSource)
Parameters
stage
MaterialShaderStagestream
stringstreamType
MaterialStreamTypeshaderSource
ShaderSource
SetStream(string, IComputeNode, ObjectParameterKey<Texture>, ParameterKey, Color?)
public void SetStream(string stream, IComputeNode computeNode, ObjectParameterKey<Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color? defaultTextureValue = null)
Parameters
stream
stringcomputeNode
IComputeNodedefaultTexturingKey
ObjectParameterKey<Texture>defaultValueKey
ParameterKeydefaultTextureValue
Color?
SetStreamFinalModifier<T>(MaterialShaderStage, ShaderSource)
public void SetStreamFinalModifier<T>(MaterialShaderStage stage, ShaderSource shaderSource)
Parameters
stage
MaterialShaderStageshaderSource
ShaderSource
Type Parameters
T
UseStream(MaterialShaderStage, string)
public void UseStream(MaterialShaderStage stage, string stream)
Parameters
stage
MaterialShaderStagestream
string
UseStreamWithCustomBlend(MaterialShaderStage, string, ShaderSource)
public void UseStreamWithCustomBlend(MaterialShaderStage stage, string stream, ShaderSource blendStream)
Parameters
stage
MaterialShaderStagestream
stringblendStream
ShaderSource
Visit(IMaterialFeature)
public void Visit(IMaterialFeature feature)
Parameters
feature
IMaterialFeature