KhronosUnlitMaterial


class KhronosUnlitMaterial : Material


Represents an unlit material, which is not affected by scene lighting.

This material type is defined by a base color and supports a limited set of parameters. It is a direct implementation of the following glTF features:

Summary

Public companion functions

suspend KhronosUnlitMaterial
@MainThread
create(session: Session, alphaMode: Int)

Asynchronously creates a KhronosUnlitMaterial.

Public functions

open Unit

Closes the KhronosUnlitMaterial and releases its underlying graphics resources.

Unit
@MainThread
setAlphaCutoff(alphaCutoff: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the alpha cutoff threshold.

Unit

Sets a linear multiplier for the base color.

Unit

Sets the material's base color using a texture.

Public companion functions

create

@MainThread
suspend fun create(session: Session, alphaMode: Int): KhronosUnlitMaterial

Asynchronously creates a KhronosUnlitMaterial.

Parameters
session: Session

The active Session in which to create the material.

alphaMode: Int

The AlphaMode to use for the material.

Returns
KhronosUnlitMaterial

The newly created KhronosUnlitMaterial.

Public functions

close

@MainThread
open fun close(): Unit

Closes the KhronosUnlitMaterial and releases its underlying graphics resources.

After being closed, the KhronosUnlitMaterial should not be used further.

setAlphaCutoff

Added in 1.0.0-alpha08
@MainThread
fun setAlphaCutoff(alphaCutoff: @FloatRange(from = 0.0, to = 1.0) Float): Unit

Sets the alpha cutoff threshold.

This value is only used when the material's alphaMode is AlphaMode.ALPHA_MODE_MASK.

Parameters
alphaCutoff: @FloatRange(from = 0.0, to = 1.0) Float

The alpha cutoff. Fragments with alpha below this value are discarded. Default is 0.5. Valid values are between 0.0 and 1.0, inclusive.

Throws
kotlin.IllegalArgumentException

if the material's alphaMode is not ALPHA_MODE_MASK.

setBaseColorFactor

Added in 1.0.0-alpha08
@MainThread
fun setBaseColorFactor(factor: Vector4): Unit

Sets a linear multiplier for the base color.

By default this is 1, 1, 1, 1.

Parameters
factor: Vector4

The Vector4 (RGBA) factor multiplied component-wise with the base color texture.

setBaseColorTexture

Added in 1.0.0-alpha08
@MainThread
fun setBaseColorTexture(
    texture: Texture,
    sampler: TextureSampler = TextureSampler()
): Unit

Sets the material's base color using a texture.

By default this is a white texture, where all pixels are 1, 1, 1, 1. In other words, if this is left as default, the base color will always be the base color factor.

Parameters
texture: Texture

The Texture to be used as the base color texture, in sRGB color space.

sampler: TextureSampler = TextureSampler()

The TextureSampler to be used when sampling the base color texture.