KhronosPbrMaterial
public final class KhronosPbrMaterial implements Material
Represents a lit PBR (Physically-Based Rendering) material, which defines the visual appearance of a surface by simulating its interaction with light.
This material implements the Khronos PBR (Physically-Based Rendering) metallic-roughness model. It is a direct implementation of the following glTF features:
-
Core glTF 2.0 Material (pbrMetallicRoughness, normalTexture, occlusionTexture, emissiveTexture)
Summary
Public methods |
|
|---|---|
void |
Closes the |
static final @NonNull KhronosPbrMaterial |
Asynchronously creates a |
final void |
@MainThreadSets the alpha cutoff threshold. |
final void |
@MainThreadSets a linear multiplier for the base color. |
final void |
@MainThreadSets the material's base color using a texture. |
final void |
@MainThreadSets a scalar multiplier for the clearcoat layer's intensity. |
final void |
@MainThreadSets the normal map texture for the clearcoat layer. |
final void |
@MainThreadSets a scalar multiplier for the clearcoat layer's roughness. |
final void |
@MainThreadSets the clearcoat roughness texture. |
final void |
@MainThreadSets the clearcoat intensity texture. |
final void |
@MainThreadSets a linear multiplier for the emissive color. |
final void |
@MainThreadSets the emissive texture, defining light emitted by the material. |
final void |
@MainThreadSets a scalar multiplier for the material's metallic property. |
final void |
@MainThreadSets a texture defining metallic and roughness properties. |
final void |
@MainThreadSets the normal map texture for surface detail. |
final void |
@MainThreadSets the ambient occlusion texture. |
final void |
@MainThreadSets a scalar multiplier for the material's roughness. |
final void |
@MainThreadSets a linear multiplier for the sheen color. |
final void |
@MainThreadSets the sheen color texture, for materials like fabric. |
final void |
@MainThreadSets a scalar multiplier for the sheen layer's roughness. |
final void |
@MainThreadSets the sheen roughness texture. |
Public methods
close
@MainThread
public void close()
Closes the KhronosPbrMaterial and releases its underlying graphics resources.
After being closed, the KhronosPbrMaterial should not be used further.
create
@MainThread
public static final @NonNull KhronosPbrMaterial create(@NonNull Session session, @NonNull AlphaMode alphaMode)
Asynchronously creates a KhronosPbrMaterial.
| Parameters | |
|---|---|
@NonNull Session session |
The active |
@NonNull AlphaMode alphaMode |
The |
| Returns | |
|---|---|
@NonNull KhronosPbrMaterial |
The newly created |
setAlphaCutoff
@MainThread
public final void setAlphaCutoff(@FloatRange(from = 0.0, to = 1.0) float alphaCutoff)
Sets the alpha cutoff threshold.
This value is only used when the material's alphaMode is AlphaMode.MASK.
| Parameters | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) float alphaCutoff |
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
@MainThread
public final void setBaseColorFactor(@NonNull Vector4 factor)
Sets a linear multiplier for the base color.
By default this is 1, 1, 1, 1.
setBaseColorTexture
@MainThread
public final void setBaseColorTexture(
@NonNull Texture texture,
@NonNull TextureSampler sampler
)
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 | |
|---|---|
@NonNull Texture texture |
The |
@NonNull TextureSampler sampler |
The |
setClearcoatFactor
@MainThread
public final void setClearcoatFactor(@FloatRange(from = 0.0, to = 1.0) float factor)
Sets a scalar multiplier for the clearcoat layer's intensity.
Other methods for controlling the clearcoat layer include:
| Parameters | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) float factor |
The clearcoat intensity factor. Default is 0.0. Valid values are between 0.0 and 1.0, inclusive. |
setClearcoatNormalTexture
@MainThread
public final void setClearcoatNormalTexture(
@NonNull Texture texture,
@FloatRange(from = 0.0) float scale,
@NonNull TextureSampler sampler
)
Sets the normal map texture for the clearcoat layer.
By default the texture is unset, in which case no normal mapping is done for the clearcoat, even if the base color has normal mapping.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@FloatRange(from = 0.0) float scale |
A scalar multiplier controlling the strength of the clearcoat normal. Default is 1.0. |
@NonNull TextureSampler sampler |
The |
setClearcoatRoughnessFactor
@MainThread
public final void setClearcoatRoughnessFactor(@FloatRange(from = 0.0, to = 1.0) float factor)
Sets a scalar multiplier for the clearcoat layer's roughness.
| Parameters | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) float factor |
The clearcoat roughness factor. Default is 0.0. Valid values are between 0.0 and 1.0, inclusive. |
setClearcoatRoughnessTexture
@MainThread
public final void setClearcoatRoughnessTexture(
@NonNull Texture texture,
@NonNull TextureSampler sampler
)
Sets the clearcoat roughness 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 clearcoat roughness values will always come from the clearcoat roughness factor.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@NonNull TextureSampler sampler |
The |
setClearcoatTexture
@MainThread
public final void setClearcoatTexture(
@NonNull Texture texture,
@NonNull TextureSampler sampler
)
Sets the clearcoat intensity 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 clearcoat intensity values will always come from the clearcoat factor.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@NonNull TextureSampler sampler |
The |
setEmissiveFactor
@MainThread
public final void setEmissiveFactor(@NonNull Vector3 factor)
Sets a linear multiplier for the emissive color.
By default this is 0, 0, 0.
setEmissiveTexture
@MainThread
public final void setEmissiveTexture(
@NonNull Texture texture,
@NonNull TextureSampler sampler
)
Sets the emissive texture, defining light emitted by the material.
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 emissive values will always come from the emissive factor.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@NonNull TextureSampler sampler |
The |
setMetallicFactor
@MainThread
public final void setMetallicFactor(@FloatRange(from = 0.0, to = 1.0) float factor)
Sets a scalar multiplier for the material's metallic property.
| Parameters | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) float factor |
The metallic factor. Default is 1.0. Valid values are between 0.0 and 1.0, inclusive. |
setMetallicRoughnessTexture
@MainThread
public final void setMetallicRoughnessTexture(
@NonNull Texture texture,
@NonNull TextureSampler sampler
)
Sets a texture defining metallic and roughness properties.
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 metalic and roughness values will always come from the corresponding factors.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@NonNull TextureSampler sampler |
The |
setNormalTexture
@MainThread
public final void setNormalTexture(
@NonNull Texture texture,
@FloatRange(from = 0.0) float scale,
@NonNull TextureSampler sampler
)
Sets the normal map texture for surface detail.
By default the texture is unset, in which case no normal mapping is done.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@FloatRange(from = 0.0) float scale |
A scalar multiplier controlling the strength of the normal map. Default is 1.0. |
@NonNull TextureSampler sampler |
The |
setOcclusionTexture
@MainThread
public final void setOcclusionTexture(
@NonNull Texture texture,
@FloatRange(from = 0.0, to = 1.0) float strength,
@NonNull TextureSampler sampler
)
Sets the ambient occlusion texture.
By default this is unset, in which case there is no ambient occlusion.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@FloatRange(from = 0.0, to = 1.0) float strength |
A scalar multiplier controlling the strength of the occlusion. Default is 1.0. Valid values are between 0.0 and 1.0, inclusive. |
@NonNull TextureSampler sampler |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if strength is outside of the range 0-1, inclusive. |
setRoughnessFactor
@MainThread
public final void setRoughnessFactor(@FloatRange(from = 0.0, to = 1.0) float factor)
Sets a scalar multiplier for the material's roughness.
| Parameters | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) float factor |
The roughness factor. Default is 1.0. Valid values are between 0.0 and 1.0, inclusive. |
setSheenColorFactor
@MainThread
public final void setSheenColorFactor(@NonNull Vector3 factor)
Sets a linear multiplier for the sheen color.
By default this is 0, 0, 0.
setSheenColorTexture
@MainThread
public final void setSheenColorTexture(
@NonNull Texture texture,
@NonNull TextureSampler sampler
)
Sets the sheen color texture, for materials like fabric.
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 sheen color values will always come from the sheen color factor.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@NonNull TextureSampler sampler |
The |
setSheenRoughnessFactor
@MainThread
public final void setSheenRoughnessFactor(@FloatRange(from = 0.0, to = 1.0) float factor)
Sets a scalar multiplier for the sheen layer's roughness.
| Parameters | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) float factor |
The sheen roughness factor. Default is 0.0. Valid values are between 0.0 and 1.0, inclusive. |
setSheenRoughnessTexture
@MainThread
public final void setSheenRoughnessTexture(
@NonNull Texture texture,
@NonNull TextureSampler sampler
)
Sets the sheen roughness 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 sheen roughness values will always come from the sheen roughness factor.
| Parameters | |
|---|---|
@NonNull Texture texture |
The |
@NonNull TextureSampler sampler |
The |