Package-level declarations

Types

Link copied to clipboard
data class AmbientOcclusion(val radius: Float = 0.3f, val bias: Float = 0.01f, val intensity: Float = 1.0f, val quality: View.Quality = View.Quality.LOW)

Screen-space ambient occlusion (SSAO).

Link copied to clipboard

A weighted, auto-advancing blend of several glTF clips — a blend tree. Each AnimationTrack contributes its pose by AnimationTrack.weight; weights are normalized so they need not sum to 1.

Link copied to clipboard

Hoisted, observable playback state for a single glTF Animator, created with rememberAnimationState and passed to GltfInstance. It auto-advances on every frame and drives the animator each frame in one of two modes:

Link copied to clipboard

One weighted clip in an AnimationMixer, created with AnimationMixer.addTrack (or rememberAnimationTrack). Mutate weight to blend it in or out, index to swap the clip, or speed/loop for playback. The read-only time, progress and isFinished update every frame.

Link copied to clipboard
data class AntiAliasing(val msaaEnabled: Boolean = false, val msaaSampleCount: Int = 4, val fxaaEnabled: Boolean = true, val taaEnabled: Boolean = false)

Anti-aliasing: MSAA (hardware), FXAA (post-process), and TAA (temporal).

Link copied to clipboard
data class Bloom(val strength: Float = 0.1f, val thresholdEnabled: Boolean = true, val quality: View.Quality = View.Quality.LOW, val resolution: Int = 0, val levels: Int = 6)

Bloom — "glow" around bright areas.

Link copied to clipboard

Hoisted, observable camera state. Create with rememberCameraState and pass to io.github.erkko68.filament.compose.FilamentView for full control over the camera.

Link copied to clipboard
data class ColorGrade(val exposure: Float = 0.0f, val contrast: Float = 1.0f, val vibrance: Float = 1.0f, val saturation: Float = 1.0f, val whiteBalanceTemperature: Float = 0.0f, val whiteBalanceTint: Float = 0.0f, val toneMapping: ToneMapping = ToneMapping.ACES)

Color grading — exposure, white balance, contrast, tone mapping, etc.

Link copied to clipboard
data class DepthOfField(val cocScale: Float = 1.0f, val maxApertureDiameter: Float = 0.01f, val filter: View.DepthOfFieldOptions.Filter = View.DepthOfFieldOptions.Filter.MEDIAN, val nativeResolution: Boolean = false)

Depth-of-field (bokeh). The camera's focus distance and aperture control the focal plane.

Link copied to clipboard
data class Direction(val x: Float, val y: Float, val z: Float)

A direction / displacement vector in 3-D space. See Position for the rationale behind the distinct type and the Float3 interop story.

Link copied to clipboard
data class Dithering(val mode: View.Dithering = View.Dithering.TEMPORAL)

