Unity—lightmap,lightprobes,reflection probes

Refer to the reprint source, unity global official website & Maizi College Wei Zhi & Json_c ;

       What is Global Illumination--Global Illumination /GI?

       What is a light map--LightMap?

       What is Light Probe--Light Probe?

       What is a reflection probe--Reflection Probe?

 

 

 

1. Global Illumination

 

     : Global Illumination (GI) is a system for simulating how light bounces off surfaces to other surfaces (indirect light), not just light that hits the surface directly from a light source (direct light).

 

         Instead, the lighting color calculation of an object is limited to itself, and the light that hits the surface directly from the light source (direct light) is local illumination.

 

A classic example is "color bleeding," where sunlight hitting a red sofa, for example, causes a red light to bounce off the wall behind it. Another is that when sunlight hits the floor at the opening of the cave and bounces inside, the inner part of the cave is also illuminated.

 

        It cannot achieve realistic physical lighting in the true sense. It is very challenging and expensive to accurately simulate global illumination. Because of this, modern games will pre-process these calculations to a certain extent, not when the game is executed. real-time operations.

 

Traditionally, video games and other real-time graphics applications were limited to direct lighting, and the computations required for indirect lighting were too slow, so they could only be used in non-real-time scenes such as CG animated films. The game approach to this limitation is to calculate indirect light, which can only be used on objects and surfaces known in advance, and cannot be moved (static). This way, slow computations can be done ahead of time, but since objects don't move, indirect lights precomputed in this way are still correct at runtime. Unity supports this technique called Baked GI (also known as Baked Lightmaps), named after "baking" - the process by which indirect light is precomputed and stored (baking). In addition to indirect light, Baked GI can also utilize more computational time to produce more realistic soft shadows from area lights and indirect light than can usually be achieved with real-time techniques.

 

         Both baked GI and precomputed realtime GI have limitations, only static objects can be included in baked/precomputed - so moving objects cannot reflect light onto other objects and vice versa. However, they could still use light detectors to pick up bounced light from static objects. Light probes are the positions in the scene where the light (probe) is measured during bake/precompute, then at runtime, the values ​​from the probe are used to approximate indirect light for non-static objects that are closest to any given moment So for example a red sphere rolled up next to a white wall won't seep its color into the wall, while a white sphere next to a red wall might absorb red color from the wall via a light detector.

 

        Implementation composition: real-time updateable, lightmap+lightprobe+reflectionprobe+self-illuminating material

 

 Broadly speaking, Unity's global illumination is "real-time" or "pre-computed", and in some cases the two methods can be combined to illuminate a more realistic scene.

 

REALTIME LIGHTING

 

By default, Unity's light sources (direct light sources, projection lights, point light sources) are all real-time, which means that these light sources will illuminate the scene and update at the frequency of each frame, because the light source can be in the scene. Moving objects, scene lighting updates are real-time, you can see the changes in the game window and scene window.

 

realtime_0.jpg

 

Effects of real-time lighting: Note that the shadows are completely black because there are no reflected light sources, and only object surfaces within the range of the projected light cone have light effects.

 

Real-time lighting is the most basic method of illuminating objects in the scene. It is used to illuminate characters and moving objects. Unfortunately, the light in Unity's real-time lighting does not reflect, so we imported the global illumination system and enabled the preset. The computing technology is all to represent a more realistic scene.

 

 

 

 

 

 

 

 

 

2. What is light mapping?

 

     : For some static objects and lights, pre-computed and stored, without real-time calculation, the result of this process is called baking.baking is a lightmapping texture. ----For static objects with stable lighting.

 

Dynamic changes in light mapping?

 

 

 

 

 

BAKEDGI LIGHTING

 

 

 

When baking a lightmap (Lightmap), the static objects in the scene will calculate a map result based on the influence of light, and superimpose the lighting effect on the scene object:

 

 

 

lightmap.jpg

 

 

 

