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#
SHADOW_PENUMBRA#
Name | Description |
---|---|
GLOBAL = -1 | Quality mode of shadow penumbra that is set globally for all light sources is applied. |
DISABLED = GLOBAL + 1 | Shadow penumbra is disabled. |
LOW = DISABLED + 1 | Low quality of shadow penumbra. |
MEDIUM = LOW + 1 | Medium quality of shadow penumbra. |
HIGH = MEDIUM + 1 | High quality of shadow penumbra. |
ULTRA = HIGH + 1 | Ultra quality of shadow penumbra. |
SHADOW_FILTER#
Name | Description |
---|---|
GLOBAL = -1 | Quality mode of shadow filtering that is set globally is applied. |
DISABLED = GLOBAL + 1 | Shadow filtering is disabled. |
LOW = DISABLED + 1 | Low quality of shadow filtering. |
MEDIUM = LOW + 1 | Medium quality of shadow filtering. |
HIGH = MEDIUM + 1 | High quality of shadow filtering. |
ULTRA = HIGH + 1 | Ultra quality of shadow filtering. |
COLOR_MODE#
Name | Description |
---|---|
CLASSIC = 0 | Classic color calculation mode, resulting color is defined by Color. |
TEMPERATURE = 1 | Physically based color calculation mode, resulting color is calculated as: ColorFilter * (color obtained using the ColorTemperature value). |
SHADOW_MODE#
SHADOW_COLOR_MODE#
Name | Description |
---|---|
IES = 0 | Light distibution is defined by the IES profile. |
SIMPLE = 1 | An arbitrary 2D texture is projected onto the scene. |
MODE#
SHAPE#
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.
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:
- Dynamic lights.
- Static lights with mixed shadow mode enabled, that use a mixture of dynamic and baked depth textures.
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):
- Shadow mask of the surface of the object
- Shadow mask of the material assigned to this surface
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.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.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.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.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.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.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:
// 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:
// 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:
// 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:
// 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-10-10
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)