Table of Contents

Class MaterialGeneratorContext

Namespace
Stride.Rendering.Materials
Assembly
Stride.Rendering.dll

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 Material
graphicsDevice GraphicsDevice

Fields

DefaultFinalCallbackOrder

public const int DefaultFinalCallbackOrder = 0

Field Value

int

Properties

CurrentMaterialDescriptor

The current material descriptor on the material stack

public IMaterialDescriptor CurrentMaterialDescriptor { get; }

Property Value

IMaterialDescriptor

GraphicsProfile

The graphics profile this material will be compatiable with.

public GraphicsProfile GraphicsProfile { get; set; }

Property Value

GraphicsProfile

Material

Gets the compiled Material.

public Material Material { get; }

Property Value

Material

MaterialPass

Gets the compiled MaterialPass. Only valid during GenerateShader.

public MaterialPass MaterialPass { get; set; }

Property Value

MaterialPass

PassCount

In case of multi pass materials, this describe the number of passes.

public int PassCount { get; }

Property Value

int

PassIndex

The current pass (used by multipass materials). Only valid during GenerateShader.

public int PassIndex { get; set; }

Property Value

int

Step

The current step of material generation.

public MaterialGeneratorStep Step { get; set; }

Property Value

MaterialGeneratorStep

Methods

AddFinalCallback(MaterialShaderStage, MaterialGeneratorCallback, int)

public void AddFinalCallback(MaterialShaderStage stage, MaterialGeneratorContext.MaterialGeneratorCallback callback, int order = 0)

Parameters

stage MaterialShaderStage
callback MaterialGeneratorContext.MaterialGeneratorCallback
order int

AddShaderSource(MaterialShaderStage, ShaderSource)

public void AddShaderSource(MaterialShaderStage stage, ShaderSource shaderSource)

Parameters

stage MaterialShaderStage
shaderSource ShaderSource

AddShading<T>(T)

public ShadingModelShaderBuilder AddShading<T>(T shadingModel) where T : class, IMaterialShadingModelFeature

Parameters

shadingModel T

Returns

ShadingModelShaderBuilder

Type Parameters

T

AddStreamInitializer(MaterialShaderStage, string)

public void AddStreamInitializer(MaterialShaderStage stage, string streamInitilizerSource)

Parameters

stage MaterialShaderStage
streamInitilizerSource string

ComputeShaderSource(MaterialShaderStage)

public ShaderSource ComputeShaderSource(MaterialShaderStage stage)

Parameters

stage MaterialShaderStage

Returns

ShaderSource

GenerateStreamInitializers(MaterialShaderStage)

public ShaderSource GenerateStreamInitializers(MaterialShaderStage stage)

Parameters

stage MaterialShaderStage

Returns

ShaderSource

GetShading<T>(T)

public ShadingModelShaderBuilder GetShading<T>(T shadingModel) where T : class, IMaterialShadingModelFeature

Parameters

shadingModel T

Returns

ShadingModelShaderBuilder

Type Parameters

T

GetStreamBlendShaderSource(string)

public ShaderSource GetStreamBlendShaderSource(string stream)

Parameters

stream string

Returns

ShaderSource

GetStreamFinalModifier<T>(MaterialShaderStage)

public ShaderSource GetStreamFinalModifier<T>(MaterialShaderStage stage)

Parameters

stage MaterialShaderStage

Returns

ShaderSource

Type Parameters

T

HasShaderSources(MaterialShaderStage)

public bool HasShaderSources(MaterialShaderStage stage)

Parameters

stage MaterialShaderStage

Returns

bool

PopLayer()

Pops the current layer.

public void PopLayer()

PopMaterial()

public IMaterialDescriptor PopMaterial()

Returns

IMaterialDescriptor

PopPass()

public void PopPass()

PushLayer(IComputeScalar)

Pushes a new layer with the specified blend map.

public void PushLayer(IComputeScalar blendMap)

Parameters

blendMap IComputeScalar

The blend map used by this layer.

PushMaterial(IMaterialDescriptor, string)

Push a material for processing.

public bool PushMaterial(IMaterialDescriptor materialDescriptor, string materialName)

Parameters

materialDescriptor IMaterialDescriptor

The material descriptor.

materialName string

Friendly 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

MaterialPass

SetMultiplePasses(string, int)

Register this material with multiple passes. This is only possible once.

public void SetMultiplePasses(string module, int passCount)

Parameters

module string

The module

passCount int

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 MaterialShaderStage
stream string
computeNode IComputeNode
defaultTexturingKey ObjectParameterKey<Texture>
defaultValueKey ParameterKey
defaultTextureValue Color?

SetStream(MaterialShaderStage, string, MaterialStreamType, ShaderSource)

public void SetStream(MaterialShaderStage stage, string stream, MaterialStreamType streamType, ShaderSource shaderSource)

Parameters

stage MaterialShaderStage
stream string
streamType MaterialStreamType
shaderSource 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 string
computeNode IComputeNode
defaultTexturingKey ObjectParameterKey<Texture>
defaultValueKey ParameterKey
defaultTextureValue Color?

SetStreamFinalModifier<T>(MaterialShaderStage, ShaderSource)

public void SetStreamFinalModifier<T>(MaterialShaderStage stage, ShaderSource shaderSource)

Parameters

stage MaterialShaderStage
shaderSource ShaderSource

Type Parameters

T

UseStream(MaterialShaderStage, string)

public void UseStream(MaterialShaderStage stage, string stream)

Parameters

stage MaterialShaderStage
stream string

UseStreamWithCustomBlend(MaterialShaderStage, string, ShaderSource)

public void UseStreamWithCustomBlend(MaterialShaderStage stage, string stream, ShaderSource blendStream)

Parameters

stage MaterialShaderStage
stream string
blendStream ShaderSource

Visit(IMaterialFeature)

public void Visit(IMaterialFeature feature)

Parameters

feature IMaterialFeature