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
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
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 getDeferredDistance ()

Returns the current distance starting from which the light source starts to be rendered as deferred.

Return value

Distance to start rendering light as deferred.

float getDiffuseScale ()

Returns the current diffuse scale for the light source.

Return value

Diffuse scale.

float getFadeDistance ()

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

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. The default is ~0.

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. The default is 1.

Return value

Color multiplier.

float getNormalScale ()

Returns a normal map scale for a light source.

Return value

Normal map scale.

float getShadowAmbient ()

Returns the factor that is used to change color of shadowed areas. The higher is this value, the lighter is the color. The default is 0.

Return value

Factor to change color of shadowed areas.

float getShadowBias ()

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

Return value

Constant depth offset.

float getShadowDistance ()

Returns the current distance, at which shadow from the light source starts fading. The default is infinity.

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. The default is (0, 0, 0).

Return value

Shadow offset vector.

int getShadowSize ()

Returns the size of the shadow map created for the light source. The default is -1 (which means to use the default size).

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. The default is 2.

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. The default is 1.

Return value

Softness of shadows.

int getShadow ()

Returns a value indicating if the light source casts shadows from surfaces with Cast Shadow material. The default is 1 (true).

Return value

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

float getSpecularPower ()

Returns a specular power of the light source.

Return value

Specular power.

float getSpecularScale ()

Returns a specular scale of the light source.

Return value

Specular scale.

float getTranslucentBias ()

Returns an offset of depth values in a shadow map for translucent objects. This offset helps to remove false self-shadowing. The default is 2.

Return value

Depth offset for translucent objects.

int getTranslucentSize ()

Returns the size of the translucent shadow map created for the light source. The default is -1 (which means to use the default size).

Return value

Translucent shadow map size:
  • -1 — default
  • 0 — 64×64
  • 1 — 128×128
  • 2 — 256×256
  • 3 — 512×512
  • 4 — 2048×2048

int getTranslucent ()

Returns a value indicating if the light source casts colored (translucent) shadows from surfaces with Cast Translucent material. The default is 0.

Return value

1 if the light casts translucent 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. The default is infinity.

Return value

Distance in units.

int isDeferred ()

Returns a value indicating if the light source is always rendered as deferred.

Return value

1 if the light is deferred; otherwise, 0.

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 setDeferredDistance (float distance)

Updates the distance starting from which the light source starts to be rendered as deferred. The default is infinity.

Arguments

  • float distance - Distance to start rendering light as deferred. If a negative value is provided, 0 will be used instead.

void setDeferred (int deferred)

Updates a value indicating if the light source should be always rendered as deferred.

Arguments

  • int deferred - 1 for the light to be deferred; otherwise, 0.

void setDiffuseScale (float scale)

Updates a diffuse scale for the light source.

Arguments

  • float scale - Diffuse scale.

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 setNormalScale (float scale)

Sets a normal map scale for a light source.

Arguments

  • float scale - Normal map scale.

void setShadowAmbient (float factor)

Updates the factor that is used to change color of shadowed areas. The higher is this value, the lighter is the color.

Arguments

  • float factor - New factor to change color of shadowed areas. This value will be saturated in range [0; 1].

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 setSpecularPower (float power)

Updates a specular power for the light source.

Arguments

  • float power - Specular power.

void setSpecularScale (float scale)

Updates a specular scale for the light source.

Arguments

  • float scale - Specular scale.

void setTranslucentBias (float offset)

Updates an offset of depth values in a shadow map for translucent objects. This offset helps to remove false self-shadowing.

Arguments

  • float offset - Depth offset for translucent objects. If a negative value is provided, 0 will be used instead.

void setTranslucentSize (int size)

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

Arguments

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

void setTranslucent (int mode)

Updates a value indicating if the light source can cast colored (translucent) shadows from surfaces with Cast Translucent material.

Arguments

  • int mode - 1 to cast translucent 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: ()