This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Light Class

This base class is used to create light sources and shadows from them. The lights can cast either normal grey shadows or translucent ones. The lights can be rendered as a simplified deferred lighting.

Light Class

This class inherits from Node

Members


float getAttenuation ()

Returns the attenuation of the light. The larger is this value, the faster the light attenuates. If the attenuation equals to zero or is close to it, the edge between illuminated and non-illuminated areas will be sharp. and The default is 1.

Return value

Light attenuation.

vec4 getColor ()

Returns the color of the light source. The default is opaque white, (1, 1, 1, 1).

Return value

Color of the light source in the RGBA format.

float getFadeDistance ()

Returns the current distance, at which the light source is faded.

Return value

Distance in units.

int getLightMask ()

Returns a light mask of the material. The material is illuminated by a light source, if they both have corresponding masks.

Return value

Integer, each bit of which is a mask.

float getMultiplier ()

Returns the color multiplier of the light source. This factor will be used to change color of illuminated areas.

Return value

Color multiplier.

float getShadowBias ()

Returns the constant offset of depth values in a shadow map. This offset helps to remove false self-shadowing.

Return value

Constant depth offset.

float getShadowDistance ()

Returns the current distance, at which shadow from the light source starts fading.

Return value

Distance in units.

vec3 getShadowOffset ()

Returns the shadow offset vector. This vector specifies how and where shadows caused by the light source will be offset.

Return value

Shadow offset vector.

int getShadowSize ()

Returns the size of the shadow map created for the light source.

Return value

Shadow map size:
  • -1 — default
  • 0 — 64×64
  • 1 — 128×128
  • 2 — 256×256
  • 3 — 512×512
  • 4 — 1024×1024
  • 5 — 2048×2048
  • 6 — 4096×4096

float getShadowSlope ()

Returns the variable offset of depth values in a shadow map. This offset is scaled depending on the surface slope from the light source point of view: the greater is the slope, the more is the offset.

Return value

Variable depth offset.

float getShadowSoftness ()

Returns the degree of softness of shadows created with a shadow map. The larger is this value, the softer are the shadows.

Return value

Softness of shadows.

int getShadow ()

Returns a value indicating if the light source casts shadows from surfaces with Cast Shadow material.

Return value

1 if the light source casts shadows; otherwise, 0.

int getViewportMask ()

Returns the current bit mask for rendering into the viewport. The light is rendered, if its mask matches the player's one.

Return value

Integer, each bit of which is a mask.

float getVisibleDistance ()

Returns the current distance, at which the light source starts fading.

Return value

Distance in units.

void setAttenuation (float attenuation)

Updates the attenuation of the light. The larger is this value, the faster the light attenuates. If the attenuation equals to zero or is close to it, the edge between illuminated and non-illuminated areas will be sharp.

Arguments

  • float attenuation - New light attenuation. This value will be saturated in range [0.001; 1].

void setColor (vec4 color)

Updates the color of the light source.

Arguments

  • vec4 color - New color in the RGBA format.

void setFadeDistance (float distance)

Updates a distance, at which the light source is faded.

Arguments

  • float distance - Distance in units.

void setLightMask (int mask)

Updates a light mask for the material. The material is illuminated by a light source, if they both have corresponding masks.

Arguments

  • int mask - Integer, each bit of which is a mask.

void setMultiplier (float factor)

Updates the color multiplier of the light source. This factor will be used to change color of illuminated areas.

Arguments

  • float factor - New color multiplier. This value will be saturated in range [1; 1000].

void setShadowBias (float offset)

Updates the constant offset of depth values in a shadow map. This offset helps to remove false self-shadowing.

Arguments

  • float offset - New constant depth offset. If a negative value is provided, 0 will be used instead.

void setShadowDistance (float distance)

Updates a distance, at which shodow from the light source starts fading.

Arguments

  • float distance - Distance in units.

void setShadowOffset (vec3 offset)

Updates the shadow offset vector. This vector specifies how and where shadows caused by the light source will be offset.

Arguments

  • vec3 offset - New shadow offset vector.

void setShadowSize (int size)

Updates the size of the shadow map created for the light source.

Arguments

  • int size - New shadow map size:
    • -1 — default
    • 0 — 64×64
    • 1 — 128×128
    • 2 — 256×256
    • 3 — 512×512
    • 4 — 1024×1024
    • 5 — 2048×2048
    • 6 — 4096×4096

void setShadowSlope (float offset)

Updates the variable offset of depth values in a shadow map. This offset is scaled depending on the surface slope from the light source point of view: the greater is the slope, the more is the offset.

Arguments

  • float offset - New variable depth offset. If a negative value is provided, 0 will be used instead.

void setShadowSoftness (float softness)

Updates the degree of softness of shadows created with a shadow map. The larger is this value, the softer are the shadows.

Arguments

  • float softness - New softness of shadows.

void setShadow (int mode)

Updates a value indicating if the light casts shadows from surfaces with Cast Shadow material.

Arguments

  • int mode - 1 to cast shadows, 0 not to cast.

void setViewportMask (int mask)

Updates a bit mask for rendering into the viewport. The light is rendered, if its mask matches the player's one.

Arguments

  • int mask - Integer, each bit of which is a mask.

void setVisibleDistance (float distance)

Updates a distance, at which the light source starts fading.

Arguments

  • float distance - Distance in units.
Last update: 2017-07-03
Build: ()