Light {
SFFloat ambientIntensity 0 # [0, 1]
SFColor color 1 1 1 # any color
SFFloat intensity 1 # [0, inf)
SFBool on TRUE # {TRUE, FALSE}
SFBool castShadows FALSE # {TRUE, FALSE}
}
Direct derived nodes: PointLight, SpotLight, DirectionalLight.
The Light node is abstract: only derived nodes can be instantiated.
Lights have two purposes in Webots: (1) the are used to graphically illuminate objects and (2) they determine the quantity of light perceived by LightSensor nodes.
Except for castShadows, every field of a Light node affects the light measurements made by LightSensor nodes.
-
The
intensityfield specifies the brightness of the direct emission from the light. -
The
ambientIntensityspecifies the intensity of the ambient emission from the light. It only applies to objects using the former Appearance node and not to objects using the PBRAppearance node. -
The
colorfield specifies the spectral color properties of both the direct and ambient light emission as an RGB value. -
The
onboolean value allows the user to turn the light on (TRUE) or off (FALSE). -
The
castShadowsfield allows the user to turn on (TRUE) or off (FALSE) the casting of shadows for this Light. When activated, sharp shadows are casted from and received by any renderable object except for the semi-transparent objects, and the IndexedLineSet and PoinSet primitives. An object can be semi-transparent either if its texture has an alpha channel, or if its Material.transparencyfield is not equal to 1. Shadows are additive (Several lights can cast shadows). The darkness of a shadow depends on how the occluded part is lighted (either by an ambient light component or by another light). Activating the shadows of just one Light can have a significant impact on the global rendering performance, particularly if the world contains either lots of objects or complex meshes. Some shadow issues can occurs in closed spaces.
Due to a performance issue in Firefox on Windows and macOS (see comment of this issue), the number of lights is limited to 48 lights of each kind: PointLight, SpotLight and DirectionalLight.
However it is possible to support more lights (up to 256 of each) if needed. The following procedure explains how to increase the lights limit:
-
Build Webots from sources (instructions are available here).
-
Modify the number of lights of
gMaxActiveDirectionalLights,gMaxActiveDirectionalLightsandgMaxActiveSpotLightsinwebots/src/wren/Constants.hpp. -
Modify the number of lights of
maxDirectionalLights,maxPointLightsandmaxSpotLightsin the following shaders:webots/resources/wren/shaders/pbr.fragwebots/resources/wren/shaders/pbr_stencil_diffuse_specular.fragwebots/resources/wren/shaders/phong.fragwebots/resources/wren/shaders/phong_stencil_ambient_emissive.fragwebots/resources/wren/shaders/phong_stencil_diffuse_specular.fragwebots/resources/wren/shaders/shadow_volume.vert
-
Compile Webots again.