rememberHdrEnvironment

fun rememberHdrEnvironment(format: Texture.InternalFormat = Texture.InternalFormat.R11F_G11F_B10F, key: Any = Unit, onError: (Throwable) -> Unit? = null, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine(), 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's EquirectangularToCubemap and SpecularFilter.

rememberFilamentScene {
Environment(rememberHdrEnvironment { Res.readBytes("env/lobby.hdr") })
GltfInstance(asset = duck)
}

Tradeoff vs. rememberKtxEnvironment: there's no baked diffuse irradiance (cmgen's spherical harmonics). Filament approximates diffuse from the reflection's lowest mip — visibly lower quality. Prefer KTX when you can bake offline; use this for raw .hdr workflows. The prefilter runs on the GPU at load, so the first frames render before it lands.

Parameters

format

Internal format for the decoded HDR equirect texture.

key

Reloads when this changes. Defaults to Unit for static assets.

onError

Invoked once if hdr throws or the bytes can't be decoded as HDR.

engine

Engine the textures are allocated on. Defaults to the engine in the current composition scope, which only exists inside rememberFilamentScene { }.

hdr

Loader for the equirectangular HDR bytes (2:1 aspect).