Material

@Serializable
data class Material(var name: String? = null, val alphaMode: String? = null, val alphaCutoff: Float = 0.5f, val doubleSided: Boolean = true, val emissiveFactor: FloatArray? = null, val emissiveTexture: GLTF2.Material.TextureInfo? = null, val pbrMetallicRoughness: GLTF2.Material.PBRMetallicRoughness? = null, val normalTexture: GLTF2.Material.NormalTextureInfo? = null, val occlusionTexture: GLTF2.Material.OcclusionTextureInfo? = null, val extensions: JsonElement? = null, val extras: JsonElement? = null) : GLTFProperty

The material appearance of a primitive.

https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/material.schema.json

Constructors

Link copied to clipboard
constructor(name: String? = null, alphaMode: String? = null, alphaCutoff: Float = 0.5f, doubleSided: Boolean = true, emissiveFactor: FloatArray? = null, emissiveTexture: GLTF2.Material.TextureInfo? = null, pbrMetallicRoughness: GLTF2.Material.PBRMetallicRoughness? = null, normalTexture: GLTF2.Material.NormalTextureInfo? = null, occlusionTexture: GLTF2.Material.OcclusionTextureInfo? = null, extensions: JsonElement? = null, extras: JsonElement? = null)

Types

Link copied to clipboard
@Serializable
data class NormalTextureInfo(var name: String? = null, val index: Int = -1, val texCoord: Int = -1, val scale: Float = 1.0f, val extensions: JsonElement? = null, val extras: JsonElement? = null) : GLTF2.Material.BaseTextureInfo
Link copied to clipboard
@Serializable
data class OcclusionTextureInfo(var name: String? = null, val index: Int = -1, val texCoord: Int = -1, val strength: Float = 1.0f, val extensions: JsonElement? = null, val extras: JsonElement? = null) : GLTF2.Material.BaseTextureInfo

https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/material.occlusionTextureInfo.schema.json

Link copied to clipboard
@Serializable
data class PBRMetallicRoughness(var name: String? = null, val baseColorFactor: FloatArray? = null, val baseColorTexture: GLTF2.Material.TextureInfo? = null, val metallicFactor: Float? = null, val roughnessFactor: Float? = null, val metallicRoughnessTexture: GLTF2.Material.TextureInfo? = null, val extensions: JsonElement? = null, val extras: JsonElement? = null) : GLTFProperty

A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology.

Link copied to clipboard
@Serializable
data class TextureInfo(var name: String? = null, val index: Int = -1, val texCoord: Int = -1, val extensions: JsonElement? = null, val extras: JsonElement? = null) : GLTF2.Material.BaseTextureInfo

Properties

Link copied to clipboard
val alphaCutoff: Float = 0.5f

Specifies the cutoff threshold when in MASK alpha mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than 1.0 will render the entire material as fully transparent. This value MUST be ignored for other alpha modes. When alphaMode is not defined, this value MUST NOT be defined.

Link copied to clipboard
val alphaMode: String? = null

OPAQUE: The alpha value is ignored, and the rendered output is fully opaque. MASK: The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alphaCutoff value; the exact appearance of the edges MAY be subject to implementation-specific techniques such as \"Alpha-to-Coverage\". BLEND: The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator).

Link copied to clipboard
val doubleSided: Boolean = true

Specifies whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double-sided lighting is enabled. The back-face MUST have its normals reversed before the lighting equation is evaluated.

Link copied to clipboard

The factors for the emissive color of the material. This value defines linear multipliers for the sampled texels of the emissive texture.

Link copied to clipboard

The emissive texture. It controls the color and intensity of the light being emitted by the material. This texture contains RGB components encoded with the sRGB transfer function. If a fourth component (A) is present, it MUST be ignored. When undefined, the texture MUST be sampled as having 1.0 in RGB components.

Link copied to clipboard
open override val extensions: JsonElement? = null

JSON object with extension-specific objects.

Link copied to clipboard
open override val extras: JsonElement? = null

Although extras MAY have any type, it is common for applications to store and access custom data as key/value pairs. Therefore, extras SHOULD be a JSON object rather than a primitive value for best portability.

Link copied to clipboard
open override var name: String?
Link copied to clipboard

The tangent space normal texture. The texture encodes RGB components with linear transfer function. Each texel represents the XYZ components of a normal vector in tangent space. The normal vectors use the convention +X is right and +Y is up. +Z points toward the viewer. If a fourth component (A) is present, it MUST be ignored. When undefined, the material does not have a tangent space normal texture.

Link copied to clipboard

The occlusion texture. The occlusion values are linearly sampled from the R channel. Higher values indicate areas that receive full indirect lighting and lower values indicate no indirect lighting. If other channels are present (GBA), they MUST be ignored for occlusion calculations. When undefined, the material does not have an occlusion texture.

Link copied to clipboard

A set of parameter values that are used to define the metallic-roughness material model from Physically Based Rendering (PBR) methodology. When undefined, all the default values of pbrMetallicRoughness MUST apply.