Class glTF2StandardMaterialMapper
Converts TriLib virtual materials of glTF2 assets into Unity Standard materials, using shader properties and material presets appropriate for the currently active render pipeline.
Inheritance
Inherited Members
Namespace: TriLibCore.Mappers
Assembly: Assembly-CSharp.dll
Syntax
[Serializable]
[CreateAssetMenu(menuName = "TriLib/Mappers/Material/glTF2 Standard Material Mapper", fileName = "glTF2StandardMaterialMapper")]
public class glTF2StandardMaterialMapper : StandardMaterialMapper
Remarks
This mapper supports both the specular-glossiness and metallic-roughness workflows. Based on the flag UsingSpecularGlossiness, it selects a material preset from HDRP, URP, or Standard resource directories. It forces the use of a shader variant collection and extracts metallic and smoothness properties. The mapper is considered compatible if the reader is a TriLibCore.Gltf.Reader.GltfReader.
Fields
UsingSpecularGlossiness
Declaration
protected bool UsingSpecularGlossiness
Field Value
| Type | Description |
|---|---|
| bool |
Properties
ConvertMaterialTextures
Indicates whether this Material Mapper does "Metallic/Smoothness/Specular/Roughness/Emission" automatic texture creation.
Declaration
public override bool ConvertMaterialTextures { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
CutoutMaterialPreset
A cutout material preset for materials that use alpha testing (fully transparent vs. fully opaque).
Declaration
public override Material CutoutMaterialPreset { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
CutoutMaterialPresetNoMetallicTexture
A cutout material preset for materials with no metallic texture usage.
Declaration
public override Material CutoutMaterialPresetNoMetallicTexture { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
ExtractMetallicAndSmoothness
Indicates whether this Material Mapper automatically extracts Metallic and Smoothness textures.
Declaration
public override bool ExtractMetallicAndSmoothness { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
LoadingMaterial
An optional placeholder material used while a model’s final materials and textures are still loading.
Declaration
public override Material LoadingMaterial { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
MaterialPreset
The default (opaque) material preset.
Declaration
public override Material MaterialPreset { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
MaterialPresetNoMetallicTexture
The default (opaque) material preset for materials with no metallic texture usage.
Declaration
public override Material MaterialPresetNoMetallicTexture { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
TransparentComposeMaterialPreset
A “compose” material preset used in layered alpha workflows when
AlphaMaterialMode is set to CutoutAndTransparent.
This is applied as a secondary pass for partially transparent regions.
Declaration
public override Material TransparentComposeMaterialPreset { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
TransparentComposeMaterialPresetNoMetallicTexture
The “compose” material preset for partially transparent materials that have no metallic texture usage.
Declaration
public override Material TransparentComposeMaterialPresetNoMetallicTexture { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
TransparentMaterialPreset
A fully transparent (alpha) material preset.
Declaration
public override Material TransparentMaterialPreset { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
TransparentMaterialPresetNoMetallicTexture
A fully transparent (alpha) material preset for materials without a metallic texture.
Declaration
public override Material TransparentMaterialPresetNoMetallicTexture { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
UseShaderVariantCollection
If overridden to return true, indicates that this mapper uses a Shader Variant
Collection instead of the usual material presets. By default, it returns false.
Declaration
public override bool UseShaderVariantCollection { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
Remarks
Implementers can override this to provide advanced material handling, especially when working with different pipelines or specialized shader setups.
Methods
ApplyGlossinessMapTexture(TextureLoadingContext)
Declaration
protected override IEnumerable ApplyGlossinessMapTexture(TextureLoadingContext textureLoadingContext)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureLoadingContext | textureLoadingContext |
Returns
| Type | Description |
|---|---|
| IEnumerable |
Overrides
CheckGlossinessValue(MaterialMapperContext)
Declaration
protected override IEnumerable CheckGlossinessValue(MaterialMapperContext materialMapperContext)
Parameters
| Type | Name | Description |
|---|---|---|
| MaterialMapperContext | materialMapperContext |
Returns
| Type | Description |
|---|---|
| IEnumerable |
Overrides
GetGlossinessOrRoughnessName(MaterialMapperContext)
Retrieves the property name for glossiness or roughness, depending on the shader’s workflow.
Declaration
public override string GetGlossinessOrRoughnessName(MaterialMapperContext materialMapperContext)
Parameters
| Type | Name | Description |
|---|---|---|
| MaterialMapperContext | materialMapperContext | Context containing the TriLib virtual material and Unity material references. |
Returns
| Type | Description |
|---|---|
| string |
Overrides
IsCompatible(MaterialMapperContext)
Determines whether this mapper can handle the specified material (e.g., by checking
shader keywords, pipeline features, or other criteria). Mappers with false returns
are skipped in favor of others with higher compatibility.
Declaration
public override bool IsCompatible(MaterialMapperContext materialMapperContext)
Parameters
| Type | Name | Description |
|---|---|---|
| MaterialMapperContext | materialMapperContext | The context providing references to both the TriLib |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
MapCoroutine(MaterialMapperContext)
Begins the material mapping process asynchronously, yielding control back to the caller
to allow frame updates or concurrent loading. Called if UsesCoroutines
returns true.
Declaration
public override IEnumerable MapCoroutine(MaterialMapperContext materialMapperContext)
Parameters
| Type | Name | Description |
|---|---|---|
| MaterialMapperContext | materialMapperContext | Holds references to the TriLib virtual material, the target Unity material, and the overall AssetLoaderContext. |
Returns
| Type | Description |
|---|---|
| IEnumerable | An IEnumerable sequence that yields at intermediate steps for cooperative asynchronous processing. |