-
Lighting in Unity 5 is more fully featured than in any previous versions of Unity.
-
The lighting pipeline now includes Realtime Global Illumination in addition to traditional Baked lightmapping.
-
This, combined with the physically based Standard Shader, gives you more power and versatility to easily light more complex scenes.
-
One of the key differences in the lighting pipeline is Unity’s new Realtime Global Illumination or “GI”.
-
GI is available for all lights working in the scene.
-
This means that all lights in the scene affect the objects within range with indirect illumination as well as direct illumination.
-
Direct Illumination comes from the light shining on the objects in the scene.
-
Indirect Illumination, however, is the light reflected, or bounced off of, other surfaces in the scene.
-
Direct and Indirect light will blend together to create a much more realistic look.
-
A new scene in Unity comes with a default skybox
-
and a default directional light that is aligned with the skybox, in addition to the default main camera.
-
Each scene also contains ambient light, which can be comprised of a number of factors.
-
In the Lighting panel’s Scene tab, we have options for ambient light
-
with a choice of skybox colour
-
a user defined gradient of 3 colours
-
or a single colour.
-
This means that any object added to the scene will receive this light, unless values are set to black.
-
When lighting scenes in Unity 5, we can work with real-time lighting
-
baked lighting or a mixture of both approaches.
-
Real-time lighting is more easily modified at runtime, but comes at a cost to performance.
-
Baked lighting pre-calculates much more detailed lighting information
-
and saves it to a lightmap - a texture on disk.
-
This lightmap information is read from disk at runtime
-
and this approach avoids the need to do calculations later, saving performance at runtime.
-
Using Baked lighting exclusively would be more appropriate for devices with lower performance capabilities,
-
such as mobile platforms.
-
Lights can be switched between Realtime, Baked and Mixed lighting on a per light basis.
-
The light mapping system can work in either "Iterative" mode, or "On Demand" mode.
-
Iterative mode will bake any lighting changes in the background as you edit properties.
-
On Demand mode will only preview changes once the "Bake" button in the Lighting panel has been selected
-
in a similar way to how previous versions of Unity functioned with baked lighting.
-
In this scene, we have a directional light coming in through the sky light at the top
-
casting shadows that you can see around the chamber area from the furniture inside.
-
This light contributes to the illumination for the rest of the scene
-
because it bounces from the surfaces it lights directly onto others.
-
If I decrease the intensity of this light, you can see the illumination of the room decreases also.
-
Likewise if we simply rotate the directional light
-
you can see that as it has moved to directly light a different part of the scene
-
we can see the light now bounces to illuminate the ceiling more effectively.
-
The rest of the room is lit with Point and Spot lights as well as Emissive surfaces.
-
This means that we can give our scene a very different feel by changing some of the colour values in the contributing lights.
-
As these elements are part of the realtime lightmapping
-
we can also control these lights at runtime using coding or animation.
-
This allows us to create complex changes in mood during our games and projects.
-
As the new standard shader can mimic a wide array of physical surfaces in your projects
-
you can expect certain materials to have different amounts of reflectivity as far as light is concerned
-
To help balance this, you can either adjust Bounce Intensity on a per light basis
-
or globally using the settings in the Lighting Panel.
-
Albedo scale lets you artificially increase the potential bounce for dark scenes.
-
Indirect scale allows you to boost or decrease indirect light in the scene for realtime and baked lightmaps.
-
Direct scale allows you to boost the light in baked lightmaps.
-
AO Exponent controls the amount of Ambient Occlusion and also only applies to baked lightmaps
-
allowing you to darken bounced lighting in occluded areas.
-
In addition to lights, we can use Emissive surfaces to contribute to lighting.
-
In this scene we can see a lit panel around the ceiling of the room
-
and various strips of geometry in the wall panels
-
all of these utilise the standard shader’s Emissive property
-
You can see that by adjusting the emission scale - the float value next to the property -
-
and adding a touch of colour, we can vastly change the mood of our scene.
-
The final contributory factor in lighting your Unity scenes are Probes.
-
There are now two types of Probe in Unity - Light and Reflection probes.
-
Light probes function in much the same way as in previous versions of Unity,
-
acting as a grid of points via which you can sample the light at different positions in the world,
-
and cast it upon dynamic objects such as characters and other moving elements, with low performance cost.
-
Reflection probes act as a single point of reference for reflection,
-
with an accompanying cubic volume to allow you to specify what should be included in the reflection.
-
These probes sample elements surrounding them using box projection
-
and store the information in a cubemap.
-
Materials with reflective shaders that are on objects within the Reflection probe’s volume,
-
can then reference that cubemap to create reflective surfaces.
-
As such, you should keep this in mind when designing the lighting of your scenes,
-
as the reflectivity of surfaces should be factored into the overall lighting.
-
So ultimately, lighting in Unity 5 is a balance of ambient light, direct and indirect light and reflections.
-
For more information on the new lighting systems in Unity 5, please see the information linked below.