This page has been translated automatically.
Unigine Basics
1. Introduction
2. Managing Virtual Worlds
3. Preparing 3D Models
4. Materials
6. Implementing Application Logic
7. Making Cutscenes and Recording Videos
8. Preparing Your Project for Release
9. Physics
10. Optimization Basics
11. PROJECT2: First-Person Shooter
12. PROJECT3: Third-Person Cross-Country Arcade Racing Game
13. PROJECT4: VR Application With Simple Interaction

Light Sources

World Light
#

World Light is an infinitely remote light source casting orthographically projected beams onto the scene. The shadows cast by this light are parallel, which provides a realistic simulation of celestial bodies such as the Sun and Moon. World Light also takes part in simulation of atmospheric scattering.

Omni Light
#

Omni Light is a point source emitting light in all directions and realistically reproducing cast shadows. This type of light serves to simulate light sources with bright center and equal roll-off of intensity. Omni Light proves useful for general lighting purposes in indoor scenes because of its nondirectional qualities. In addition, Omni Light has many shapes and therefore can be used to create a variety of lights for indoor and outdoor lighting.

Projected Light
#

Projected Light is a light source that casts light from a single point forming a focused beam aimed in a specific direction. This type of light is visualized in a form of a pyramid. Due to its form, it is versatile and can be conveniently used to simulate the numerous light emitting sources: for example, car headlights, flash light, or street lamps.

Area Lights
#

By default, Omni and Projected light sources are represented by a point emitting light. They both also have additional parameters that specify the light shape (sphere, capsule or box). Local light sources provide wider light spots and correct specular highlights on geometry.

Emissive Objects
#

It is also possible to make almost any geometry emit light (e.g. to make neon signs or a glowing electric stove). This is done using Emission, and materials have a corresponding set of parameters that allow you to set the glow brightness and color. By default, the glow from such objects does not affect the environment. However, it is possible to bake lighting from an emissive object to GI (we'll review this in detail a bit later) or calculate it in real time with Screen-Space GI.

How Shadows Are Drawn and Why Too Many Sources May Cause Performance Drop
#

Now we know what types of light sources are available and we want to hang the Sun (World Light) outside the window, light the room with a lot of spotlights (Projected Light), and a lot of bulbs (Omni Light), or even a garland! But, it is said that a large number of light sources can be very hard on performance, and shadows are the culprit! To understand why regular shadows are so expensive, we need to understand how they are drawn.

Shadows in engines (and UNIGINE is no exception here) are drawn using the traditional Shadow Mapping method, which allows you to define lighted and darkened areas for each light source. This method is based on the use of Z-buffer (depth buffer). First, we draw the scene into the Z-buffer from the point of view of the light source to define the pixels visible from this point and the distances to them — thus a special buffer (shadow map) is created, which is a two-dimensional texture. Then, when the scene is drawn from the observer's point of view, the texture coordinates are compared with the shadow map: if this comparison says that the corresponding pixel is invisible from the point of view of the light source and therefore should be shaded, it is painted with a dark color.

This is how it's done for a directional Projected source, but if we have an Omni point source (an ordinary light bulb, for example), then instead of one depth buffer we have to draw a whole cube map (6 depth buffers, one for each side of the cube surrounding the light source). Thus, one bulb requires drawing the scene again, albeit highly simplified, but 6 more times! And this all is for one frame! Now it becomes clear why a large number of light sources significantly increases the load on the GPU, so all sorts of tricks are used to minimize the number of sources for which shadows are actually calculated. Depending on the scene type, different approaches are used.

Last update: 2024-01-18
Build: ()