[Unity] Chapter 1: illumination textures and light effects, Chapter 2 unity
Classification: Unity, C #, VS2015
Date created: 1. Introduction
In Unity 5, Lighting is a technology that enhances the illumination and shadow effects of scenarios. It can make static scenarios look more real, rich, and stereoscopic with a small amount of performance consumption, it can also process dynamic objects.
In earlier versions, Unity 4 can only process "static" objects and "dynamic" objects separately, called Lightmapping. However, lightmapping cannot be used to process "dynamic" illumination in real time. In Unity 5, lightmapping-related functions are reintegrated into the Unity engine and opened the setting Window through Window> Lighting. In the Lighting Window, developers only need simple operations, you can create a smooth, real, and unexpected light and shadow effect.
Light Probes is a technology that integrates "dynamic objects" into "static scenarios" during runtime. It can solve the problem of "dynamic" illumination in real time. The basic principle is: first place some sampling points in the scene space to collect the surrounding light and shade information, and then perform interpolation operations on the neighboring sampling points of the dynamic object at runtime, and apply the interpolation results to dynamic objects. Because interpolation does not consume too much performance, this method can achieve real-time fusion between dynamic game objects and static scenarios without causing huge consumption of memory resources. Ii. Global Illumination (GI)
Before using the functions provided by Unity 5 to implement the illumination textures and light effects, you must first master two basic concepts: GI and Realtime GI.
GI (Global Illumination) refers to the light (indirect light) that is reflected to the surface of other models after Model A is illuminated by light in the Global coordinate system ), instead of directly illuminating Model A with A light source. For example, sunlight shining on the red sofa will cause the red light to rebound to the wall behind it, so that the wall will also look pale red. In another example, the sun shines in the room with only one small mouth at the top, which causes other parts of the room to be illuminated by the light from the bounce (reflection) of the object.
It is a scenario that applies the Global Illumination (GI) effect. In this figure, the rebound light (indirect light) makes the entire scenario look bright, gorgeous, and more realistic.
Traditional film technology generally only has direct light (such as direct light, spot light ,...... When simulating the effect of indirect light in real time, the simulation of indirect light requires a lot of computing, which will greatly reduce the playing performance of the film, therefore, in actual film production, we generally do this in two steps: early shooting and post-production.
In Unity, this kind of work similar to early filming is called preprocessing. Preprocessing is carried out in the Unity Editor, mainly for processing static objects. This technology is called Baked GI (also called Baked Lightmaps), that is, to process indirect light in advance (Bake, the goal of baking is to mark the scene as a Static object in advance, and the post-production work of a movie is called Light Probes in Unity, that is, add some lighting points (sampling points) to the scene, and then use the rebound (indirect light) Effect of the lighting points to illuminate the surrounding area during operation, in this way, the entire scenario looks bright, gorgeous, and pleasing to the eye.
In versions earlier than Unity 5.0, this technology that combines Baked GI and Light Probes is the Global Illumination (GI), also known as lightmaps ). In other words, the static objects in the scenario are "preprocessed" in the Unity editing state, and then the Light Probes is used for post-processing at runtime. In this way, the game running scene looks bright, gorgeous, and elegant. Iii. Real-time GI)
In addition to the global illumination technology (GI), Unity has provided a new technology called "Precomputed Realtime GI" since 5.0, the principle is similar to the Baked GI technology provided in earlier versions 5.0. However, although the technology is still targeted at static objects (only for processing objects identified as static), the main difference between it and Baked GI is: the pre-processing results through "Precomputed Realtime GI" can also be directly used for runtime Dynamic Object lighting. The implementation principle is: Unity first sets the information (location, direction, color ,...... And so on. In this way, you can directly use the preprocessing information to lighting dynamic objects. In other words, in Unity 5, you only need to use the "Realtime GI" technology to greatly improve the lighting rendering processing performance during running, instead of using Baked GI + Light Probes for combination. Iv. Conclusion
In short, when global lighting is implemented to provide time effects, either use method 1 ("Baked GI" + "Light Probes" technology provided by earlier versions of Unity 5 ), either use method 2 (the "Precomputed Realtime GI" technology provided since Unity 5.0 ). However, methods 1 and 2 cannot be used at the same time. Otherwise, the memory will soon be eaten up, leading to abnormal automatic shutdown (this should be a new bug, it is estimated that later versions will solve this problem ).
Note: Both "Baked GI" and "Precomputed Realtime GI" are for "static" objects, that is to say, you must first mark the baked object as "Static" before lighting preprocessing. For dynamic objects, if static objects are created using the "Baked GI" technology instead of the "Precomputed Realtime GI" technology, you can also use the pre-placed lighting point to lighting dynamic objects through "Light Probes" during running. If you use the "Precomputed Realtime GI" technology to bake static objects, because it can lighting dynamic objects directly at runtime, in this case, do not use "Light Probes.