Back to Filament

IndirectLight

docs/android/dokka/filament-android/com.google.android.filament/-indirect-light/index.md

1.75.07.6 KB
Original Source

//filament-android/com.google.android.filament/IndirectLight

IndirectLight

open class IndirectLight

IndirectLight is used to simulate environment lighting, a form of global illumination.

Environment lighting has a two components:

  1. irradiance
  2. reflections (specular component)

Environments are usually captured as high-resolution HDR equirectangular images and processed by the cmgen tool to generate the data needed by IndirectLight.

Currently IndirectLight is intended to be used for "distant probes", that is, to represent global illumination from a distant (i.e. at infinity) environment, such as the sky or distant mountains. Only a single IndirectLight can be used in a Scene. This limitation will be lifted in the future.

Creation and destruction

An IndirectLight object is created using the IndirectLight.Builder and destroyed by calling destroyIndirectLight.

kotlin
 Engine engine = Engine.create();

 Scene scene = engine.createScene();

 IndirectLight environment = new IndirectLight.Builder()
             .reflections(cubemap)
             .irradiance(numBands, sphericalHarmonicsCoefficients)
             .build(engine);

 scene.setIndirectLight(environment);

Irradiance

The irradiance represents the light that comes from the environment and shines an object's surface. The irradiance is calculated automatically from the Reflections (see below), and generally doesn't need to be provided explicitly. However, it can be provided separately from the Reflections as Spherical Harmonics (SH) of 1, 2 or 3 bands, respectively 1, 4 or 9 coefficients.

Use the cmgen tool to generate the Spherical Harmonics for a given environment.

Reflections

The reflections on object surfaces (specular component) is calculated from a specially filtered cubemap pyramid generated by the cmgen tool.

See also

Scene
LightManager
Texture
Skybox

Constructors

IndirectLight[main]
constructor(indirectLight: Long)

Types

NameSummary
Builder[main]
open class Builder
Use Builder to construct an IndirectLight object instance.

Functions

NameSummary
getColorEstimate[main]
open fun getColorEstimate(colorIntensity: Array<Float>, x: Float, y: Float, z: Float): Array<Float>
[main]
open fun getColorEstimate(colorIntensity: Array<Float>, sh: Array<Float>, x: Float, y: Float, z: Float): Array<Float>
Helper to estimate the color and relative intensity of the environment in a given direction.
getDirectionEstimate[main]
open fun getDirectionEstimate(direction: Array<Float>): Array<Float>
[main]
open fun getDirectionEstimate(sh: Array<Float>, direction: Array<Float>): Array<Float>
Helper to estimate the direction of the dominant light in the environment.
getIntensity[main]
open fun getIntensity(): Float
Returns the environment's intensity in lux, or lumen/m^2.
getIrradianceTexture[main]
open fun getIrradianceTexture(): Texture
getNativeObject[main]
open fun getNativeObject(): Long
getReflectionsTexture[main]
open fun getReflectionsTexture(): Texture
getRotation[main]
open fun getRotation(rotation: Array<Float>): Array<Float>
Returns the rigid-body transformation applied to the IBL.
setIntensity[main]
open fun setIntensity(intensity: Float)
Sets the environment's intensity.
setRotation[main]
open fun setRotation(rotation: Array<Float>)
Sets the rigid-body transformation to apply to the IBL.