Light

Inherits: VisualInstance < CullInstance < Spatial < Node < Object Inherited By: DirectionalLight, OmniLight, SpotLight Provides a base class for different kinds of light nodes.

Description

abstract base class for light nodes. As it can’t be instanced, it shouldn’t be used directly. Other types of light nodes inherit from it. Light contains the common variables and parameters used for lighting.

Tutorials

  • 3D lights and shadows
  • Third Person Shooter Demo

    Properties

    Methods

    Enumerations

    Param:
  • PARAM_ENERGY = 0 —- Constant for accessing light_energy.
  • PARAM_INDIRECT_ENERGY = 1 —- Constant for accessing light_indirect_energy.
  • PARAM_SIZE = 2 —- Constant for accessing light_size.
  • PARAM_SPECULAR = 3 —- Constant for accessing light_specular.
  • PARAM_RANGE = 4 —- Constant for accessing OmniLight.omni_range or SpotLight.spot_range.
  • PARAM_ATTENUATION = 5 —- Constant for accessing OmniLight.omni_attenuation or SpotLight.spot_attenuation.
  • PARAM_SPOT_ANGLE = 6 —- Constant for accessing SpotLight.spot_angle.
  • PARAM_SPOT_ATTENUATION = 7 —- Constant for accessing SpotLight.spot_angle_attenuation.
  • PARAM_CONTACT_SHADOW_SIZE = 8 —- Constant for accessing shadow_contact.
  • PARAM_SHADOW_MAX_DISTANCE = 9 —- Constant for accessing DirectionalLight.directional_shadow_max_distance.
  • PARAM_SHADOW_SPLIT_1_OFFSET = 10 —- Constant for accessing DirectionalLight.directional_shadow_split_1.
  • PARAM_SHADOW_SPLIT_2_OFFSET = 11 —- Constant for accessing DirectionalLight.directional_shadow_split_2.
  • PARAM_SHADOW_SPLIT_3_OFFSET = 12 —- Constant for accessing DirectionalLight.directional_shadow_split_3.
  • PARAM_SHADOW_NORMAL_BIAS = 13 —- Constant for accessing DirectionalLight.directional_shadow_normal_bias.
  • PARAM_SHADOW_BIAS = 14 —- Constant for accessing shadow_bias.
  • PARAM_SHADOW_BIAS_SPLIT_SCALE = 15 —- Constant for accessing DirectionalLight.directional_shadow_bias_split_scale.
  • PARAM_MAX = 16 —- Represents the size of the Param enum.

BakeMode:

  • BAKE_DISABLED = 0 —- Light is ignored when baking. Note: Hiding a light does not affect baking.
  • BAKE_INDIRECT = 1 —- Only indirect lighting will be baked (default).
  • BAKE_ALL = 2 —- Both direct and indirect light will be baked. Note: You should hide the light if you don’t want it to appear twice (dynamic and baked).

    Property Descriptions

  • bool editor_only true, the light only appears in the editor and will not be visible at runtime.

  • BakeMode light_bake_mode BakeMode.

  • Color light_color overbright color can be used to achieve a result equivalent to increasing the light’s light_energy.

  • int light_cull_mask The light will affect objects in the selected layers.

  • float light_energy OmniLight and SpotLight, changing this value will only change the light color’s intensity, not the light’s radius.

  • float light_indirect_energy BakedLightmap and GIProbe.

  • bool light_negative true, the light’s effect is reversed, darkening areas and casting bright shadows.

  • float light_size light_bake_mode is set to BAKE_ALL. Increasing this value will make the shadows appear blurrier. This can be used to simulate area lights to an extent.

  • float light_specular 0, the light becomes a pure diffuse light. When not baking emission, this can be used to avoid unrealistic reflections when placing lights above an emissive surface.

  • float shadow_bias Used to adjust shadow appearance. Too small a value results in self-shadowing (“shadow acne”), while too large a value causes shadows to separate from casters (“peter-panning”). Adjust as needed.

  • Color shadow_color The color of shadows cast by this light.

  • float shadow_contact shadow_bias gap by rendering screen-space contact shadows. This has a performance impact, especially at higher values. Note: Contact shadows can look broken, so leaving this property to 0.0 is recommended.

  • bool shadow_enabled true, the light will cast shadows.

  • bool shadow_reverse_cull_face true, reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double-sided shadows with GeometryInstance.SHADOW_CASTING_SETTING_DOUBLE_SIDED.

    Method Descriptions

  • float get_param ( Param param ) const Param parameter.

  • set_param ( Param param, float value ) Param parameter.