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.

val tex = rememberTexture { Res.readBytes("files/textures/wood.png") }
tex?.let { Sphere(material = rememberTexturedMaterialInstance(it)) }

Parameters

texture

Base-colour texture bound to the albedo sampler.

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.