UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1

Lighting

Different lighting can transform your scene and give it completely different looks. The right lighting is of big importance, as it does not only illuminates the scene, it also creates some specific atmosphere. To help you choose the way your scene should be lit, below is a general description of lighting approaches that are widely used now.

Broadly speaking, lighting techniques can be divided by various parameters, for example, there is per-pixel and vertex lighting and static and dynamic lighting. However, the per-vertex one is out of fashion now, as it requires high-tessellated models and gives accent to edges between faces. So, we will focus on differences and usefulness of static and dynamic lighting.

Precomputed and Dynamic Lighting

Though games are gradually progressing towards implementing fully dynamic lighting, developers mostly use combined approaches to lighting. Each of the technologies has its own advantages and disadvantages, stemming from processor and graphics performance limitations.

Precomputed lighting methods introduce an efficient and utile solution for lighting of relatively static scenes. They allow to offload most of lighting computations to a precomputation step, leaving only simple texture lookups to be performed at the rendering time. But these methods still only roughly simulate the lighting for the moving objects entering the scene and sometimes lack physical accuracy registered by the eye. But it could be compensated by the number of light sources, for example, thus allowing to obtain the necessary balance in the project.

In its turn, dynamic lighting provides real-time lighting calculation. This advanced solution looks very realistic, as it can illuminate dynamic objects, light sources can be themselves moving and changing (for example, turned on and off), and there can be several of them. Here is a short list of features provided by this type of lighting:

  • Changing of light source properties: moving, turning on and off, changing colors, and so on.
  • Accounts for real-time variations, such as change in virtual environment state, character position and camera movement.
  • Quicker level creation: the designer needs only to find the right places for light sources, and there is no need to wait for hours to see final results.
  • Advanced shading can be used to the full extent.

However, dynamic lighting also has some constraints:

  • Rendering lighting in run time is a very expensive operation in terms of performance.
  • Each light source is usually rendered in a separate pass, so not too many light sources can be used in one scene, as it will substantially slow down the rendering process (say, using three lights means almost poly count * 3). Hence, the level designer has to use some tricks like approximating several fake light sources with one real.
    Notice
    There are some optimization methods, which reduce rendered poly count per light pass, for example, unlit objects are skipped. Also, scissoring and clip planes are used to speed up rendering process.
  • There is only a limited set of light source types.
Last update: 2017-07-03