Dithering applied at tonemap time. View.Dithering.TEMPORAL (Filament's native default) hides 8-bit banding in dark gradients and bloom halos.

Link copied to clipboard
data class DynamicResolution(val minScale: Float = 0.5f, val maxScale: Float = 1.0f, val sharpness: Float = 0.9f, val quality: View.Quality = View.Quality.LOW, val homogeneousScaling: Boolean = false)

Dynamic resolution scaling — lowers internal resolution under GPU load and upscales.

Link copied to clipboard

A loaded image-based-lighting environment: the indirectLightState that lights the scene and an optional skyboxState background. Obtain via rememberKTXEnvironment (pre-baked KTX) or rememberHDREnvironment (raw .hdr) and feed the two states straight into io.github.erkko68.filament.compose.rememberFilamentScene:

Link copied to clipboard
data class Exposure(val aperture: Float = 16.0f, val shutterSpeed: Float = 1f / 125f, val sensitivity: Float = 100.0f)

Photographic exposure (aperture / shutter-speed / ISO triangle).

Link copied to clipboard
data class Fog(val distance: Float = 0.0f, val density: Float = 0.1f, val height: Float = 0.0f, val heightFalloff: Float = 1.0f, val color: LinearColor = LinearColor(0f, 0f, 0f))

Height-based and volumetric fog.

Link copied to clipboard

A loaded glTF asset whose GPU resources are ready. Obtain via rememberGltfAsset.

Link copied to clipboard

Scope for interacting with a specific glTF instance via low-level Filament APIs.

Link copied to clipboard

Hoisted, observable Image-Based Lighting (IBL) state. Pass to io.github.erkko68.filament.compose.rememberFilamentScene via indirectLightState = ....

Link copied to clipboard
data class LensScaling(val x: Float, val y: Float)

Projection scaling — multiplies the projection along each axis. 2 on one axis zooms that axis in; unequal values give an anamorphic squeeze.

Link copied to clipboard
data class LensShift(val x: Float, val y: Float)

Lens shift — moves the projection off-axis without rotating the camera, in units of half the viewport (1 shifts by a full half-width/height). Used for tilt-shift looks, and for keeping verticals parallel in architectural shots.

Link copied to clipboard
sealed interface LightIntensity

A light's brightness as a value type, bundling the amount with how it's interpreted — one variant per intensity setter on the core LightManager.Builder, so unit-specific extras (Watts' efficiency) are unrepresentable with the other units.

Link copied to clipboard
data class LinearColor(val r: Float, val g: Float, val b: Float)

An RGB color (linear or sRGB depending on the consuming API). Distinct from the spatial vectors so a LinearColor can't be passed as a Position. Components are r/g/b.

Link copied to clipboard
data class Position(val x: Float, val y: Float, val z: Float)

A point in 3-D space.

Link copied to clipboard
data class PostProcessing(val enabled: Boolean = true, val bloom: Bloom? = null, val vignette: Vignette? = null, val fog: Fog? = null, val ambientOcclusion: AmbientOcclusion? = null, val antiAliasing: AntiAliasing? = null, val screenSpaceReflections: ScreenSpaceReflections? = null, val colorGrade: ColorGrade? = null, val depthOfField: DepthOfField? = null, val dynamicResolution: DynamicResolution? = null, val dithering: Dithering? = null, val renderQuality: RenderQuality? = null)

Per-view visual configuration: post-processing effects plus render-quality options. Pass to io.github.erkko68.filament.compose.FilamentView via postProcessing = ....

Link copied to clipboard
sealed class Projection

Camera projection. Pass an instance as the Camera.projection argument.

Link copied to clipboard
data class RenderQuality(val hdrColorBuffer: View.Quality = View.Quality.HIGH)

Precision of the view's HDR color buffer. View.Quality.HIGH (the native default) is RGBA16F where supported — needed for emissive values above 1.0 to survive into bloom.

Link copied to clipboard
data class Rotation(val x: Float, val y: Float, val z: Float, val w: Float)

A 3-D rotation, stored as a unit quaternion. See Position for the rationale behind the distinct type — the same one applies doubly here, since filament-utils' Quaternion has mutable components and so is an unstable Compose input.

Link copied to clipboard
data class Scale(val x: Float, val y: Float, val z: Float)

A per-axis scale factor. See Position for the rationale behind the distinct type.

Link copied to clipboard
data class ScreenSpaceReflections(val thickness: Float = 0.1f, val bias: Float = 0.01f, val maxDistance: Float = 3.0f)

Screen-space reflections (SSR).

Link copied to clipboard
data class ShadowConfig(val mapSize: Int = 1024, val constantBias: Float = 0.001f, val normalBias: Float = 1.0f, val shadowFar: Float = 0.0f, val shadowNearHint: Float = 1.0f, val shadowFarHint: Float = 100.0f, val stable: Boolean = false, val lispsm: Boolean = false, val cascades: Int = 1, val cascadeSplits: List<Float>? = null, val contactShadows: Boolean = false, val contactShadowDistance: Float = 0.3f, val contactShadowSteps: Int = 8, val bulbRadius: Float = 0.02f, val blurWidth: Float = 0.0f, val elvsm: Boolean = false, val transform: Rotation? = null)

Per-light shadow-map quality, mapping onto the core LightManager.ShadowOptions. Pass a non-null shadow to a DirectionalLight/SunLight/SpotLight/FocusedSpotLight to make it cast shadows; null disables them. (Point lights cannot cast shadows.)

Link copied to clipboard
sealed interface Shadows

View-wide shadow technique, passed to a view via FilamentView(shadows = …) (or FilamentSceneView(shadows = …)). Each subtype is one of Filament's shadow algorithms and carries only the tuning that algorithm actually uses — so there are no silently-ignored fields. Passing null for the view's shadows disables shadowing entirely. See ShadowConfig for the per-light counterpart that sets each caster's map quality.

Link copied to clipboard
sealed class SkyboxSource

Source for a SkyboxState: either a solid color or a cubemap texture.

Link copied to clipboard

Hoisted, observable skybox state. Pass to io.github.erkko68.filament.compose.rememberFilamentScene via skyboxState = .... A null source removes the skybox entirely.

Link copied to clipboard
data class SphericalHarmonics(val bands: Int, val coefficients: FloatArray)

Spherical harmonics coefficients for diffuse irradiance.

Link copied to clipboard
data class SpotCone(val innerAngle: Float = 0.5f, val outerAngle: Float = 0.6f)

Spot / focused-spot cone angles (half-angles in radians). innerAngle must be ≤ outerAngle.

Link copied to clipboard

The built-in materials shipped with filament-compose — precompiled .filamat blobs embedded in the library, so the common "colour a primitive" case needs no .mat authoring, no matc, and no asset shipping on any target (including Web, where runtime material compilation isn't available).

Link copied to clipboard
data class SunParams(val angularRadius: Float = 1.9f, val haloSize: Float = 10.0f, val haloFalloff: Float = 80.0f)

Sun-disk appearance parameters for SunLight.

Link copied to clipboard
sealed interface ToneMapping

Tone mapping operator selection for ColorGrade, as a value: every variant compares structurally, so two ColorGrades built with the same settings are equal and don't force a ColorGrading rebuild (the native ToneMapper instances have identity equality, which would re-bake the grading LUT on every recomposition). The native operator is constructed only when the configuration is actually applied.

Link copied to clipboard
data class Vignette(val midPoint: Float = 0.5f, val roundness: Float = 0.5f, val feather: Float = 0.5f, val color: LinearColor = LinearColor(0f, 0f, 0f))

Vignette — darkens the corners of the viewport.

Functions

Link copied to clipboard
fun FilamentSceneScope.CameraNode(cameraState: CameraState, eyeOffset: Position = Position(0f), targetOffset: Position = Position(0f, 0f, -1f), up: Direction = Direction(0f, 1f, 0f))

Attaches a CameraState to the surrounding Group so the camera follows that group's world transform every frame — a declarative chase / first-person / mounted camera.

Link copied to clipboard
fun FilamentSceneScope.DirectionalLight(direction: Direction = Direction(0.3f, -1f, -0.5f), color: LinearColor = LinearColor(1f, 1f, 1f), intensity: LightIntensity = LightIntensity.LuminousPower(100_000f), shadow: ShadowConfig? = null, castLight: Boolean = true, lightChannels: Set<Int> = setOf(0), followGroupRotation: Boolean = true)

A directional light — parallel rays from infinitely far (the classic "sun" for shading, without the visible disk; use SunLight for that). Only directional and spot lights can cast shadows.

Link copied to clipboard
fun FilamentSceneScope.FocusedSpotLight(position: Position = Position(0f, 2f, 0f), direction: Direction = Direction(0f, -1f, 0f), color: LinearColor = LinearColor(1f, 1f, 1f), intensity: LightIntensity = LightIntensity.LuminousPower(100_000f), falloff: Float = 10.0f, cone: SpotCone = SpotCone(), shadow: ShadowConfig? = null, castLight: Boolean = true, lightChannels: Set<Int> = setOf(0), followGroupRotation: Boolean = true)

A physically-correct spot light (LightManager.Type.FOCUSED_SPOT) — like SpotLight, but the outer cone angle affects total illumination (narrowing the cone concentrates the light). Can cast shadows. Parameters match SpotLight.

Link copied to clipboard
fun FilamentSceneScope.GltfInstance(asset: GltfAsset?, position: Position = Position(0f), rotation: Rotation = Rotation.Identity, scale: Scale = Scale(1f), pivot: Position = Position(0f), animationIndex: Int? = null, animationTime: Float = 0.0f, animationState: AnimationState? = null, morphWeights: FloatArray? = null, castShadows: Boolean? = null, receiveShadows: Boolean? = null, visible: Boolean = true, onCreate: GltfInstanceScope.() -> Unit = {}, onUpdate: GltfInstanceScope.() -> Unit = {})

Places one copy of a GltfAsset in the scene.

Link copied to clipboard
fun FilamentSceneScope.Group(position: Position = Position(0f), rotation: Rotation = Rotation.Identity, scale: Scale = Scale(1f), pivot: Position = Position(0f), visible: Boolean = true, onCreate: EntityScope.() -> Unit = {}, content: @Composable FilamentSceneScope.() -> Unit)

Groups child scene composables under a single transform. Everything declared inside content is parented to a hidden transform entity, so moving/rotating/scaling the Group moves the whole assembly as a unit. Children's own position/rotation/scale become local to the group, and groups themselves nest cleanly inside other groups.

Link copied to clipboard

Low-level escape hatch: adds a light configured directly through the raw LightManager.Builder, for cases the typed composables (DirectionalLight, SpotLight, …) don't cover. You own the full builder; this composable only manages the entity, scene membership, and (when inside a Group) the transform so the light follows the group.

Link copied to clipboard
fun FilamentSceneScope.PointLight(position: Position = Position(0f, 2f, 0f), color: LinearColor = LinearColor(1f, 1f, 1f), intensity: LightIntensity = LightIntensity.LuminousPower(100_000f), falloff: Float = 10.0f, castLight: Boolean = true, lightChannels: Set<Int> = setOf(0))

A point light — emits from position in all directions, intensity diminishing with the inverse square law out to falloff.

Link copied to clipboard

Creates and remembers a standalone AnimationMixer for imperative use — drive it from an OnFrame callback with the instance's Animator, mutating track weights from your own animation logic. Prefer AnimationState + rememberAnimationTrack for the declarative path.

Link copied to clipboard

The clip names of asset, indexed by animation index, or empty until the asset is ready. Look up an index by name — names.indexOf("Walk") — instead of hard-coding integers. Entries are null for unnamed clips.

Link copied to clipboard
fun rememberAnimationState(initialAnimationIndex: Int? = 0, initialSpeed: Float = 1.0f, initialCrossFadeDuration: Float = 0.3f, initialLoop: Boolean = true): AnimationState

Creates and remembers an AnimationState. The initial* values seed the state on first composition only; afterwards mutate the returned object's fields to drive playback.

Link copied to clipboard
fun rememberAnimationTrack(state: AnimationState, index: Int, weight: Float = 1.0f, speed: Float = 1.0f, loop: Boolean = true): AnimationTrack

Adds a weighted track to state's AnimationState.mixer for as long as this call stays in composition, and keeps its weight/index/speed/loop in sync with the arguments. The track is created once and removed automatically when the call leaves composition, so build a blend tree by calling this once per clip and driving weight from your own state. Its clock keeps running across index/weight changes; call AnimationTrack.seek to rewind.

Link copied to clipboard
fun rememberCameraState(initialEye: Position = Position(0f, 1f, 10f), initialTarget: Position = Position(0f, 0f, 0f), initialUp: Direction = Direction(0f, 1f, 0f), initialProjection: Projection = Projection.Perspective(), initialExposure: Exposure = Exposure(), initialFocusDistance: Float = 10.0f, initialShift: LensShift = LensShift.None, initialScaling: LensScaling = LensScaling.Identity): CameraState

Creates and remembers a CameraState.

Link copied to clipboard
fun rememberColorMaterialInstance(color: LinearColor, metallic: Float = 0.0f, roughness: Float = 0.5f, reflectance: Float = 0.5f, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine()): MaterialInstance

A LIT PBR MaterialInstance tinted color, updated in place as the inputs change. Drop it straight into a primitive:

Link copied to clipboard
fun rememberEmissiveMaterialInstance(color: LinearColor, intensity: Float = 1.0f, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine()): MaterialInstance

An UNLIT emissive MaterialInstance that glows: color tint scaled by intensity. Intensity above ~1 pushes past the bloom threshold and produces a halo (enable Bloom on the view).

Link copied to clipboard
fun rememberGltfAsset(key: Any = Unit, onError: (Throwable) -> Unit? = null, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine(), load: suspend () -> ByteArray): GltfAsset?

Asynchronously loads a glTF/glb asset and keeps it alive as long as the calling composable is in the composition.

Link copied to clipboard
fun rememberHDREnvironment(engine: Engine, initialIntensity: Float, showSkybox: Boolean = true, format: Texture.InternalFormat = Texture.InternalFormat.R11F_G11F_B10F, key: Any = Unit, onError: (Throwable) -> Unit? = null, hdr: suspend () -> ByteArray): Environment

Builds an Environment from an equirectangular HDR image instead of pre-baked KTX — no cmgen step, just ship the .hdr. The reflection cubemap and skybox are prefiltered on the GPU at load via IBLPrefilterContext/EquirectangularToCubemap/SpecularFilter.

Link copied to clipboard
fun rememberIndirectLightState(initialReflections: Texture? = null, initialIrradianceCubemap: Texture? = null, initialIrradianceSh: SphericalHarmonics? = null, initialIntensity: Float, initialRotation: Rotation? = null): IndirectLightState

Creates and remembers an IndirectLightState. The initial* values seed the state on first composition only; mutate the returned state's fields to change the IBL afterwards.

Link copied to clipboard
fun rememberKTXEnvironment(engine: Engine, initialIntensity: Float, key: Any = Unit, onError: (Throwable) -> Unit? = null, skybox: suspend () -> ByteArray? = null, ibl: suspend () -> ByteArray): Environment

Loads an IBL environment (and optional skybox) from KTX1 data and wires it into the scene's indirect-light/skybox state. This is the convenience path over hand-wiring KTX1Loader, texture lifetimes, and IndirectLightState/SkyboxState.

Link copied to clipboard
fun rememberMaterial(key: Any = Unit, onError: (Throwable) -> Unit? = null, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine(), load: suspend () -> ByteArray): Material?

Asynchronously loads a Filament Material and keeps it alive as long as the calling composable is in the composition. Returns null while loading and on failure — it never throws inside composition. Pass onError to react when load throws (missing file, network error).

Link copied to clipboard
fun rememberMaterialInstance(material: Material?, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine()): MaterialInstance?

Creates and manages a MaterialInstance from a Material. The instance is destroyed when this leaves the composition.

fun rememberMaterialInstance(material: Material?, vararg keys: Any?, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine(), configure: MaterialInstance.() -> Unit): MaterialInstance?

Creates a MaterialInstance and (re-)applies configure declaratively — the imperative createInstance() + setParameter(...) + dispose dance done for you. The instance is built once per material; configure runs once on creation and again whenever any value in keys changes, so parameters track Compose state without an onUpdate/SideEffect. The instance is destroyed when this leaves the composition.

Link copied to clipboard
fun rememberSkyboxState(initialSource: SkyboxSource? = null, initialShowSun: Boolean = false, initialIntensity: Float = 1.0f, initialPriority: Int = 0): SkyboxState

Creates and remembers a SkyboxState. The initial* values seed the state on first composition only; mutate the returned state's fields to change the skybox afterwards.

Link copied to clipboard
fun rememberStandardMaterial(type: StandardMaterial, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine()): Material

The shared base Material for a StandardMaterial, built on engine and kept alive for the lifetime of the enclosing rememberFilamentScene (one per engine + type, reused across call sites). Outside a scene — when engine is hoisted via rememberFilamentEngine — it builds a material owned by this call site and destroyed when it leaves the composition.

Link copied to clipboard
fun rememberTexture(type: TextureLoader.TextureType = TextureLoader.TextureType.COLOR, key: Any = Unit, onError: (Throwable) -> Unit? = null, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine(), load: suspend () -> ByteArray): Texture?

Asynchronously loads and manages a Filament Texture. Returns null while loading and on failure — it never throws inside composition. Pass onError to react when load throws (missing file, network error) or the bytes can't be decoded on this platform. See rememberMaterial for the engine-hoisting pattern when calling outside rememberFilamentScene { }.

Link copied to clipboard
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.

Link copied to clipboard
fun rememberTransparentColorMaterialInstance(color: LinearColor, alpha: Float = 0.5f, metallic: Float = 0.0f, roughness: Float = 0.5f, reflectance: Float = 0.5f, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine()): MaterialInstance

A LIT PBR MaterialInstance tinted color with alpha transparency — the "make this object semi-transparent" case with no .mat authoring. Alpha is pre-multiplied by the shader and the material renders in two depth passes so convex primitives composite correctly with themselves.

Link copied to clipboard
fun rememberUnlitColorMaterialInstance(color: LinearColor, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine()): MaterialInstance

An UNLIT solid-colour MaterialInstance — a flat color unaffected by scene lighting (HUD markers, wireframe-style fills, unlit gizmos).

Link copied to clipboard

Sets a float3 parameter from a LinearColor, keeping call sites typed against the colour value class.

Link copied to clipboard
fun FilamentSceneScope.SpotLight(position: Position = Position(0f, 2f, 0f), direction: Direction = Direction(0f, -1f, 0f), color: LinearColor = LinearColor(1f, 1f, 1f), intensity: LightIntensity = LightIntensity.LuminousPower(100_000f), falloff: Float = 10.0f, cone: SpotCone = SpotCone(), shadow: ShadowConfig? = null, castLight: Boolean = true, lightChannels: Set<Int> = setOf(0), followGroupRotation: Boolean = true)

A spot light — emits from position along direction within a cone, decoupling the outer cone from total illumination (easier to tweak than FocusedSpotLight). Can cast shadows.

Link copied to clipboard
fun FilamentSceneScope.SunLight(direction: Direction = Direction(0.3f, -1f, -0.5f), color: LinearColor = LinearColor(1f, 1f, 1f), intensity: LightIntensity = LightIntensity.LuminousPower(100_000f), sun: SunParams = SunParams(), shadow: ShadowConfig? = null, castLight: Boolean = true, lightChannels: Set<Int> = setOf(0), followGroupRotation: Boolean = true)

A directional light that also draws a sun disk and halo in the sky (LightManager.Type.SUN). Same shading as DirectionalLight plus the visible disk configured by sun.

Link copied to clipboard

Reinterpret a Float3 as a Direction.

Link copied to clipboard

Convert a Compose UI androidx.compose.ui.graphics.Color to a scene-ready LinearColor, applying the sRGB→linear transfer. Alpha is dropped. Covers ARGB ints too, via Compose's own Color(0xFF2196F3) constructor.

Reinterpret a Float3 as a LinearColor (x→r, y→g, z→b).

Link copied to clipboard

Reinterpret a Float3 as a Position.

Link copied to clipboard
Link copied to clipboard

Reinterpret a Float3 as a Scale.