Left: The result of a simple lightmap scene, right: A lightmap generated by Unity (shadow and light source information is included in the calculation)

 

 

 

These "lightmaps" can contain direct light sources projected on the surface of objects in the scene, as well as "indirect light sources" reflected between different objects. Such lightmaps can be described as colors through the shader on the object's material. Surface information (Albedo) and bump (Normals) information.

 

 

 

The texture generated by the baked lighting cannot be changed when the game is running, so it is defined as Static. Although the light source calculation can continue to be superimposed on this layer of texture, the two cannot be interacted with each other. Usually we use this lighting method to make low-end mobile phones run smoothly and solve the performance problem of light running in the game.

 

 

 

 

 

PRECOMPUTED REALTIME GI LIGHTING

 

 

 

Although traditional static lightmaps cannot change the lighting conditions of the scene while the game is running, the pre-computed real-time global illumination system can help us calculate complex scene light interactions in real time. Through this method, we can create a dim environment with rich The global illumination reflection, and reflect the changes of the light source in real time. It is like making a sundial, the position and color of the shadow will change with the movement of the light source, which cannot be achieved in the original baked lighting system.

 

 

 

timeofdaycycle400.gif

 

 

 

An example of a sundial rendered with GI

 

 

 

In order to achieve these effects at a reasonable frame rate, we need to "pre-calculate" a bunch of long digital data before real-time calculation. The pre-calculation is responsible for calculating the complex behavior of light during the game. It can be used when the time is empty. To perform a computation, we call it an "offline" operation.

 

PRE-LIGHTSETTINGS

 

The default bake mode for each light in Unity is "Realtime", which means these lights will still illuminate your scene, and Unity's precomputed GI system handles indirect lighting. But if the default baking mode is "Baked", then these lights will be processed by Unity's baked GI system for direct and indirect light sources, and the resulting lightmaps cannot be changed during execution once they are attached to the scene.

 

lightbakingmode_2.png

 

A point light with the bake mode set to "Realtime"

 

If the baking mode is "Mixed", the static objects in the scene will be used for calculation by the baked GI. However, unlike the "Baked" mode, the mixed mode lights will still continue to calculate the real-time light source to the non-static objects, which is very important for You want to bake a static environment into lightmaps, but at the same time want the same light to be helpful for calculating shadows for a moving character.

 

GI cache (GI CACHE)

 

Whether it is a baking or precomputing system, Unity will "cache" the lighting data of the scene to the "GI cache", and will try to reuse the data during calculation to save time. Your changes to the scene will affect the reuse of this data. How much.

 

If you want to clear this cache, you can clear it from (Preference->GICache->Clear Cache). After clearing, all data must be recalculated, so it will take some time. In some cases, you may need to reduce the file space. Size (eg moving the project to another computer) is helpful.

 

 

 

 

 

 

 

 Unity5's GI strategy:

 

 

 

 

 

 

 

 

Overview:

       Click Window > Lighting > Settings and the Lighting window will pop up, which is the window for setting global illumination.

The Lighting window is divided into three areas:

1. Scene: Settings apply to the entire scene instead of individual GameObjects. These settings control lighting effects and refine selections.

2. Global Maps: Displays the GI lighting process generated by all lightmap asset files.

3. Object Maps: Preview the currently selected GameObject's GI lightmap texture (including shadow masks).

      There is an Auto Generate below, check it, Unity will automatically update the Lightmap data, but the update process is very time-consuming, so it is not recommended to check Auto Generate (it should be checked faster) . You can manually click Generate Lighting to bake. (note that unity will only bake

Check the GameObject of Lightmap Static, so before baking, first select Lightmap Static in the Static at the top of the Inspector panel)

       

 

 

Scene Tab:

1、Environment

       

Property:

Function:

Skybox Material

skybox material

Sun Source

Set a directional light as the sun in the scene. If set to None, unity will use the brightest directional light as the sun (the sun: no matter how far you set it, the light will shine on the scene)

Environment Lighting

Ambient light settings, which affect light from distant environments

