This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
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.

Shadows

UNIGINE provides realtime and precomputed shadows from light sources.

Shadows are cast using a commonly used technique called Shadow Mapping: a depth texture (or a cubemap for omni lights) is grabbed from the position of the light source and used to define lit and shaded areas.

World light sources use an advanced shadow mapping technique called Parallel-Split Shadow Mapping to handle shadows at large distances. The shadow settings are available per each world light source.

To enable shadow casting from a light source, check the Enabled option in its Shadow Settings:

All light sources can be either in Dynamic or Static mode according to which it is decided if shadow maps are computed in real time or saved in an asset once, thus significantly reducing the number of polygons rendered each frame.

Each surface has the shadows-related Rendering Parameters. For a surface to cast shadows, it should have the Cast Proj and Omni Shadows and Cast World Shadows options enabled, the same options are available per material.

The Shadow Mode parameter is set per surface

The surface's Shadow Mode is responsible for the type of shadows cast by the surface:

  • Static. The surface casts both types of shadows: cached (from static lights) and dynamic (from dynamic lights).
  • Dynamic. The surface casts shadow only if lit by a dynamic light or a static light with Mixed shadow mode. No shadows baked.

You can control shadow-related interactions between surfaces/materials and light sources by using the Shadow Mask.

See Also#

Dynamic Shadows#

Dynamic or realtime shadows are useful in changing scenes: when a light source or objects lit by it move. In this case all affected geometry is rendered into shadow buffer one more time, which might affect the performance.

Notice
You can estimate the number of polygons rendered into shadows by using the Triangles Shadows counter of the Performance Profiler.

To make a light source provide dynamic shadows, set the Mode to Dynamic and adjust the Shadow Settings.

Cached Shadows#

Mostly, virtual environments tend to be static. That is why it makes sense to drop the shadows computation each frame to gain the performance.

The idea behind precomputed Cached Shadows is to grab the shadow map of a light source and save it in an asset to be rendered later at run time.

To get shadows from a light source cached:

  1. Select Static Shadow Mode for all stationary surfaces. This is the default mode for surfaces of Mesh Static objects.
  2. Open Bake Lighting window and check Bake Static Shadows For Lights.

    Notice
    Enable the Automatic Rebake option to make shadows for static light sources be automatically rebaked every time you make changes to their transformation and shadows-related settings.
  3. Choose Static Mode for the light source.

  4. In the Shadow Settings, select the Static shadow mode and Resolution of the shadow map.

  5. Click Bake Selected in the Bake Lighting window. The shadow map of the light source will be saved at the bake_lighting/shadows folder and assigned to the Depth Texture asset field.

After that, the light source will provide static cached shadows only. After changing light's position, rotation or parameters, it should be rebaked for proper shadow casting.

Notice
It is not recommended to bake shadows for lights stored in multiple Node References that refer to the same .node asset — the assigned textures will be lost. However, you can save a light source to a node reference after baking its shadows and clone, if needed. Make sure the Automatic Rebake option is disabled; otherwise, the shadow map will be re-baked.

World light sources require additional adjustments. For more details refer to the Shadow Settings of the World light.

Mixing Dynamic and Cached Shadows#

By using the Mixed shadow mode you can combine baked shadows from static geometry and realtime shadows cast by certain dynamic meshes:

  1. Select Static Shadow Mode for all stationary surfaces.
  2. Select Dynamic Shadow Mode for all moving or changing surfaces.
  3. Open Bake Lighting window and check Bake Static Shadows For Lights.

  4. Choose Static Mode for the light source.

  5. In the Shadow Settings, select the Mixed shadow mode and Resolution of the shadow map.

  6. Click Bake Selected in the Bake Lighting window to bake static shadows. The shadow map containing shadows cast by static geometry will be saved at the bake_lighting/shadows folder and assigned to the Depth Texture asset field.

After that, the light source will provide both cached and dynamic shadows. After changing light's position, rotation or parameters, it should be rebaked for proper shadow casting.

Area Shadows#

Soft shadows from area lights can be simulated for both static and dynamic light sources by using the Penumbra Settings.

Screen-Space Shadows#

Screen-Space Shadows are raytraced shadows calculated in screen space. This effect does not depend on the polygon count, that is why it may be a great solution for small contact shadows or shadows at a high distance from the camera.

Last update: 2023-06-23
Build: ()