This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine 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
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
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.

Unigine.Light Class

Inherits from: 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

Enums

SHADOW_RESOLUTION#

NameDescription
MODE_DEFAULT = -1Default shadow map resolution (512×512).
MODE_64 = MODE_DEFAULT + 1Shadow map resolution equals 64×64.
MODE_128 = MODE_64 + 1Shadow map resolution equals 128×128.
MODE_256 = MODE_128 + 1Shadow map resolution equals 256×256.
MODE_512 = MODE_256 + 1Shadow map resolution equals 512×512.
MODE_1024 = MODE_512 + 1Shadow map resolution equals 1024×1024.
MODE_2048 = MODE_1024 + 1Shadow map resolution equals 2048×2048.
MODE_4096 = MODE_2048 + 1Shadow map resolution equals 4096×4096.
MODE_8192 = MODE_4096 + 1Shadow map resolution equals 8192×8192.
MODE_16384 = MODE_8192 + 1Shadow map resolution equals 16384×16384.

SHADOW_PENUMBRA#

NameDescription
GLOBAL = -1Quality mode of shadow penumbra that is set globally for all light sources is applied.
DISABLED = GLOBAL + 1Shadow penumbra is disabled.
LOW = DISABLED + 1Low quality of shadow penumbra.
MEDIUM = LOW + 1Medium quality of shadow penumbra.
HIGH = MEDIUM + 1High quality of shadow penumbra.
ULTRA = HIGH + 1Ultra quality of shadow penumbra.

SHADOW_FILTER#

NameDescription
GLOBAL = -1Quality mode of shadow filtering that is set globally is applied.
DISABLED = GLOBAL + 1Shadow filtering is disabled.
LOW = DISABLED + 1Low quality of shadow filtering.
MEDIUM = LOW + 1Medium quality of shadow filtering.
HIGH = MEDIUM + 1High quality of shadow filtering.
ULTRA = HIGH + 1Ultra quality of shadow filtering.

COLOR_MODE#

NameDescription
CLASSIC = 0Classic color calculation mode, resulting color is defined by Color.
TEMPERATURE = 1Physically based color calculation mode, resulting color is calculated as: ColorFilter * (color obtained using the ColorTemperature value).

SHADOW_MODE#

NameDescription
MIXED = 0Shadow mode for omni and projected light sources with the static light mode enabled to render both static and dynamic shadows.
STATIC = 1Static shadow mode for omni and projected light sources with the static light mode enabled.

SHADOW_COLOR_MODE#

NameDescription
IES = 0Light distibution is defined by the IES profile.
SIMPLE = 1An arbitrary 2D texture is projected onto the scene.

MODE#

NameDescription
DYNAMIC = 0Real-time light rendering mode. The light source with this mode enabled is turned off while light baking is being calculated. Objects lit by such light cast only dynamic shadows.
STATIC = 1Mixed light rendering mode. The light source with this light mode enabled contributes to light baking and remains enabled all the time providing direct realtime lighting. Objects lit by such light can cast static or dynamic shadows depending on the shadow mode set for the source and the object surface.

SHAPE#

NameDescription
DEFAULT = -1A point light source (light is emitted by an infinitely small point) set by default.
POINT = DEFAULT + 1A point light source (light is emitted by an infinitely small point).
SPHERE = POINT + 1A sphere-shaped light source.
CAPSULE = SPHERE + 1A capsule-shaped light source.
RECTANGLE = CAPSULE + 1A rectangular light source. Such light source produces the light and the speck in a form of a rounded rectangle.

Properties

float ShadowScreenSpaceSoftness#

The current softness value of the screen-space shadows for the light source.

float ShadowScreenSpaceThresholdNear#

The current threshold value used to calculate screen-space shadows for the light source.

float ShadowScreenSpaceStepSizeNear#

The current size of the step used to calculate screen-space shadows for the light source.

float ShadowScreenSpaceNoiseStep#

The current intensity of the step noise used to calculate screen-space shadows for the light source.

float ShadowScreenSpaceNoiseRay#

The current intensity of the ray noise used to calculate screen-space shadows for the light source.

