rememberTexturedMaterialInstance
fun rememberTexturedMaterialInstance(texture: Texture?, metallic: Float = 0.0f, roughness: Float = 0.5f, sampler: TextureSampler = TextureSampler(
TextureSampler.MinFilter.LINEAR_MIPMAP_LINEAR,
TextureSampler.MagFilter.LINEAR,
TextureSampler.WrapMode.REPEAT,
), engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine()): MaterialInstance?
A LIT MaterialInstance whose base colour is sampled from texture. Pair with a primitive (all built-ins supply uv0) or a io.github.erkko68.filament.compose.scene.primitives.Mesh with UVs. Returns null while texture is null, so it chains straight off rememberTexture:
Sphere(material = rememberTexturedMaterialInstance(rememberTexture { Res.readBytes("files/textures/wood.png") }))Content copied to clipboard
Parameters
texture
Base-colour texture bound to the albedo sampler, or null while it is still loading.
metallic
0 = dielectric, 1 = metal.
roughness
0 = mirror, 1 = fully rough.
sampler
How the texture is filtered and wrapped. Defaults to trilinear + repeat.
engine
Engine that owns the material. Defaults to the current composition scope's engine.