This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
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.

Unigine::Light Class

Header:#include <UnigineLights.h>
Inherits:Node

This base class is used to create light sources and shadows from them. The lights can be rendered as a simplified deferred lighting.

Light Class

Members


Ptr<Light> cast(const Ptr<Node> & node)

Casts a Light out of the Node instance.

Arguments

  • const Ptr<Node> & node - Pointer to Node.

Return value

Pointer to Light.

void setAttenuationPower(float power)

Updates the attenuation power of the light. This parameter determines how fast the intensity decreases up to the attenuation distance set for the light source. If the attenuation equals to zero or is close to it, the edge between illuminated and non-illuminated areas will be sharp.

Arguments

  • float power - Light attenuation power.

float getAttenuationPower()

Returns the attenuation power of the light. This parameter determines how fast the intensity decreases up to the attenuation distance set for the light source. If the attenuation equals to zero or is close to it, the edge between illuminated and non-illuminated areas will be sharp. The default is 1.

Return value

Light attenuation power.

void setColor(const Math::vec4 & color)

Updates the color of the light source.

Arguments

  • const Math::vec4 & color - New color in the RGBA format.

Math::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.

void setDepthTexture(const Ptr<Texture> & texture)

Arguments

  • const Ptr<Texture> & texture

Ptr<Texture> getDepthTexture()

void setFadeDistance(float distance)

Updates a distance, at which the light gradually disappears. This parameter enables to render the light with decreasing radiance after the Visible distance is past.

Arguments

  • float distance - Distance in units.

float getFadeDistance()

Returns the current distance, at which the light source gradually disappears. This parameter enables to render the light with decreasing radiance after the Visible distance is past.

Return value

Distance in units.

void setIntensity(float intensity)

Updates the multiplier for the light color used to control color intensity. The higher the value, the brighter the light is.
  • The minimum value of 1 corresponds to the least saturated light color.
  • The maximum value of 100 equals the most bright and intense color.

Arguments

  • float intensity - New color multiplier.

float getIntensity()

Returns the multiplier of the light color used to control color intensity. The higher the value, the brighter the light is.

Return value

Light color multiplier.

Ptr<Light> getLight()

Returns a light pointer.

Return value

The light pointer.

void setLightMask(int mask)

Updates a light mask for the surface. For the surface to be illuminated by the light source, its light mask must match the mask of the light source.

Arguments

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

int getLightMask()

Returns a light mask of the surface. For the surface to be illuminated by the light source, its light mask must match the mask of the light source.

Return value

Integer, each bit of which is used to set a mask.

setRenderTransparent(int transparent)

Arguments

  • int transparent

getRenderTransparent()

setRenderWater(int water)

Arguments

  • int water

getRenderWater()

void setShadow(int shadow)

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

Arguments

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

int getShadow()

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

Return value

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

void setShadowBias(float bias)

Updates the constant offset of depth values in a shadow map.
  • If the shadow acne appears, the bias value should be increased. This procedure eliminates the self-shadowing effect, as the points will appear closer to light source when compared to the map depth value.
  • If the bias value is set too high, the shadow will look detached from the object casting it (see the 3rd picture below).

Arguments

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

float getShadowBias()

Returns the constant offset of depth values in a shadow map.
  • If the shadow acne appears, the bias value should be increased. This procedure eliminates the self-shadowing effect, as the points will appear closer to light source when compared to the map depth value.
  • If the bias value is set too high, the shadow will look detached from the object casting it (see the 3rd picture below).

Return value

Constant depth offset.

void setShadowDistance(float distance)

Updates a distance, at which shadow from the light source starts fading out to nonexistence.

Arguments

  • float distance - Distance in units.

float getShadowDistance()

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

Return value

Distance in units.

void setShadowNormalBias(float bias)

Updates the shadow bias that is achieved by shifting the surface on which the shadow falls. The surface is shifted along normals stored in the normal map. Depending on the normal map of the surface, the shadow may differ for the same values of the normal bias.

Arguments

  • float bias - New normal bias. If a negative value is provided, 0 will be used instead.

float getShadowNormalBias()

Returns the shadow bias that is achieved by shifting the surface on which the shadow falls. The surface is shifted along normals stored in the normal map. Depending on the normal map of the surface, the shadow may differ for the same values of the normal bias.

Return value

The normal bias.

void setShadowOffset(const Math::vec3 & offset)

Updates the offset of the shadow along the X, Y and Z axes. This vector specifies how and where shadows caused by the light source will be shifted.

Arguments

  • const Math::vec3 & offset - New shadow offset vector.

Math::vec3 getShadowOffset()

Returns offset of the shadow along the X, Y and Z axes relative to the source position. This vector specifies how and where shadows caused by the light source will be shifted.

Return value

Shadow offset vector.

void setShadowResolution(int resolution)

Updates the size of the shadow map created for the light source.
  • The higher the resolution, the smoother and true to life the result is.
  • The lower the resolution, the more blocky and jagged the shadows outline appears.

Arguments

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

int getShadowResolution()

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

Return value

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

void setShadowSoftness(float softness)

Updates the size of the blur applied to the shadow edge.
  • Low softness values corresponds to the crisp and sharp shadow edges.
  • Higher softness values serve to accentuate the effect of soft indirect lighting.

Arguments

  • float softness - New softness of shadows.

float getShadowSoftness()

Returns the size of the blur applied to the shadow edge.
  • Low softness values corresponds to the crisp and sharp shadow edges.
  • Higher softness values serve to accentuate the effect of soft indirect lighting.

Return value

Softness of shadows.

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 used to set a mask.

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 used to set a mask.

void setVisibleDistance(float distance)

Updates a distance, at which the light source starts fading. If the distance is set to infinity, the source is always rendered.

Arguments

  • float distance - Distance in units.

float getVisibleDistance()

Returns the current distance, at which the light source starts fading. If the distance is set to infinity, the source is always rendered.

Return value

Distance in units.

int SHAPE_CAPSULE

Description

A capsule-shaped light source.

int SHAPE_POINT

Description

A point light source (light is emitted by an infinitely small point).

int SHAPE_RECTANGLE

Description

A rectangular light source. Such light source produces the light and the speck in a form of a rounded rectangle.

int SHAPE_SPHERE

Description

A sphere-shaped light source.
Last update: 2017-07-03
Build: ()