docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class MaterialGenerator

    Common base class for implementations of IMaterialGenerator

    Inheritance
    object
    MaterialGenerator
    BuiltInMaterialGenerator
    ShaderGraphMaterialGenerator
    Implements
    IMaterialGenerator
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Cloud.Gltfast.Materials
    Assembly: Unity.Cloud.Gltfast.dll
    Syntax
    [MovedFrom(true, "GLTFast.Materials", "glTFast", null)]
    public abstract class MaterialGenerator : IMaterialGenerator

    Fields

    AlphaTestOnKeyword

    Shader keyword _ALPHATEST_ON

    Declaration
    public const string AlphaTestOnKeyword = "_ALPHATEST_ON"
    Field Value
    Type Description
    string

    DefaultMaterialName

    When a glTF mesh(primitive) has no material assigned, a default material, has to get created and assigned. This default material should get named after this field's value to ensure future round-trip workflows are functioning.

    Declaration
    public const string DefaultMaterialName = "glTF-Default-Material"
    Field Value
    Type Description
    string

    FadeRenderType

    Render type Fade value

    Declaration
    public const string FadeRenderType = "Fade"
    Field Value
    Type Description
    string

    OpaqueRenderType

    Render type Opaque value

    Declaration
    public const string OpaqueRenderType = "Opaque"
    Field Value
    Type Description
    string

    RenderTypeTag

    Render type key

    Declaration
    public const string RenderTypeTag = "RenderType"
    Field Value
    Type Description
    string

    TextureTransformKeyword

    Shader keyword _TEXTURE_TRANSFORM

    Declaration
    public const string TextureTransformKeyword = "_TEXTURE_TRANSFORM"
    Field Value
    Type Description
    string

    TransparentCutoutRenderType

    Render type TransparentCutout value

    Declaration
    public const string TransparentCutoutRenderType = "TransparentCutout"
    Field Value
    Type Description
    string

    TransparentRenderType

    Render type Transparent value

    Declaration
    public const string TransparentRenderType = "Transparent"
    Field Value
    Type Description
    string

    UVChannelSelectKeyword

    Shader keyword _UV_CHANNEL_SELECT

    Declaration
    public const string UVChannelSelectKeyword = "_UV_CHANNEL_SELECT"
    Field Value
    Type Description
    string

    Properties

    Logger

    Logger to be used for messaging. Can be null!

    Declaration
    protected ICodeLogger Logger { get; }
    Property Value
    Type Description
    ICodeLogger

    Methods

    FindShader(string)

    Loads a shader by name and does eventual error reporting.

    Declaration
    protected virtual Shader FindShader(string shaderName)
    Parameters
    Type Name Description
    string shaderName

    The requested shader's name.

    Returns
    Type Description
    Shader

    Requested shader or null if it couldn't be loaded.

    FindShader(string, ICodeLogger)

    Loads a shader by name and does eventual error reporting.

    Declaration
    protected static Shader FindShader(string shaderName, ICodeLogger logger)
    Parameters
    Type Name Description
    string shaderName

    The requested shader's name.

    ICodeLogger logger

    Logger used for reporting errors.

    Returns
    Type Description
    Shader

    Requested shader or null if it couldn't be loaded.

    GenerateDefaultMaterial(bool)

    Creates a fallback material to be assigned to nodes without a material.

    Declaration
    protected abstract Material GenerateDefaultMaterial(bool pointsSupport = false)
    Parameters
    Type Name Description
    bool pointsSupport

    If true, material has to support meshes with points topology

    Returns
    Type Description
    Material

    fallback material

    GenerateMaterial(Material, IGltfReadable, bool)

    Converts a glTF material into a Unity Material. gltfMaterial might reference textures, which can be queried from gltf.

    Declaration
    public abstract Material GenerateMaterial(Material gltfMaterial, IGltfReadable gltf, bool pointsSupport = false)
    Parameters
    Type Name Description
    Material gltfMaterial

    Source glTF material

    IGltfReadable gltf

    Interface to a loaded glTF's resources (e.g. textures)

    bool pointsSupport

    If true, material has to support meshes with points topology.

    Returns
    Type Description
    Material

    Generated Unity Material

    GetDefaultMaterial(bool)

    Get fallback material that is assigned to nodes without a material.

    Declaration
    public Material GetDefaultMaterial(bool pointsSupport = false)
    Parameters
    Type Name Description
    bool pointsSupport

    If true, material has to support meshes with points topology.

    Returns
    Type Description
    Material

    fallback material

    GetDefaultMaterialGenerator()

    Provides the default material generator that's being used if no custom material generator was provided. The result depends on the currently used render pipeline.

    Declaration
    public static IMaterialGenerator GetDefaultMaterialGenerator()
    Returns
    Type Description
    IMaterialGenerator

    The default material generator

    Exceptions
    Type Condition
    InvalidOperationException

    Is thrown when the default material generator couldn't be determined based on the current render pipeline.

    SetLogger(ICodeLogger)

    Has to be called prior to GenerateMaterial(Material, IGltfReadable, bool). The logger can be used to inform users about incidents of arbitrary severity (error,warning or info) during material generation.

    Declaration
    public void SetLogger(ICodeLogger logger)
    Parameters
    Type Name Description
    ICodeLogger logger

    Logger to be used.

    TransmissionWorkaroundShaderMode(Transmission, ref Color)

    Approximates Transmission material effect for Render Pipelines / Shaders where filtering the backbuffer is not possible.

    Declaration
    protected static bool TransmissionWorkaroundShaderMode(Transmission transmission, ref Color baseColorLinear)
    Parameters
    Type Name Description
    Transmission transmission

    glTF transmission extension data

    Color baseColorLinear

    BaseColor reference. Alpha will be altered according to transmission

    Returns
    Type Description
    bool

    True when the transmission can be approximated with Premultiply mode. False if blending is better

    TrySetTexture(TextureInfo, Material, IGltfReadable, int, int, int, int)

    Attempts assigning a glTF texture to a Unity material.

    Declaration
    protected bool TrySetTexture(TextureInfo textureInfo, Material material, IGltfReadable gltf, int texturePropertyId, int scaleTransformPropertyId = -1, int rotationPropertyId = -1, int uvChannelPropertyId = -1)
    Parameters
    Type Name Description
    TextureInfo textureInfo

    glTF source texture

    Material material

    target material

    IGltfReadable gltf

    Context glTF

    int texturePropertyId

    Target texture property

    int scaleTransformPropertyId

    Scale/transform (_ST) property

    int rotationPropertyId

    Rotation property

    int uvChannelPropertyId

    UV channel selection property

    Returns
    Type Description
    bool

    True if texture assignment was successful, false otherwise.

    Implements

    IMaterialGenerator
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)