The world of lighting in Unity has nothing but exciting constructs and I am beyond thrilled to share them starting with this series of cinematography and lighting.
Light has a special trait of reflection which makes it extremely complex to calculate and mimic. Plus, when it has to happen while the game is being played without any lag takes it a notch further.
In Unity, there is a term called global Illumination, which consists of multiple techniques and mathematical models that help simulating lighting behavior that resembles to the real lighting.
The GI provides following 4 broad tools for its proper execution.
- Direct Lighting
- Indirect Lighting
- Direct shadows for Bounce Lighting
- Indirect shadows for Bounce Lighting
It is very important to keep in mind that global illumination is a concept about how light bounces between surfaces and not about it arriving from a light source.
In order to calculate the shading of a game object, Unity needs to know the following three values of a given light source.
[ Depending on the render pipeline, the lighting inspector would display different options.]
The broadest categorization of lighting is real-time lighting and baked (Pre-computed) lighting. When these are two combined, we get an immersive lighting experience.
- Types of Light
There are 4 types of lights to choose the behavior of a light.
Please checkout the link here for elaborate explanation.
Types of light
This page describes the effects of the Type property on a Light component. You can use the Type property to choose how…
2. Mode of Light
There are three distinct modes of any light possible in Unity. However, there are constraints of their availability based on the selection of GI of the project.
Realtime light illumination is computed every frame and Unity does not compute any of its effects beforehand.
Since they are calculated at runtime, they can be altered to create effects such as flickering bulbs or a player’s torch, etc.
These lights can cast shadows up to the shadow distance set in the quality section. [The distance is calculated from the location of the main camera. The bigger the number, the more distance the light would cast its shadow]
There are two significant limitation of real time lights.
— They are expensive to calculate if the scene geometry is complex and the target platform’s hardware is low-end.
— They do not contribute to overall indirect lighting in the scene. Therefore, their shadows are completely black. So, it is a hinderance in creating a realistic scene.
Unity performs the calculations for Baked Lights in the Unity Editor, and saves the results to disk as lighting data. This process is called baking.
At runtime, Unity loads the baked lighting data, and uses it to light the scene. Because the complex calculations are performed in advance, Baked Lights reduce shading cost at runtime, and reduce the rendering cost of shadows.
So, their best application is to lit up geometry and areas that will not be moving while the player moves or they are far distant from the player or a geometry whose size does not make sense logically to be added to real time contribution.
There are a few significant limitation of Baked lights.
— Moving objects in the game do not receive light or shadow from baked lights.
— The lighting mode in the project must be set to baked GI. If it changes to the real time GI, baked lights in the project will by default set their mode to realtime lights.
The prime requirement for baked lighting to work in your project is to mark immovable geometry as static. Only static objects receive lights and shadow from baked lights.
As seen in the images above, the cube has lights on it from all baked light sources.
If I would move this cube a little away from its current spot, the shadow generated for it would not move.
To remap the shadow, the lightmap has to be regenerated.
Mixed, as the same suggests, divides calculation. Some of it happens beforehand and some of it happens during the runtime.
You can use Mixed Lights to combine dynamic shadows with baked lighting from the same light source, or when you want a light to contribute direct realtime lighting and baked indirect lighting.
As you can see in this footage, the red and blue lights are casting shadows as well as lighting up the surround areas. But the player is a dynamic object whereas the remaining parts are static.
This is what you would be mostly interested to achieve on any occasion. A light shall lit up the area as well behave like a real light :)
There is a significant limitation to Mixed lights regarding memory usage.
So far, we have seen just the tip of the iceberg of entire lighting system in Unity.
I’ll be taking through each of them soon in different blogs :)
Thank you very much