int ShadowScreenSpaceNumSteps#

The current number of steps used to calculate screen-space shadows for the light source.

int ShadowScreenSpaceNumRays#

The current number of rays used to calculate screen-space shadows for the light source.

int ShadowScreenSpace#

The A value indicating if screen-space shadows for the light source are enabled. when this option is enabled, penumbras from the light source are calculated using the ray tracing algorithm.

Texture DepthTexture#

The Depth texture (shadow map) of the light source.

Texture ShadowColorTexture#

The Current shadow texture of the light source used to render translucent shadows: G-channel stores depth values, R-channel - transparency values.

Texture BakedDepthTexture#

The depth texture baked for the light source. this texture is available for Static light sources only.
Notice
Static lights with mixed shadow mode enabled use a mixture of dynamic and baked depth textures.

string BakedDepthTexturePath#

The A path to a baked depth texture, which is used for storing the shadow map created from the light source set to the static light mode. this texture is baked automatically via the editor or using bake() or bakeAll() methods.

Texture DynamicDepthTexture#

The current dynamic depth texture for the light source. this texture is available for the following types of light sources:

float ShadowPenumbra#

The current intensity of penumbra for the selected mode.

Light.SHADOW_PENUMBRA ShadowPenumbraMode#

The current global quality mode used for rendering penumbra from the light source. this mode enables simulation of real-world shadows by keeping sharp contact shadows closer to the base and softening the farther the shadow stretches away. Higher values produce softer shadows.

float ShadowFilter#

The current filtering intensity for the selected mode.

Light.SHADOW_FILTER ShadowFilterMode#

The current filtering mode used to reduce the stair-step effect for soft shadows making the edges smoother.

Light.SHADOW_MODE ShadowMode#

The Shadow mode for the light source in static mode. this shadow mode should be aligned with the shadow mode of the object surface in order to make this surface cast a shadow from the light source.

Light.MODE Mode#

The current rendering mode for the light source. this option determines whether the light is to be rendered as a dynamic or static one.

float ShadowNormalBias#

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.

float ShadowBias#

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).

Light.SHADOW_RESOLUTION ShadowResolution#

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

bool Shadow#

The A value indicating if the light source casts shadows from surfaces with the Cast Shadow material.

float AttenuationPower#

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.

vec4 ColorFilter#

The color multiplier for the light source color (calculated using the color temperature value). This is used to imitate colored glass. The method takes effect only when the Temperature color mode is set.

float ColorTemperature#

The light source temperature used for light color calculation.

float Lux#

The intensity of the light color (as perceived by the human eye) in lux. in unigine, all light sources have the intensity of 1 by default, which is equal to 100000 lux.

float Intensity#

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

vec4 Color#

The color of the light source. the default is opaque white, (1, 1, 1, 1). The method takes effect only when the Classic color mode is set.

Light.COLOR_MODE ColorMode#

The current color calculation mode of the light source. light source color can be defined by the color value (classic mode) or by the color temperature and color filter values (physically based mode).

int ViewportMask#

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

int ShadowMask#

The current light mask for the light source.

For the shadow from an object's surface to be rendered for the light source, this mask must match the following ones (one bit, at least):

bool RenderTransparent#

The A value indicating if the light from the source is rendered on transparent objects.

bool RenderWater#

The A value indicating if the light from the source is rendered on water objects.

float FadeDistance#

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.

float ShadowDistance#

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

float VisibleDistance#

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

int NumLensFlares#

The total number of lens flares used for the per-light lens flare effect.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

bool LensFlaresUseLightColor#

The A value indicating if light color modulation is enabled for per-light lens flares. when enabled, the lens flares will have the same color as the light source.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

vec3 LensFlaresWorldPositionOffset#

The current offset from the world position of the light source for the per-light lens flares. offset is not available for World Lights.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

float LensFlaresOcclusionFadeBorder#

The current lens flare occlusion fade value for the cases when the light source becomes occluded by the edges of the screen.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

float LensFlaresOcclusionFade#

The current lens flare occlusion fade value for the cases when the light source becomes occluded by an object.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

