docs/android/dokka/filament-android/com.google.android.filament/-light-manager/index.md
//filament-android/com.google.android.filament/LightManager
[main]
open class LightManager
LightManager allows you to create a light source in the scene, such as a sun or street lights.
At least one light must be added to a scene in order to see anything (unless the UNLIT is used).
A Light component is created using the LightManager.Builder and destroyed by calling destroy.
Engine engine = Engine.create();
int sun = EntityManager.get().create();
LightManager.Builder(Type.SUN)
.castShadows(true)
.build(engine, sun);
engine.getLightManager().destroy(sun);
Lights come in three flavors:
Directional lights have a direction, but don't have a position. All light rays are parallel and come from infinitely far away and from everywhere. Typically a directional light is used to simulate the sun.
Directional lights and spot lights are able to cast shadows.
To create a directional light use DIRECTIONAL or SUN, both are similar, but the later also draws a sun's disk in the sky and its reflection on glossy objects.
warning: Currently, only a single directional light is supported. If several directional lights are added to the scene, the dominant one will be used.
Unlike directional lights, point lights have a position but emit light in all directions. The intensity of the light diminishes with the inverse square of the distance to the light. falloff controls the distance beyond which the light has no more influence.
A scene can have multiple point lights.
Spot lights are similar to point lights but the light they emit is limited to a cone defined by spotLightCone and the light's direction.
A spot light is therefore defined by a position, a direction and inner and outer cones. The spot light's influence is limited to inside the outer cone. The inner cone defines the light's falloff attenuation.
A physically correct spot light is a little difficult to use because changing the outer angle of the cone changes the illumination levels, as the same amount of light is spread over a changing volume. The coupling of illumination and the outer cone means that an artist cannot tweak the influence cone of a spot light without also changing the perceived illumination. It therefore makes sense to provide artists with a parameter to disable this coupling. This is the difference between FOCUSED_SPOT (physically correct) and SPOT (decoupled).
Generally, adding lights to the scene hurts performance, however filament is designed to be able to handle hundreds of lights in a scene under certain conditions. Here are some tips to keep good performance.
| Name | Summary |
|---|---|
| Builder | [main] |
| open class Builder | |
| Use Builder to construct a Light object instance | |
| ShadowCascades | [main] |
| open class ShadowCascades | |
| ShadowOptions | [main] |
| open class ShadowOptions | |
| Control the quality / performance of the shadow map associated to this light | |
| Type | [main] |
| enum Type | |
| Denotes the type of the light being created. |
| Name | Summary |
|---|---|
| EFFICIENCY_FLUORESCENT | [main] |
| val EFFICIENCY_FLUORESCENT: Float = 0.0878f | |
| Typical efficiency of a fluorescent light bulb (8. | |
| EFFICIENCY_HALOGEN | [main] |
| val EFFICIENCY_HALOGEN: Float = 0.0707f | |
| Typical efficiency of an halogen light bulb (7. | |
| EFFICIENCY_INCANDESCENT | [main] |
| val EFFICIENCY_INCANDESCENT: Float = 0.022f | |
| Typical efficiency of an incandescent light bulb (2. | |
| EFFICIENCY_LED | [main] |
| val EFFICIENCY_LED: Float = 0.1171f | |
| Typical efficiency of a LED light bulb (11. |
| Name | Summary |
|---|---|
| destroy | [main] |
| open fun destroy(entity: Int) | |
| Destroys this component from the given entity | |
| getColor | [main] |
| open fun getColor(i: Int, out: Array<Float>): Array<Float> | |
| Returns the light color | |
| getComponentCount | [main] |
| open fun getComponentCount(): Int | |
| Returns the number of components in the LightManager, note that components are not guaranteed to be active. | |
| getDirection | [main] |
| open fun getDirection(i: Int, out: Array<Float>): Array<Float> | |
| returns the light's direction in world space | |
| getFalloff | [main] |
| open fun getFalloff(i: Int): Float | |
| returns the falloff distance of this light. | |
| getInnerConeAngle | [main] |
| open fun getInnerConeAngle(i: Int): Float | |
| getInstance | [main] |
| open fun getInstance(entity: Int): Int | |
| Gets an Instance representing the Light component associated with the given Entity. | |
| getIntensity | [main] |
| open fun getIntensity(i: Int): Float | |
| returns the light's luminous intensity in lumens. | |
| getLightChannel | [main] |
| open fun getLightChannel(i: Int, channel: Int): Boolean | |
| Returns whether a light channel is enabled on a specified renderable. | |
| getNativeObject | [main] |
| open fun getNativeObject(): Long | |
| getOuterConeAngle | [main] |
| open fun getOuterConeAngle(i: Int): Float | |
| getPosition | [main] |
| open fun getPosition(i: Int, out: Array<Float>): Array<Float> | |
| returns the light's position in world space | |
| getSunAngularRadius | [main] |
| open fun getSunAngularRadius(i: Int): Float | |
| returns the angular radius if the sun in degrees. | |
| getSunHaloFalloff | [main] |
| open fun getSunHaloFalloff(i: Int): Float | |
| returns the halo falloff of a Type.SUN light as a dimensionless value. | |
| getSunHaloSize | [main] |
| open fun getSunHaloSize(i: Int): Float | |
| returns the halo size of a Type.SUN light as a multiplier of the sun angular radius. | |
| getType | [main] |
| open fun getType(i: Int): LightManager.Type | |
| hasComponent | [main] |
| open fun hasComponent(entity: Int): Boolean | |
| Returns whether a particular Entity is associated with a component of this LightManager | |
| isShadowCaster | [main] |
| open fun isShadowCaster(i: Int): Boolean | |
| returns whether this light casts shadows. | |
| setColor | [main] |
| open fun setColor(i: Int, linearR: Float, linearG: Float, linearB: Float) | |
| Dynamically updates the light's hue as linear sRGB | |
| setDirection | [main] |
| open fun setDirection(i: Int, x: Float, y: Float, z: Float) | |
| Dynamically updates the light's direction The light direction is specified in world space and should be a unit vector. | |
| setFalloff | [main] |
| open fun setFalloff(i: Int, falloff: Float) | |
| Set the falloff distance for point lights and spot lights. | |
| setIntensity | [main] |
| open fun setIntensity(i: Int, intensity: Float) | |
| open fun setIntensity(i: Int, watts: Float, efficiency: Float) | |
| Dynamically updates the light's intensity. | |
| setIntensityCandela | [main] |
| open fun setIntensityCandela(i: Int, intensity: Float) | |
| Dynamically updates the light's intensity in candela. | |
| setLightChannel | [main] |
| open fun setLightChannel(i: Int, channel: Int, enable: Boolean) | |
| Enables or disables a light channel. | |
| setPosition | [main] |
| open fun setPosition(i: Int, x: Float, y: Float, z: Float) | |
| Dynamically updates the light's position. | |
| setShadowCaster | [main] |
| open fun setShadowCaster(i: Int, shadowCaster: Boolean) | |
| Whether this Light casts shadows (disabled by default) warning:POINT cannot cast shadows. | |
| setSpotLightCone | [main] |
| open fun setSpotLightCone(i: Int, inner: Float, outer: Float) | |
| Dynamically updates a spot light's cone as angles | |
| setSunAngularRadius | [main] |
| open fun setSunAngularRadius(i: Int, angularRadius: Float) | |
| Dynamically updates the angular radius of a Type.SUN light The Sun as seen from Earth has an angular size of 0.526° to 0. | |
| setSunHaloFalloff | [main] |
| open fun setSunHaloFalloff(i: Int, haloFalloff: Float) | |
| Dynamically updates the halo falloff of a Type.SUN light. | |
| setSunHaloSize | [main] |
| open fun setSunHaloSize(i: Int, haloSize: Float) | |
| Dynamically updates the halo radius of a Type.SUN light. |