Class MaterialExportBase
Converts a Unity Material into a glTF material
Implements
Inherited Members
Namespace: GLTFast.Export
Assembly: glTFast.Export.dll
Syntax
public abstract class MaterialExportBase : IMaterialExport
Fields
BaseColorProperty
_BaseColor shader property identifier
Declaration
public static readonly int BaseColorProperty
Field Value
Type | Description |
---|---|
int |
ColorProperty
_Color shader property identifier
Declaration
public static readonly int ColorProperty
Field Value
Type | Description |
---|---|
int |
CutoffProperty
_Cutoff shader property identifier
Declaration
public static readonly int CutoffProperty
Field Value
Type | Description |
---|---|
int |
MainTexProperty
_MainTex shader property identifier
Declaration
public static readonly int MainTexProperty
Field Value
Type | Description |
---|---|
int |
MetallicProperty
_Metallic shader property identifier
Declaration
public static readonly int MetallicProperty
Field Value
Type | Description |
---|---|
int |
SmoothnessProperty
_Smoothness shader property identifier
Declaration
public static readonly int SmoothnessProperty
Field Value
Type | Description |
---|---|
int |
Methods
AddImageExport(IGltfWritable, ImageExportBase, out int)
Adds an ImageExport to the glTF. No conversions or channel swizzling
Declaration
[Obsolete("Use MaterialExport.AddImageExport instead.")]
protected static bool AddImageExport(IGltfWritable gltf, ImageExportBase imageExport, out int textureId)
Parameters
Type | Name | Description |
---|---|---|
IGltfWritable | gltf | glTF to add the image to. |
ImageExportBase | imageExport | Texture generator to be added |
int | textureId | Resulting texture index. |
Returns
Type | Description |
---|---|
bool | True if the texture was added, false otherwise. |
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 |
---|---|
bool | True if material was converted successfully, false otherwise |
ExportNormalTextureInfo(Texture, Material, IGltfWritable, int)
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 |
int | 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(TextureInfoBase, Material, int, IGltfWritable)
Calculates a texture's transform and adds a KHR_texture_transform glTF extension, if required
Declaration
protected static void ExportTextureTransform(TextureInfoBase def, Material mat, int texPropertyId, IGltfWritable gltf)
Parameters
Type | Name | Description |
---|---|---|
TextureInfoBase | def | glTF TextureInfo to edit |
Material | mat | Source Material |
int | texPropertyId | Texture property to fetch transformation from |
IGltfWritable | gltf | Context glTF to export to (for registering extension usage) |
ExportUnlit(Material, Material, int, 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 |
int | 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 |
---|---|
bool | True if the unlit color was retrieved, false otherwise |
IsDoubleSided(Material, int)
Retrieves whether material is double-sided.
Declaration
protected static bool IsDoubleSided(Material uMaterial, int cullPropId)
Parameters
Type | Name | Description |
---|---|---|
Material | uMaterial | Material to analyze. |
int | cullPropId | CullMode property id. |
Returns
Type | Description |
---|---|
bool | 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 |
---|---|
bool | 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 |