Lights are objects in a scene used to illuminate other objects so that the colour, texture, and shape of these objects can be rendered.
Types of Light Sources
Lights can be used in real-time to produce dynamic shadows and reflections or be baked into lightmaps. Baked light produces higher quality lighting with lower computation in runtime. Real-time lighting creates real-time shadows and can be interacted with while the game is running.
We can change the entire theme of a scene by varying or changing the lights of that scene. A scene can have multiple types of light sources. Each light source can have different characteristics as well.
To create multiple types of light behaviour, Unity has various interesting options for light sources.
Directional Light is the most basic light source in Unity. It is automatically added when a new scene is created.
This light simulates light coming from a source at an infinitely far distance so that all the light rays run parallel with each other. Therefore, all objects cast shadows in the same direction. The position of this light source is not important as light intensity is the same all across the scene.
This light source is useful when simulating light coming from the sun or moon. It can also be used to create sharp shadows as it creates a uniform shadow everywhere.
Point Lights originate from a single point and send rays out to everything around it in equal intensity. Light is cast equally in all directions with a decrease in strength proportional to distance following the inverse square law.
Since the source is a point, it projects shadows depending on the object's position with respect to the source. The shadow is projected in the direction opposite from the light source towards the object. This type of light is useful when simulating light sources like fire, candles, bulbs etc.
A Spot Light is a source of light that originates from a point, but unlike the point light, there is a constraint in the angle at which light is cast. This constraint creates a cone-like shape in the path of light.
The intensity of light decreases with the increase of distance, similar to a point light. It can simulate light sources like torches, car headlights, street lamps, etc., where light is projected in a single direction from a point source.
An Area Light is a type of light emitted from the surface of a shape. Two types of shapes are available, Rectangular and Disc. This light gives a soft shadow as light spreads uniformly in all directions.
This light is not available in runtime as it is computationally intensive. It should be baked into lightmaps. It can be used to create light shining from a house window at night, light from televisions, sunlight coming through the window inside a room, flush lights, etc.
Global Environment Light
Try removing all light sources from a scene, and you will notice that scene is darker, but objects are still clearly visible in colour. This is due to the presence of ambient environment lighting. There is ambient light in the scene by default, with the skybox as the source. You can find its setting in the Lighting window inside the Environment tab.
Environment light is necessary because it provides ambient light in places where no other light source can reach. Without ambient light, the part of scenes with no direct light will be completely dark. This can be unrealistic as, in real life, those areas are still illuminated by bouncing light.
Apart from light sources, light can also be produced from objects with emission materials. These can make an object or a part of the object glow in different colours. It can also create light-emitting particles, trails, etc., to create sparks, lighting and explosions.
So, these are common light sources in Unity. Experimenting with various light sources is important because choosing the appropriate light source is integral in setting the mood of a scene.
See you in the next one!