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

Lights Optimization

Light sources in the scene are resource-consuming (especially, if there are a lot of them). For example, depending on the light source type, calculation of shadows cast by the lit objects may require up to 6 rendering passes. Some type-specific settings of light sources can affect the performance, as well.

The article describes basic light optimization techniques.

Notice
Light and shadow settings for each surface can be monitored using the Surfaces tab of the Content Profiler tool.

Common Lighting Optimizations#

Some optimization approaches differ depending on the type of the light source. However, there are several common optimizations that can be applied to all light sources in the scene.

Disabling Shadows for Surfaces#

You can disable shadow rendering for some surfaces or materials. For example, it can be done for the farthest LOD surface (when the shadows don't matter).

To disable shadow rendering for a surface:

  1. In the World Hierarchy window, choose the node and go to the Surfaces section in the Node tab of the Parameters window.
  2. Select the required surfaces and toggle the Cast Proj and Omni Shadows parameter off. To disable shadows from the world light, toggle the Cast World Shadows parameter off.

To disable shadow rendering for a material:

  1. In the Materials Hierarchy window, choose the material and go to the Common tab of the Parameters window.
  2. Toggle the Cast Proj and Omni Shadow parameter off. To disable shadows from the World Light, toggle the Cast World Shadow parameter off.

Enabling Static Lighting and Shadows#

Dynamic lighting ensures that all shadows from moving light sources cast by moving objects are rendered correctly. This approach implies that geometry of your scene is rendered one more time each frame to calculate shadows for each Projected light source (or six more times — for each Omni). Using multiple dynamic lights in the scene and calculating shadows for them on the fly may cause a performance drop, especially when the scene contains complex geometry with lots of polygons. It can be a terrible waste of resources, when most objects and lights are static.

It’s better to avoid dynamic shadows and use baked ones for everything static wherever possible. You can replace dynamic Omni and Projected Light sources with static ones (shadows for them are precomputed and stored in depth textures).

Types of shadows to be rendered are defined by the light’s mode and shadow modes set for both lights and object surfaces.

Depending on your needs, you can choose to render baked shadows only, or combine rendering of both baked and dynamic ones. The table below shows all possible variants of shadow settings.

Thus, for a Dynamic light, shadows from all lit objects are rendered as dynamic.

For a Static light in Static shadow mode, only baked shadows from objects with Mixed shadow mode are rendered; dynamic shadows are not rendered at all.

For a Static light in Mixed shadow mode, both types of shadows are rendered: baked (from surfaces with Mixed shadow mode) and dynamic (from surfaces with Dynamic shadow mode).

Mixed mode implies that the dynamic shadow map is copied into the static depth texture and the result is rendered. If you select a higher resolution, the process of copying the shadow map can take time and affect performance. Therefore, 4K resolution in the Mixed shadow mode makes sense if the scene has more than 1.5 million triangles, otherwise Dynamic mode may be faster. Moreover, pay attention to video memory consumption, as a single 4K resolution depth texture for an omni light takes about 400 MB.

Notice
If shadows from static light sources are not rebaked automatically, use the Bake Lighting tool.

The World Light source works in a similar way, but it uses shadow cascades. In Dynamic mode, shadow cascades are built dynamically relative to the camera's position, while in Static, they are baked and have their area defined by the light source's position. Static mode of the World Light is suitable as a performance optimization technique for small-area ArchViz projects where shadow cascades can be divided into two sections: walkable area with high-resolution shadows (as they're observed closely) and non-walkable area with low-resolution shadows (as they're observed from a distance). Note that changing the time of day is not available in Static mode, as shadow cascades are baked.

Notice
The Cached Shadows video tutorial illustrates how to set and use dynamic and static shadows.

Using Shadow Masks#

A Shadow mask allows you to control rendering of shadows. You can specify which surfaces lit by a light source should cast shadows:

  1. For a light source, specify the Shadow mask: open the World Hierarchy window and select your light source. In the Shadow Mask section of the Node tab in the Parameters window, specify the shadow mask.

  2. For all surfaces that are lit by the light source and should cast shadows, specify the Shadow mask that matches the light source's Shadow mask (one bit at least).
  3. For all materials applied to such surfaces, specify the matching shadow mask as well.
Notice
An example of using shadow masks is available in the Content Optimization video tutorial.

Using Screen Space Shadows#

For all types of light sources, screen-space shadows can be rendered instead of the shadow maps at large distances. It improves the performance, as such shadows don't depend on complexity of the geometry.

Notice
Screen-space shadows depend on the screen resolution: the higher the resolution, the more accurate shadows are.

You can enable screen-space shadows in one of the following ways:

  • In the Menu Bar, choose Rendering -> Shadows -> Screen Space Shadows.
  • In the Menu Bar, choose Windows -> Settings and then go to the Shadows section. Here you can toggle the Screen Space Shadows parameter on.

You can also set up per-light screen space shadows in the type-specific tabs (Light World, Light Omni, etc.) of the Parameters window.

Screen Space Shadow Settings of Omni Light

Reducing Size of Light Source#

All Omni and Projected light sources are subject to a common deferred optimization technique — the Scissor Test: for each light source a scissor rectangle is found to define its bounds and, therefore, the area of its influence. The scissor rectangle defines the size of the render target for the current light source, since everything that falls outside that region is not affected by the light at the current moment.

Enable the Scissors visual helper or use the render_show_scissors 1 console command to enable visualization of the Scissor Test.

Scissor rectangles for Omni light sources

Therefore, the size of a light source significantly affects the performance: the larger the screen area where the illuminated surface is rendered, the lower the light performance is. So, keep the size as small as possible.

Engaging Interleaved Lights Rendering#

In this mode lighting is rendered during the Deferred pass in half resolution (1/4 of all pixels) with subsequent reconstruction of neighboring pixels using the data from previous frames, making it possible to reduce rendering load.

Interleaved Lights Rendering settings

For more details refer to the Interleaved Lights Rendering article.

Setting Up Visibility Distances#

You can control rendering of light sources and cast shadows by specifying the visibility distances.

The global settings for all light sources (World, Omni, Projected) can be specified in the Visibility Distances section of the Settings window.

Setting Limits For Transparent Objects#

Non-opaque geometry is shaded on the Forward pass of the Rendering Sequence. Since all light sources are applied to each transparent surface in a cycle, it is highly recommended to keep the number of lights affecting transparent objects as low as possible for optimal performance.

Global Lights Settings include Forward Per-Object Limits where you can limit the number of certain light sources that affect each transparent object at a time.

Rendering Lights on Water#

If your scene contains water object(s), you can disable rendering the light from the light source on them. It will significantly increase the performance.

  1. Select a light source in the World Hierarchy.

  2. In the Parameters window, go to the Render section and toggle the Water parameter off.

World Light#

The World Light source illuminates all objects that are positioned along the shadows visibility distance thus increasing the number of calculations of shadows. So it is recommended to keep the number of World Light objects in the scene as low as possible. For most purposes, other light sources (Projected Light, etc.) are more suitable in terms of project performance.

Shadow Distance Parameter

For the World Light, the Engine creates cascaded shadow maps (maximum 4 cascades). Each cascade requires a separate rendering pass.

4 Shadow Cascades

You can affect the performance by decreasing the number of the rendered cascades in the Parameters window (the Number of Cascades parameter). However, changing the number of cascades also affects the rendered image quality, so try to find a balance.

Omni Light#

Omni light sources emit light in all directions, which allows reproducing realistic shadow casting.

Omni Light in Scene

The Omni light source uses 6 cameras that generate shadow maps, so shadowing by this light source requires 6 rendering passes and can sufficiently decrease the performance. So, keep the number of such light sources as low as possible. For better performance, you can disable rendering of shadows created by the Omni light in certain directions or use Projected light sources instead of the Omni ones.

Rendering of shadows in certain directions can be disabled

However, there is a way to use a lot of Omni light sources in the scene without negative impact on the performance: you should disable shadows for them (not screen-space shadows). As the Engine uses tile rendering for the Omni lights with the Point shape and shadows disabled, they will be grouped and rendered in batches, decreasing the number of DIP calls and making Omni lights the fastest light sources in the scene.

The related settings are available in the Batching options:

This optimization enables you to engage big numbers of Omni lights with no significant performance drop.

Batching of 1024 Omni lights

You can also control rendering of Omni lights and cast shadows by specifying visibility distances for the light sources. When the camera is located at a given distance from the light source, it is turned off. The same can be specified for the cast shadows:

  1. Open the World Hierarchy window and select an Omni light source.
  2. In the Parameters window, specify the Distance Visibility Settings.

Projected Light#

Projected light sources cast light from a single point forming a light pyramid. Such light sources produces shadows that require only 1 rendering pass, so they are performance-cheap.

Projected Light in Scene

However, the influence of these light sources on performance can be also reduced by specifying visibility distances for the light sources and the cast shadows:

  1. Open the World Hierarchy window and select a Projected light source.
  2. In the Parameters window, specify the Distance Visibility Settings.

Voxel and Environment Probes#

The Voxel Probe light source provides static voxel lighting and shading on an object inside the Probe by using a prebaked 3D lighting map. Voxel Probe is a required object for baking indirect lighting from light sources in static mode.

Notice
Resolution of a 3D lighting map that the Voxel Probe projects, has no influence on performance. Therefore, you can use any resolution you want.

Using a Voxel Probe as an inset inside another Voxel Probe significantly decreases the performance. Moreover, if you add several nested Voxel Probe objects with coinciding size, the visual result will be the same as if you add a single Voxel Probe. However, the performance will drop. So, if possible, try to avoid such situations.

The main setting of Voxel Probe that significantly decreases performance is Cubic Filtering. Disable it if the linear filtering for ambient lighting is enough.

One more setting that affects the performance is Reflections. When toggled on, Voxel Probe is used for both ambient lighting and reflections. We recommend you to use Environment Probe for reflections simulation.

The Environment Probe light source provides ambient lighting and reflections on an object inside the Probe by using a cubemap. However, the main purpose of Environment Probe is reflection rendering. For lighting, we recommend using Voxel Probe: just toggle the Indirect Diffuse lighting off in the Parameters window.

Notice
At that, the Reflections should be toggled off for Voxel Probe.

This approach allows improving the application performance without loss of visual quality: using both the Environment and Voxel Probes for ambient lighting and reflections rarely gives notable visual improvement.

Voxel Probe Ambient Light + Environment Probe Reflections

Fake Lighting#

When you need only the visualization of a light source without illumination, you can use one of the tricks described below.

Using Billboards#

Billboards can be used to simulate small light sources observed from large distances. In such cases, only visualization of light sources matters. For example, you can use Billboards for takeoff runway lights. They don't produce any light, but look like real lights.

Billboards Used for Takeoff Runway Lights

To create Billboard that replaces a real light source, perform the following:

  1. Add a Billboard object to the scene by choosing Create -> Billboards -> Base in the Menu Bar and place it somewhere in the world.

  2. Assign a material inherited from the billboards_base material.
  3. Specify the following settings for this material:

    1. In the Common tab, set the blending Preset to Additive and toggle the Depth Write parameter off to avoid obstructing objects behind the Billboard.

    2. In the States tab, disable writing into the Deferred Buffers and enable the following states:

      • Emission to provide the emission effect by using the corresponding texture.
      • Geometry Inflation to limit the minimum Billboard screen size to a fixed value and, therefore, to provide visibility from far distances.
      • Soft Interaction to make interaction of the Billboard with other objects in the scene softer and avoid artifacts.

    3. In the Textures tab, specify the Diffuse and Emission textures.

    4. In the Parameters window, specify the following values:

      • Set the Diffuse color multiplier to black, so that Billboard become fully transparent.
      • Increase the Emission Scale to make Billboard brighter.
      • Increase the Geometry Parameters to scale the size of Billboard and limit the minimum size of Billboard.
      • Correct the Soft Interaction value, if necessary.

As a result, you get the Billboard that can be used to simulate a small light source at far distances. You can add any required number of Billboards to the existing Billboard object: in the Parameters window, select the created Billboard in the list and click Add.

Lights Simulated by Billboards

Using Volumetric Objects#

Volumetric objects can be used to simulate visible light volumes instead of using real light sources. Such objects should be used when you don't need illumination. For example, by using Volumetric objects, you can create light spheres, beams, or volumes, imitate sun beams falling into a room through openings, and so on.

Light sphere and beam simulated instead of real light source

To create such light volumes, perform the following:

  1. Add the Volume Sphere object by choosing Create -> Volume -> Sphere Light in the Menu Bar and make it a child of the node that should emit the light.

  2. In the Volume Sphere section of the Parameters window, change the size of the sphere to 0.15.
  3. In the Node tab of the Parameters window, set coordinates of the volume sphere to the parent node and then slightly correct the sphere position, so that it looks realistic.

  4. Assign a material inherited from the volume_light_base base material and specify the required values in the Parameters tab. For example, you can set the color of the light sphere and scale the density of the light.

  5. Add the Volume Projected object by choosing Create -> Volume -> Projected in the Menu Bar and make it a child of the node that should emit the light.

  6. In the Node tab of the Parameters window, reset the position and rotation of the Volume Projected to the parent node ones.

  7. In the Volume Projected section of the Parameters window, specify the required parameters of the light beam. For example, change its size, radius, field of view, and step.

  8. Assign a material inherited from the volume_proj_base base material.
  9. In the Parameters window of the material, set the color of the light beam the same as for the Volume Sphere and decrease the diffuse scale to 0.5 to make the color less bright.

As a result, you get a light sphere and a beam imitating the real light source.

Light simulated by Volume Sphere and Volume Proj objects
Last update: 2023-06-23
Build: ()