float LensFlaresIntensity#

The current intensity of per-light lens flares.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

string LensFlaresTextureName#

The name of the texture currently used for the per-light lens flare effect. this texture stores images for all lens flares used to render lens flares.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

bool LensFlaresEnabled#

The A value indicating if the per-light lens flare effect is enabled for the light source.
Notice
This feature is available only for: Omni Lights, Projected Lights and World Lights.

float ShadowScreenSpaceThresholdFar#

The current threshold value used to calculate screen-space shadows for the light source (long distance range). You can set different Step Size and Threshold values for objects located near the camera and far away from it. Thus, full-scale shadows will be rendered for large objects located far away, while within the close distance range only shadows cast by small objects will be rendered. This feature is especially useful for locations where details are required for both short and long-distance ranges.

float ShadowScreenSpaceThresholdFarDistance#

The Sets the distance from the camera after which the Far Threshold is used for screen-space shadows calculation. You can set different Step Size and Threshold values for objects located near the camera and far away from it. Thus, full-scale shadows will be rendered for large objects located far away, while within the close distance range only shadows cast by small objects will be rendered. This feature is especially useful for locations where details are required for both short and long-distance ranges.

float ShadowScreenSpaceThresholdNearDistance#

The current distance from the camera up to which the Near Threshold is used for screen-space shadows calculation. You can set different Step Size and Threshold values for objects located near the camera and far away from it. Thus, full-scale shadows will be rendered for large objects located far away, while within the close distance range only shadows cast by small objects will be rendered. This feature is especially useful for locations where details are required for both short and long-distance ranges.

float ShadowScreenSpaceStepSizeFar#

The current size of the step used to calculate screen-space shadows for the light source (long distance range). This parameter can be used to adjust calculation of shadows for specific sizes of objects. You can set different Step Size and Threshold values for objects located near the camera and far away from it. Thus, full-scale shadows will be rendered for large objects located far away, while within the close distance range only shadows cast by small objects will be rendered. This feature is especially useful for locations where details are required for both short and long-distance ranges.

float ShadowScreenSpaceStepSizeNearDistance#

The current distance from the camera up to which the Near Step Size is used for screen-space shadows calculation. You can set different Step Size and Threshold values for objects located near the camera and far away from it. Thus, full-scale shadows will be rendered for large objects located far away, while within the close distance range only shadows cast by small objects will be rendered. This feature is especially useful for locations where details are required for both short and long-distance ranges.

float ShadowScreenSpaceStepSizeFarDistance#

The current distance from the camera after which the Far Step Size is used for screen-space shadows calculation. You can set different Step Size and Threshold values for objects located near the camera and far away from it. Thus, full-scale shadows will be rendered for large objects located far away, while within the close distance range only shadows cast by small objects will be rendered. This feature is especially useful for locations where details are required for both short and long-distance ranges.

Light.SHADOW_COLOR_MODE ShadowColorTextureMode#

The Type of texture used to define light distribution. One of the following modes:
  • IES - Light distibution is defined by the IES profile.
  • SIMPLE - An arbitrary 2D texture is projected onto the scene.
Notice
This feature is available only for Omni Lights and Projected Lights. See description of the modes in the corresponding articles forOmni Lights and Projected Lights.

float ShadowScreenSpaceTranslucentViewBias#

The Translucent View Bias value for Screen-Space Shadows, that controls an effect of fuzziness for vegetation (e.g. simulating leaves of saintpaulia or providing a sponge-like look for tree crowns).
  • By the value of 0 the effect is disabled
  • the value of 1 corresponds to the maximum effect.

float ShadowScreenSpaceTranslucentDepthPerspectiveCompensation#

The Perspective Compensation value for the Translucent Depth parameter of Screen-Space Shadows, that defines whether the Translucent Depth parameter depends on the distance from the camera to the surface or not.
  • 0 - the Translucent Depth value does not depend on the distance from the camera to the surface.
  • 1 - the Translucent Depth value linearly depends on the distance from the camera to the surface.

This effect is used to make tree crowns located far from the camera more translucent than the grass nearby.

