Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    MaterialGeneratorContext Class

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

    Main entry point class for generating shaders from a MaterialDescriptor

    System.Object → DisposeBase → ComponentBase → ShaderGeneratorContext → MaterialGeneratorContext
    Derived from MaterialGeneratorContext:

    public class MaterialGeneratorContext : ShaderGeneratorContext, IDisposable, IComponent, IReferencable, ICollectorHolder
    Name Description
    Constructors
    MaterialGeneratorContext(Material, GraphicsDevice)

    Initializes a new instance of MaterialGeneratorContext.

    Fields
    DefaultFinalCallbackOrder
    Properties
    CurrentMaterialDescriptor

    The current material descriptor on the material stack

    GraphicsProfile

    The graphics profile this material will be compatiable with.

    Material

    Gets the compiled Material.

    MaterialPass

    Gets the compiled MaterialPass. Only valid during GenerateShader.

    PassCount

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

    PassIndex

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

    Step

    The current step of material generation.

    Methods
    AddFinalCallback(MaterialShaderStage, MaterialGeneratorContext.MaterialGeneratorCallback, Int32)
    AddShaderSource(MaterialShaderStage, ShaderSource)
    AddShading<T>(T)
    AddStreamInitializer(MaterialShaderStage, String)
    ComputeShaderSource(MaterialShaderStage)
    GenerateStreamInitializers(MaterialShaderStage)
    GetShading<T>(T)
    GetStreamBlendShaderSource(String)
    GetStreamFinalModifier<T>(MaterialShaderStage)
    HasShaderSources(MaterialShaderStage)
    PopLayer()

    Pops the current layer.

    PopMaterial()
    PopPass()
    PushLayer(IComputeScalar)

    Pushes a new layer with the specified blend map.

    PushMaterial(IMaterialDescriptor, String)

    Push a material for processing.

    PushPass()
    SetMultiplePasses(String, Int32)

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

    SetStream(MaterialShaderStage, String, IComputeNode, ObjectParameterKey<Texture>, ParameterKey, Nullable<Color>)
    SetStream(MaterialShaderStage, String, MaterialStreamType, ShaderSource)
    SetStream(String, IComputeNode, ObjectParameterKey<Texture>, ParameterKey, Nullable<Color>)
    SetStreamFinalModifier<T>(MaterialShaderStage, ShaderSource)
    UseStream(MaterialShaderStage, String)
    UseStreamWithCustomBlend(MaterialShaderStage, String, ShaderSource)
    Visit(IMaterialFeature)
    | Improve this Doc View Source

    Constructors


    MaterialGeneratorContext(Material, GraphicsDevice)

    Initializes a new instance of MaterialGeneratorContext.

    public MaterialGeneratorContext(Material material = null, GraphicsDevice graphicsDevice = null)
    Parameters
    Type Name Description
    Material material
    GraphicsDevice graphicsDevice
    | Improve this Doc View Source

    Fields


    DefaultFinalCallbackOrder

    public const int DefaultFinalCallbackOrder = 0
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Properties


    CurrentMaterialDescriptor

    The current material descriptor on the material stack

    public IMaterialDescriptor CurrentMaterialDescriptor { get; }
    Property Value
    Type Description
    IMaterialDescriptor

    GraphicsProfile

    The graphics profile this material will be compatiable with.

    public GraphicsProfile GraphicsProfile { get; set; }
    Property Value
    Type Description
    GraphicsProfile

    Material

    Gets the compiled Material.

    public Material Material { get; }
    Property Value
    Type Description
    Material

    MaterialPass

    Gets the compiled MaterialPass. Only valid during GenerateShader.

    public MaterialPass MaterialPass { get; set; }
    Property Value
    Type Description
    MaterialPass

    PassCount

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

    public int PassCount { get; }
    Property Value
    Type Description
    System.Int32

    PassIndex

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

    public int PassIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    Step

    The current step of material generation.

    public MaterialGeneratorStep Step { get; set; }
    Property Value
    Type Description
    MaterialGeneratorStep
    | Improve this Doc View Source

    Methods


    AddFinalCallback(MaterialShaderStage, MaterialGeneratorContext.MaterialGeneratorCallback, Int32)

    public void AddFinalCallback(MaterialShaderStage stage, MaterialGeneratorContext.MaterialGeneratorCallback callback, int order = 0)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    MaterialGeneratorContext.MaterialGeneratorCallback callback
    System.Int32 order

    AddShaderSource(MaterialShaderStage, ShaderSource)

    public void AddShaderSource(MaterialShaderStage stage, ShaderSource shaderSource)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    ShaderSource shaderSource

    AddShading<T>(T)

    public ShadingModelShaderBuilder AddShading<T>(T shadingModel)
        where T : class, IMaterialShadingModelFeature
    Parameters
    Type Name Description
    T shadingModel
    Returns
    Type Description
    ShadingModelShaderBuilder
    Type Parameters
    Name Description
    T

    AddStreamInitializer(MaterialShaderStage, String)

    public void AddStreamInitializer(MaterialShaderStage stage, string streamInitilizerSource)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    System.String streamInitilizerSource

    ComputeShaderSource(MaterialShaderStage)

    public ShaderSource ComputeShaderSource(MaterialShaderStage stage)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    Returns
    Type Description
    ShaderSource

    GenerateStreamInitializers(MaterialShaderStage)

    public ShaderSource GenerateStreamInitializers(MaterialShaderStage stage)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    Returns
    Type Description
    ShaderSource

    GetShading<T>(T)

    public ShadingModelShaderBuilder GetShading<T>(T shadingModel)
        where T : class, IMaterialShadingModelFeature
    Parameters
    Type Name Description
    T shadingModel
    Returns
    Type Description
    ShadingModelShaderBuilder
    Type Parameters
    Name Description
    T

    GetStreamBlendShaderSource(String)

    public ShaderSource GetStreamBlendShaderSource(string stream)
    Parameters
    Type Name Description
    System.String stream
    Returns
    Type Description
    ShaderSource

    GetStreamFinalModifier<T>(MaterialShaderStage)

    public ShaderSource GetStreamFinalModifier<T>(MaterialShaderStage stage)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    Returns
    Type Description
    ShaderSource
    Type Parameters
    Name Description
    T

    HasShaderSources(MaterialShaderStage)

    public bool HasShaderSources(MaterialShaderStage stage)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    Returns
    Type Description
    System.Boolean

    PopLayer()

    Pops the current layer.

    public void PopLayer()

    PopMaterial()

    public IMaterialDescriptor PopMaterial()
    Returns
    Type Description
    IMaterialDescriptor

    PopPass()

    public void PopPass()

    PushLayer(IComputeScalar)

    Pushes a new layer with the specified blend map.

    public void PushLayer(IComputeScalar blendMap)
    Parameters
    Type Name Description
    IComputeScalar blendMap

    The blend map used by this layer.


    PushMaterial(IMaterialDescriptor, String)

    Push a material for processing.

    public bool PushMaterial(IMaterialDescriptor materialDescriptor, string materialName)
    Parameters
    Type Name Description
    IMaterialDescriptor materialDescriptor

    The material descriptor.

    System.String materialName

    Friendly name of the material.

    Returns
    Type Description
    System.Boolean

    true if the material is valid and can be visited, false otherwise.

    Exceptions
    Type Condition
    System.ArgumentNullException

    materialDescriptor


    PushPass()

    public MaterialPass PushPass()
    Returns
    Type Description
    MaterialPass

    SetMultiplePasses(String, Int32)

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

    public void SetMultiplePasses(string module, int passCount)
    Parameters
    Type Name Description
    System.String module

    The module

    System.Int32 passCount

    SetStream(MaterialShaderStage, String, IComputeNode, ObjectParameterKey<Texture>, ParameterKey, Nullable<Color>)

    public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey<Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color? defaultTextureValue = null)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    System.String stream
    IComputeNode computeNode
    ObjectParameterKey<Texture> defaultTexturingKey
    ParameterKey defaultValueKey
    System.Nullable<Color> defaultTextureValue

    SetStream(MaterialShaderStage, String, MaterialStreamType, ShaderSource)

    public void SetStream(MaterialShaderStage stage, string stream, MaterialStreamType streamType, ShaderSource shaderSource)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    System.String stream
    MaterialStreamType streamType
    ShaderSource shaderSource

    SetStream(String, IComputeNode, ObjectParameterKey<Texture>, ParameterKey, Nullable<Color>)

    public void SetStream(string stream, IComputeNode computeNode, ObjectParameterKey<Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color? defaultTextureValue = null)
    Parameters
    Type Name Description
    System.String stream
    IComputeNode computeNode
    ObjectParameterKey<Texture> defaultTexturingKey
    ParameterKey defaultValueKey
    System.Nullable<Color> defaultTextureValue

    SetStreamFinalModifier<T>(MaterialShaderStage, ShaderSource)

    public void SetStreamFinalModifier<T>(MaterialShaderStage stage, ShaderSource shaderSource)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    ShaderSource shaderSource
    Type Parameters
    Name Description
    T

    UseStream(MaterialShaderStage, String)

    public void UseStream(MaterialShaderStage stage, string stream)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    System.String stream

    UseStreamWithCustomBlend(MaterialShaderStage, String, ShaderSource)

    public void UseStreamWithCustomBlend(MaterialShaderStage stage, string stream, ShaderSource blendStream)
    Parameters
    Type Name Description
    MaterialShaderStage stage
    System.String stream
    ShaderSource blendStream

    Visit(IMaterialFeature)

    public void Visit(IMaterialFeature feature)
    Parameters
    Type Name Description
    IMaterialFeature feature

    Inherited Members

    ShaderGeneratorContext.FindAsset
    ShaderGeneratorContext.GetAssetFriendlyName
    ShaderGeneratorContext.Log
    ShaderGeneratorContext.Content
    ShaderGeneratorContext.Parameters
    ShaderGeneratorContext.CurrentOverrides
    ShaderGeneratorContext.ColorSpace
    ShaderGeneratorContext.IsNotPixelStage
    ShaderGeneratorContext.OptimizeMaterials
    ShaderGeneratorContext.GetParameterKey(ParameterKey)
    ShaderGeneratorContext.GenerateTextureFromColor(Color)
    ShaderGeneratorContext.GetTextureKey(Texture, ObjectParameterKey<Texture>, Nullable<Color>)
    ShaderGeneratorContext.GetSamplerKey(SamplerStateDescription, GraphicsDevice)
    ShaderGeneratorContext.GetTextureKey(ComputeTextureBase, MaterialComputeColorKeys)
    ShaderGeneratorContext.GetSamplerKey(ComputeColorParameterSampler)
    ShaderGeneratorContext.ResetParameterKeys()
    ShaderGeneratorContext.PushOverrides(MaterialOverrides)
    ShaderGeneratorContext.PopOverrides()
    ComponentBase.Tags
    ComponentBase.Name
    ComponentBase.Destroy()
    ComponentBase.ICollectorHolder.Collector
    ComponentBase.OnNameChanged()
    ComponentBase.ToString()
    DisposeBase.Dispose()
    DisposeBase.IsDisposed
    DisposeBase.IReferencable.ReferenceCount
    DisposeBase.IReferencable.AddReference()
    DisposeBase.IReferencable.Release()
    DisposeBase.OnAddReference()
    DisposeBase.OnReleaseReference()

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation