TriLib 2.2.8
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Properties | List of all members
TriLibCore.Mappers.MaterialMapper Class Reference

Represents a Mapper used to convert Model Materials into Unity Materials. More...

Inheritance diagram for TriLibCore.Mappers.MaterialMapper:
TriLibCore.HDRP.Mappers.HDRPMaterialMapper TriLibCore.Mappers.StandardMaterialMapper TriLibCore.URP.Mappers.UniversalRPMaterialMapper

Public Member Functions

virtual bool IsCompatible (MaterialMapperContext materialMapperContext)
 Determines whether this Mapper is compatible with the given Material Renderer Context.
 
virtual void Map (MaterialMapperContext materialMapperContext)
 Starts the mapping process, comparing the Mapper Properties against the source Material ones.
 
void ApplyMaterialToRenderer (MaterialRendererContext materialRendererContext)
 Applies Material to the Renderer using the context data.
 
virtual string GetDiffuseTextureName (MaterialMapperContext materialMapperContext)
 Gets the Diffuse Texture Property name.
 
virtual string GetDiffuseColorName (MaterialMapperContext materialMapperContext)
 Gets the Diffuse Color Property name.
 
virtual string GetEmissionColorName (MaterialMapperContext materialMapperContext)
 Gets the Emission Color Property name.
 
virtual string GetGlossinessOrRoughnessName (MaterialMapperContext materialMapperContext)
 Gets the Glossiness or Roughness Property name.
 
virtual string GetMetallicName (MaterialMapperContext materialMapperContext)
 Gets the Metallic Property name.
 
virtual string GetGlossinessOrRoughnessTextureName (MaterialMapperContext materialMapperContext)
 Gets the Glossiness or Roughness Texture Property name.
 
virtual string GetMetallicTextureName (MaterialMapperContext materialMapperContext)
 Gets the Metallic Texture Property name.
 

Public Attributes

bool ForceStandardMaterial = false
 Force the usage of the Standard Material preset?
 
int CheckingOrder
 Priority when testing the compatibility of this Mapper. Lower priority Mappers will be tested later.
 

Static Public Attributes

static Action< TextureLoadingContextCreateTextureCallback
 
static Action< TextureLoadingContextLoadTextureCallback
 
static Action< TextureLoadingContextScanForAlphaPixelsCallback
 
static Action< TextureLoadingContextApplyTextureCallback
 
static Action< TextureLoadingContextFixNPOTTextureCallback
 
static Action< TextureLoadingContextFixNormalMapCallback
 
static Action< TextureLoadingContextPostProcessTextureCallback
 The method to call when the Mapper has to post-process a Texture data.
 

Protected Member Functions

void LoadTextureWithCallbacks (MaterialMapperContext materialMapperContext, TextureType textureType, ITexture texture, params Action< TextureLoadingContext >[] onTextureProcessed)
 Loads a Texture using callbacks to be called on the main Thread later.
 
void BuildMaterial (MaterialMapperContext materialMapperContext)
 Creates the final Unity Material using the given context data.
 

Static Protected Member Functions

static void CheckTextureOffsetAndScaling (TextureLoadingContext textureLoadingContext)
 Applies the Texture scaling and offset, when applicable.
 
static void CheckTextureOffsetAndScaling (MaterialMapperContext materialMapperContext, ITexture texture, bool textureLoaded)
 

Properties

static List< string > RegisteredMappers [get]
 Default Material Mappers list.
 
static List< string > RegisteredMapperNamespaces [get]
 Default Material Mappers namespace list.
 
virtual bool ExtractMetallicAndSmoothness = true [get]
 Turn off this field to disable metallic and smoothness textures extraction.
 
virtual Material MaterialPreset [get]
 Standard Material preset to instantiate.
 
virtual Material CutoutMaterialPreset [get]
 Cutout material preset.
 
virtual Material TransparentMaterialPreset [get]
 Transparent (alpha) material preset.
 
virtual Material TransparentComposeMaterialPreset [get]
 Compose (secondary) material preset to use when AssetLoaderOptions.AlphaMaterialMode is set to CutoutAndTransparent.
 
virtual Material MaterialPresetNoMetallicTexture [get]
 
virtual Material CutoutMaterialPresetNoMetallicTexture [get]
 
virtual Material TransparentMaterialPresetNoMetallicTexture [get]
 
virtual Material TransparentComposeMaterialPresetNoMetallicTexture [get]
 
virtual Material SpecularMaterialPreset [get]
 
virtual Material SpecularCutoutMaterialPreset [get]
 
virtual Material SpecularTransparentMaterialPreset [get]
 
virtual Material SpecularTransparentComposeMaterialPreset [get]
 
virtual Material AutodeskMaterialPreset [get]
 
virtual Material AutodeskCutoutMaterialPreset [get]
 
virtual Material AutodeskTransparentMaterialPreset [get]
 
virtual Material AutodeskTransparentComposeMaterialPreset [get]
 
virtual Material LoadingMaterial [get]
 Gets the loading Material preset for this Mapper.
 

Detailed Description

Represents a Mapper used to convert Model Materials into Unity Materials.

Member Function Documentation

◆ ApplyMaterialToRenderer()

void TriLibCore.Mappers.MaterialMapper.ApplyMaterialToRenderer ( MaterialRendererContext  materialRendererContext)

Applies Material to the Renderer using the context data.

Parameters
materialRendererContextThe Material Renderer Context, containing the Material and Unity Renderer.

◆ BuildMaterial()

void TriLibCore.Mappers.MaterialMapper.BuildMaterial ( MaterialMapperContext  materialMapperContext)
protected

Creates the final Unity Material using the given context data.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

◆ CheckTextureOffsetAndScaling() [1/2]

static void TriLibCore.Mappers.MaterialMapper.CheckTextureOffsetAndScaling ( MaterialMapperContext  materialMapperContext,
ITexture  texture,
bool  textureLoaded 
)
staticprotected
Deprecated:
Applies the Texture scaling and offset, when applicable.
Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.
textureThe TriLib Texture.
textureLoadedIndicates whether the Unity Texture has been loaded.

◆ CheckTextureOffsetAndScaling() [2/2]

static void TriLibCore.Mappers.MaterialMapper.CheckTextureOffsetAndScaling ( TextureLoadingContext  textureLoadingContext)
staticprotected

Applies the Texture scaling and offset, when applicable.

Parameters
textureLoadingContextThe Texture Context containing Data from the original and the Unity Texture.

◆ GetDiffuseColorName()

virtual string TriLibCore.Mappers.MaterialMapper.GetDiffuseColorName ( MaterialMapperContext  materialMapperContext)
virtual

Gets the Diffuse Color Property name.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ GetDiffuseTextureName()

virtual string TriLibCore.Mappers.MaterialMapper.GetDiffuseTextureName ( MaterialMapperContext  materialMapperContext)
virtual

Gets the Diffuse Texture Property name.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ GetEmissionColorName()

virtual string TriLibCore.Mappers.MaterialMapper.GetEmissionColorName ( MaterialMapperContext  materialMapperContext)
virtual

Gets the Emission Color Property name.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ GetGlossinessOrRoughnessName()

virtual string TriLibCore.Mappers.MaterialMapper.GetGlossinessOrRoughnessName ( MaterialMapperContext  materialMapperContext)
virtual

Gets the Glossiness or Roughness Property name.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ GetGlossinessOrRoughnessTextureName()

virtual string TriLibCore.Mappers.MaterialMapper.GetGlossinessOrRoughnessTextureName ( MaterialMapperContext  materialMapperContext)
virtual

Gets the Glossiness or Roughness Texture Property name.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ GetMetallicName()

virtual string TriLibCore.Mappers.MaterialMapper.GetMetallicName ( MaterialMapperContext  materialMapperContext)
virtual

Gets the Metallic Property name.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ GetMetallicTextureName()

virtual string TriLibCore.Mappers.MaterialMapper.GetMetallicTextureName ( MaterialMapperContext  materialMapperContext)
virtual

Gets the Metallic Texture Property name.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ IsCompatible()

virtual bool TriLibCore.Mappers.MaterialMapper.IsCompatible ( MaterialMapperContext  materialMapperContext)
virtual

Determines whether this Mapper is compatible with the given Material Renderer Context.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.
Returns
true if this Mapper is compatible with the given Material Renderer Context, otherwise, false.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

◆ LoadTextureWithCallbacks()

void TriLibCore.Mappers.MaterialMapper.LoadTextureWithCallbacks ( MaterialMapperContext  materialMapperContext,
TextureType  textureType,
ITexture  texture,
params Action< TextureLoadingContext >[]  onTextureProcessed 
)
protected

Loads a Texture using callbacks to be called on the main Thread later.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.
textureTypeThe Texture Type.
textureThe source Texture to load.
onTextureProcessedCallbacks to call when the Texture is processed.
Returns
The loaded Texture, or null.

◆ Map()

virtual void TriLibCore.Mappers.MaterialMapper.Map ( MaterialMapperContext  materialMapperContext)
virtual

Starts the mapping process, comparing the Mapper Properties against the source Material ones.

Parameters
materialMapperContextThe source Material Mapper Context, containing the Virtual Material and Unity Material.

Reimplemented in TriLibCore.Mappers.StandardMaterialMapper, TriLibCore.HDRP.Mappers.HDRPMaterialMapper, and TriLibCore.URP.Mappers.UniversalRPMaterialMapper.

Member Data Documentation

◆ ApplyTextureCallback

Action<TextureLoadingContext> TriLibCore.Mappers.MaterialMapper.ApplyTextureCallback
static

summary> The method to call to fix NPOT textures. /summary>

◆ CreateTextureCallback

Action<TextureLoadingContext> TriLibCore.Mappers.MaterialMapper.CreateTextureCallback
static

summary> The method to call when the Mapper has to load a Texture. /summary>

◆ FixNPOTTextureCallback

Action<TextureLoadingContext> TriLibCore.Mappers.MaterialMapper.FixNPOTTextureCallback
static

summary> The method to call to fix normal map textures. /summary>

◆ LoadTextureCallback

Action<TextureLoadingContext> TriLibCore.Mappers.MaterialMapper.LoadTextureCallback
static

summary> The method to call to scan the texture for alpha pixels. /summary>

◆ ScanForAlphaPixelsCallback

Action<TextureLoadingContext> TriLibCore.Mappers.MaterialMapper.ScanForAlphaPixelsCallback
static

summary> The method to call to apply texture CPU data. /summary>

Property Documentation

◆ LoadingMaterial

virtual Material TriLibCore.Mappers.MaterialMapper.LoadingMaterial
get

Gets the loading Material preset for this Mapper.

The loading Material preset.

◆ SpecularCutoutMaterialPreset

virtual Material TriLibCore.Mappers.MaterialMapper.SpecularCutoutMaterialPreset
get
Deprecated:
Specular cutout material preset.

◆ SpecularMaterialPreset

virtual Material TriLibCore.Mappers.MaterialMapper.SpecularMaterialPreset
get
Deprecated:
Specular Material preset to instantiate.

◆ SpecularTransparentComposeMaterialPreset

virtual Material TriLibCore.Mappers.MaterialMapper.SpecularTransparentComposeMaterialPreset
get
Deprecated:
Specular compose (secondary) specular material preset to use when AssetLoaderOptions.AlphaMaterialMode is set to CutoutAndTransparent.

◆ SpecularTransparentMaterialPreset

virtual Material TriLibCore.Mappers.MaterialMapper.SpecularTransparentMaterialPreset
get
Deprecated:
Specular transparent (alpha) material preset.