This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
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
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
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.

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.

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 (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 depends 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 Shadows Settings of Omni Light

Reducing Size of Light Source#

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.

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.

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.

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 without shadows, 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.

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 voxel probes as insets inside other voxel probes significantly decreases the performance. Moreover, if you add several nested voxel probes 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 the 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, the voxel probe is used for both ambient lighting and reflections. We recommend you to use Environment Probes 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 the environment probe is reflections rendering. For lighting, we recommend using Voxel Probes: just toggle the Ambient lighting off in the Parameters window.

Notice
At that, the Reflections should be toggled off for the 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 a billboard that replaces the 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 the billboard become fully transparent.
      • Increase the Emission Scale to make the billboard brighter.
      • Increase the Geometry Parameters to scale the size of the billboard and limit the minimum size of the 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 a 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 a 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, set the position and rotation of the volume projected to the parent node.

  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: 2019-08-16
Build: ()