float ShadowScreenSpaceTranslucentDepth#

The Translucent Depth value for Screen-Space Shadows indicating how much the light passes through screen-space shadows on translucent materials (with Translucence option enabled).
The higher the value the deeper the light penetrates translucent objects shifting the shadow.

Members


void AllocateLensFlares ( int num ) #

Allocate a buffer for a given number of lens flares to be created. With this function, memory can be allocated once rather than in chunks, making the creation faster.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

Arguments

  • int num - Number of lens flares to be created in the allocated buffer.

void AddLensFlare ( ) #

Add a new lens flare for the per-light lens flare effect.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

LightLensFlare GetLensFlare ( int num ) #

Returns the given lens flare from the list of the ones used for the per-light lens flare effect.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

Arguments

  • int num - Lens flare number.

Return value

Light lens flare instance.

void CloneLensFlare ( int num ) #

Creates a clone of the lens flare with a given number in the list of lens flares used for the per-light lens flare effect.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

Arguments

  • int num - Number of lens flare to be cloned.

void RemoveLensFlare ( int num ) #

Removes the lens flare with a given number from the list of lens flares used for the per-light lens flare effect.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

Arguments

  • int num - Number of lens flare to be removed.

void ClearLensFlares ( ) #

Clears the list of lens flares used for the per-light lens flare effect.
Notice
The lens flare effect must be enabled for the light source. This feature is available only for: Omni Lights, Projected Lights and World Lights.

vec4 CalculateFinalColor ( ) #

Calculates the final color of the light source depending on the calculation mode used.

Return value

Resulting color of the light source.

bool SaveStateLight ( Stream stream ) #

Saves the state of the light source to the specified stream.

Example using SaveStateLight() and RestoreStateLight() methods:

Source code (C#)
// set the light state
light.ColorTemperature = 15000.0f;

// save state
Blob blob_state = new Blob();
light.SaveStateLight(blob_state);

// change the node state
light.ColorTemperature = 27000.0f;

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
light.RestoreStateLight(blob_state);

Arguments

  • Stream stream - Stream instance.

Return value

true if the state of the light source is saved successfully; otherwise, false.

bool RestoreStateLight ( Stream stream ) #

Restores the state of the light source from the specified stream.

Example using SaveStateLight() and RestoreStateLight() methods:

Source code (C#)
// set the light state
light.ColorTemperature = 15000.0f;

// save state
Blob blob_state = new Blob();
light.SaveStateLight(blob_state);

// change the node state
light.ColorTemperature = 27000.0f;

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
light.RestoreStateLight(blob_state);

Arguments

  • Stream stream - Stream instance.

Return value

true if the state of the light source is restored successfully; otherwise, false.

bool SaveStateLensFlares ( Stream stream ) #

Saves the state of the per-light lens flare effect to the specified stream.

Example using SaveStateLensFlares() and RestoreStateLensFlares() methods:

Source code (C#)
// set the lens flare state
lens_flare.LensFlaresIntensity = 0.75f;

// save state
Blob blob_state = new Blob();
lens_flare.SaveStateLensFlares(blob_state);

// change the node state
lens_flare.LensFlaresIntensity = 0.25f;

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
lens_flare.RestoreStateLensFlares(blob_state);

Arguments

  • Stream stream - Stream instance.

Return value

true if the state of the per-light lens flare effect is saved successfully; otherwise, false.

bool RestoreStateLensFlares ( Stream stream ) #

Restores the state of the per-light lens flare effect from the specified stream.

Example using SaveStateLensFlares() and RestoreStateLensFlares() methods:

Source code (C#)
// set the lens flare state
lens_flare.LensFlaresIntensity = 0.75f;

// save state
Blob blob_state = new Blob();
lens_flare.SaveStateLensFlares(blob_state);

// change the node state
lens_flare.LensFlaresIntensity = 0.25f;

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
lens_flare.RestoreStateLensFlares(blob_state);

Arguments

  • Stream stream - Stream instance.

Return value

true if the state of the per-light lens flare effect is restored successfully; otherwise, false.
Last update: 2022-12-14
Build: ()