Source

Diffuse ambient light (ambient light, the light of the environment around the scene), the skybox is used as the ambient light by default.

Color

Use a certain color as the ambient light.

    Gradient // gradient

Choose a color for sky, horizon and ground respectively, and mix out an ambient light.

    Skybox

skybox as ambient light,

Intensity Multiplier//Light intensity

The brightness of the ambient light, the range is 0-8, the default is 1.

Ambient Mode //Ambient Mode

Specifies the mode of the GI in the scene. ambient: ambient, ambient; when MixedLighting RealtimeLighting is checked, enabled;

    Realtime

实时更新;Choose Realtime if you want the ambient light in the Scene to be calculated and updated in real time.

                Choose Realtime if you want the ambient light/ambient light in the scene to be simulated in real time and updated in real time.

    Baked

Baked (precompute the lights in the scene); Choose Baked if you want the ambient light to be precomputed and set into the Scene at run time.

                 If you want the ambient light to be precomputed and imported into the scene at Run time, select Baked

Environment Reflections

Sets reflection parameters globally; These settings control global settings involved in Reflection Probe baking, and settings affecting global reflections.

Controls global settings related to reflection probe baking and affects global reflections;

Source

reflector.

    Skybox

The skybox acts as a reflection source.

    Custom

Use a cube map as the reflection source.

Compression//Compression

Whether the reflection map is compressed.

    Auto

Compress if it suits you.

    Uncompressed

Not compressed.

    Compressed

compression

Intensity Multiplier

The intensity of reflected light.

Bounces//Bounces

The number of times a beam of light is reflected.

 

 

          

2、Realtime Lighting

Property: Function:
Realtime Global Illumination Whether to enable real-time panoramic lighting.

                                                                                                                            

 

3、Mixed Lighting

      :混合光是由那些具有自身模式属性的光元件/light components被设置混合。

Mixed Lights 可以改变他们在运行期间的Transform/坐标&Visual Properties/光学属性(如颜色,强度),但有很多必须的限制。他们点亮静态和动态的物体,总是提供直接光源,并有选择的提供反射光。

被Mixed Lights点亮的动态物体总是能在其它动态物体上产生实时阴影。

      同一场场景中的所有Mixed Lights使用同一Mixed Lighting Mode。

 a.Baked Indirect mode--间接光烘焙模式

         Only indirect lighting is precomputed

           最适用于中端PC和高端手机。此模式,只预先计算间接光,不预先计算阴影,阴影由Shadow Distance中实时 //Shadows are fully real-time within the Shadow Distance (menu: Edit > Project Settings > Quality > Shadows).

           换句话说, 就像实时光加上间接光照,但不含Shadow Distance外的阴影。                      //Realtime Lights with additional indirect lighting, but with no shadows beyond the Shadow Distance.

          比如大雾天的室外,连接房间的走廊,这些可以用雾遮盖远处缺失的阴影或所有阴影都在shadow distance内.

b.ShadowMask mode

          Indirect lighting and direct occlusion are precomputed

          You also need to select the desired Shadowmask mode to use from the Quality Settings (menu: Edit > Project Settings > Quality):

  • Shadowmask: Static GameObjects that cast shadows always use baked shadows.
  • Distance Shadowmask: Unity uses real-time shadows up to the Shadow Distance, and baked shadows beyond.

c.Subtractive mode

         All light paths are precomputed

         Best for low-end gear.

         The only one of the mixed lighting modes that bakes direct light into lightmaps and discards the information for compositing static/dynamic shadows in the first two modes.

 

 

 

                                                                           

Property: Function:
Baked Global Illumination Whether to use baked global illumination.
Lighting Mode

Decide how mixed lights and shadows coexist with objects in the scene;

Modifying the Light Mode requires re-baking. Of course, if Auto Generate is checked, it is not necessary. Otherwise, click Generate Lighting.

Realtime Shadow Color The color of the real-time shadow. 

                                                                                                             

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324550184&siteId=291194637