docs.unity3d.com
    Show / Hide Table of Contents

    Class MaterialExportBase

    Converts a Unity Material into a glTF material

    Inheritance
    Object
    MaterialExportBase
    HighDefinitionMaterialExport
    StandardMaterialExport
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: GLTFast.Export
    Syntax
    public abstract class MaterialExportBase : IMaterialExport

    Fields

    BaseColorProperty

    _BaseColor shader property identifier

    Declaration
    public static readonly int BaseColorProperty
    Field Value
    Type Description
    Int32

    ColorProperty

    _Color shader property identifier

    Declaration
    public static readonly int ColorProperty
    Field Value
    Type Description
    Int32

    CutoffProperty

    _Cutoff shader property identifier

    Declaration
    public static readonly int CutoffProperty
    Field Value
    Type Description
    Int32

    MainTexProperty

    _MainTex shader property identifier

    Declaration
    public static readonly int MainTexProperty
    Field Value
    Type Description
    Int32

    MetallicProperty

    _Metallic shader property identifier

    Declaration
    public static readonly int MetallicProperty
    Field Value
    Type Description
    Int32

    SmoothnessProperty

    _Smoothness shader property identifier

    Declaration
    public static readonly int SmoothnessProperty
    Field Value
    Type Description
    Int32

    Methods

    AddImageExport(IGltfWritable, ImageExportBase, out Int32)

    Adds an ImageExport to the glTF. No conversions or channel swizzling

    Declaration
    protected static bool AddImageExport(IGltfWritable gltf, ImageExportBase imageExport, out int textureId)
    Parameters
    Type Name Description
    IGltfWritable gltf
    ImageExportBase imageExport
    Int32 textureId
    Returns
    Type Description
    Boolean

    glTF texture ID

    ConvertMaterial(Material, out Material, IGltfWritable, ICodeLogger)

    Converts a Unity material into a glTF material

    Declaration
    public abstract bool ConvertMaterial(Material uMaterial, out Material material, IGltfWritable gltf, ICodeLogger logger)
    Parameters
    Type Name Description
    Material uMaterial

    Source material

    Material material

    Resulting glTF material

    IGltfWritable gltf

    glTF to export material to. Will be used to add required texture images

    ICodeLogger logger

    Custom logger

    Returns
    Type Description
    Boolean

    True if material was converted successfully, false otherwise

    Implements
    IMaterialExport.ConvertMaterial(Material, out Material, IGltfWritable, ICodeLogger)

    ExportNormalTextureInfo(Texture, Material, IGltfWritable, Int32)

    Export a normal texture from Unity to glTF.

    Declaration
    protected static NormalTextureInfo ExportNormalTextureInfo(Texture texture, Material material, IGltfWritable gltf, int normalScalePropId)
    Parameters
    Type Name Description
    Texture texture

    Normal texture to export

    Material material

    Material the normal is used on

    IGltfWritable gltf

    Context glTF to export to

    Int32 normalScalePropId

    Normal scale property ID

    Returns
    Type Description
    NormalTextureInfo

    glTF texture info

    ExportTextureInfo(Texture, IGltfWritable, ImageFormat)

    Export a Unity texture to a glTF.

    Declaration
    protected static TextureInfo ExportTextureInfo(Texture texture, IGltfWritable gltf, ImageFormat format = ImageFormat.Unknown)
    Parameters
    Type Name Description
    Texture texture

    Texture to export.

    IGltfWritable gltf

    Context glTF to export to

    ImageFormat format

    Desired image format

    Returns
    Type Description
    TextureInfo

    glTF texture info

    ExportTextureTransform(TextureInfo, Material, Int32, IGltfWritable)

    Calculates a texture's transform and adds a KHR_texture_transform glTF extension, if required

    Declaration
    protected static void ExportTextureTransform(TextureInfo def, Material mat, int texPropertyId, IGltfWritable gltf)
    Parameters
    Type Name Description
    TextureInfo def

    glTF TextureInfo to edit

    Material mat

    Source Material

    Int32 texPropertyId

    Texture property to fetch transformation from

    IGltfWritable gltf

    Context glTF to export to (for registering extension usage)

    ExportUnlit(Material, Material, Int32, IGltfWritable, ICodeLogger)

    Converts an unlit Unity material into a glTF material

    Declaration
    protected void ExportUnlit(Material material, Material uMaterial, int mainTexProperty, IGltfWritable gltf, ICodeLogger logger)
    Parameters
    Type Name Description
    Material material

    Destination glTF material

    Material uMaterial

    Source Unity material

    Int32 mainTexProperty

    Main texture property ID

    IGltfWritable gltf

    Context glTF to export to

    ICodeLogger logger

    Custom logger

    GetUnlitColor(Material, out Color)

    Returns the color of an unlit material

    Declaration
    protected virtual bool GetUnlitColor(Material uMaterial, out Color baseColor)
    Parameters
    Type Name Description
    Material uMaterial

    Unity material

    Color baseColor

    Resulting unlit color

    Returns
    Type Description
    Boolean

    True if the unlit color was retrieved, false otherwise

    IsDoubleSided(Material, Int32)

    Retrieves whether material is double-sided.

    Declaration
    protected static bool IsDoubleSided(Material uMaterial, int cullPropId)
    Parameters
    Type Name Description
    Material uMaterial

    Material to analyze.

    Int32 cullPropId

    CullMode property id.

    Returns
    Type Description
    Boolean

    True if material is double-sided, false otherwise.

    IsUnlit(Material)

    Retrieves whether material is unlit

    Declaration
    protected static bool IsUnlit(Material material)
    Parameters
    Type Name Description
    Material material

    Material to analyze

    Returns
    Type Description
    Boolean

    True if material uses unlit shader, false otherwise

    SetAlphaModeAndCutoff(Material, Material)

    Applies alpha mode and cutoff

    Declaration
    protected static void SetAlphaModeAndCutoff(Material uMaterial, Material material)
    Parameters
    Type Name Description
    Material uMaterial

    Source Unity Material

    Material material

    glTF material to apply settings on

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023