EnvironmentMap class base Lighting and environment

A source of image-based lighting: diffuse irradiance plus prefiltered specular radiance, both derived from an equirectangular environment.

Diffuse is stored as 9 L2 spherical-harmonic RGB coefficients (cheap, no texture fetch, seam-free); specular is a GPU-prefiltered "PMREM" roughness-band atlas (see prefilterEquirectRadiance). Both are computed up front, so constructing an environment from images does GPU work and is best done once.

Construct one with EnvironmentMap.fromAssets / EnvironmentMap.fromUIImages (which compute the SH and prefilter the radiance for you), EnvironmentMap.studio (the built-in procedural default), EnvironmentMap.fromGpuTextures when you already hold a prefiltered atlas, or EnvironmentMap.empty for a no-op black environment.

Set one on a Scene via Scene.environment (it defaults to EnvironmentMap.studio); an individual PhysicallyBasedMaterial can override it via PhysicallyBasedMaterial.environment.

Constructors

EnvironmentMap.empty()
A black environment that contributes no image-based lighting.
factory
EnvironmentMap.fromGpuTextures({required Texture prefilteredRadiance, List<Vector3>? diffuseSphericalHarmonics, Texture? diffuseShTexture})
Wraps an already-built prefiltered radiance texture.
factory

Properties

diffuseShTexture Texture
The diffuse SH coefficients as a kDiffuseShCoefficientCount-by-1 r16g16b16a16Float texture (coefficient i at texel i, RGB used).
no setter
diffuseSphericalHarmonics List<Vector3>
The kDiffuseShCoefficientCount RGB L2 spherical-harmonic coefficients describing the diffuse (Lambertian) irradiance.
no setter
hashCode int
The hash code for this object.
no setterinherited
prefilteredRadianceTexture Texture
The prefiltered radiance texture sampled for specular IBL.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
usesMipRadianceLayout bool
Whether prefilteredRadianceTexture stores its roughness bands as mip levels (see useMipRadianceLayout).
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

mipRadianceLayoutSupported bool
Whether the active Flutter GPU backend can build and sample the mip radiance layout: rendering into non-zero mip levels plus sampling hand-written mip chains.
no setter
useMipRadianceLayout bool
Whether newly built environments store their prefiltered roughness bands as mip levels of one equirect (sampled with hardware trilinear textureLod) rather than the legacy vertically stacked band atlas. Defaults to true, and applies only where the backend supports the layout (see mipRadianceLayoutSupported).
getter/setter pair

Static Methods

computeDiffuseSphericalHarmonics(Image equirectangular) Future<List<Vector3>>
Projects an equirectangular radiance image onto 9 L2 spherical- harmonic coefficients suitable for diffuse irradiance.
fromAssets({required String radianceImagePath, List<Vector3>? diffuseSphericalHarmonics}) Future<EnvironmentMap>
Loads an EnvironmentMap from an equirectangular sRGB radiance image in the asset bundle (see fromUIImages).
fromEquirectHdr({required Float32List linearPixels, required int width, required int height, List<Vector3>? diffuseSphericalHarmonics}) Future<EnvironmentMap>
Builds an EnvironmentMap from a high-dynamic-range equirectangular radiance map: linear (not sRGB) RGBA float pixels, row-major, width by height. Row 0 is the top of the image (the up pole), the standard equirectangular convention.
fromSky(SkySource source, {int faceResolution = 128, int equirectWidth = 512}) EnvironmentMap
Bakes a sky into an environment for image-based lighting.
fromUIImages({required Image radianceImage, List<Vector3>? diffuseSphericalHarmonics}) Future<EnvironmentMap>
Builds an EnvironmentMap from an already-decoded equirectangular dart:ui radiance image: uploads it, GPU-prefilters it for roughness-aware specular, and projects it onto diffuse SH.
studio() EnvironmentMap
Builds the package's built-in procedural "studio" environment.