Light Modes and Types

Tutorial

·

intermediate

·

+0XP

·

15 mins

·

(78)

Unity Technologies

Light Modes and Types

In this tutorial, we compare the available light modes and types in Unity, along with advantages and disadvantages for each one.

Languages available:

1. Light Modes

There are several different light modes available in Unity. These modes relate to the mobility of a light and how it’s used within a Scene. The various modes differ in terms of performance, so this is an important consideration when implementing lights. In this tutorial, we will look at the advantages and disadvantages of three different lighting modes: baked, mixed, and real-time.



2. Baked Lighting

The baked light mode provides static lighting, meaning it doesn’t change during runtime. Baking is the process of storing lighting data in Texture maps prior to running the game.


The key caveats of baked light mode are as follows:


  • Lights and shadows are baked into lightmaps and, therefore, cannot be modified at runtime. Since this processing is done when lighting is created in Unity, it does not affect run-time performance.

  • Shadows are static, which can look odd if there are dynamic or moving objects during gameplay.

  • Baked light mode is the least computationally expensive method that we discuss in this guide.

3. Real-time Lighting

Real-time light mode provides dynamic or movable lights. The key features of real-time light mode are as follows:


  • Dynamic lighting and shadows can be modified at runtime rather than being baked into lightmaps.

  • Real-time light mode is the most computationally expensive lighting mode that we discuss in this guide.

4. Mixed Lighting

Mixed light mode combines stationary lights with moving objects. It can be considered a mixture of the two other methods.


The key features of mixed light mode are as follows:


  • It provides dynamic direct lighting and shadows.

  • Light can be included in lightmap calculations for static objects.

  • Light affects dynamic objects, including generating shadows for those objects.

  • Intensity can be changed at runtime and only direct light is updated.

  • Mixed light mode is an expensive computation method.

5. Real-time Lights and Light Types

When building 3D mobile applications, you should try to handle all your lighting with baked lighting, light probes, and Material effects. When you need to use a real-time light, you must consider which type of real-time light to use. Each type has a different cost to calculate:


  • Directional Light: With a uniform direction and no fall off, Directional light is the cheapest real-time lighting. You usually only need one Directional light because it can illuminate the whole Scene. This means that with forward rendering, Unity will always render one Directional light. This is true even if there is no Directional light in the Scene.

  • Point Light: A Point light is located at a point in space and sends light out in all directions equally.

  • Spot Light: Because a Spot light culls more objects than a spherical Point light, it’s the next cheapest type of real-time lighting. Keep the cone width tight and only have it hit selected objects to get the best performance.

Using Spot and Point lights can seem stylish, but it can also impact performance. Comparatively, Directional lights have a relatively cheap calculation and apply light everywhere. Spot lights should be used for small areas and Point lights for a wider region, while considering their effect on performance.


Since shadow calculations can be the most expensive part of lighting, casting light in all directions increases the amount of computational power spent on shadow calculations.


Dynamic lights are expensive to render, so it’s best to avoid them in mobile games. Sometimes 3D engines put limits on their use, depending on the device and graphics API used. For example, in the Unity Universal Render Pipeline forward renderer, there is a limit of eight lights per object (or four lights using OpenGL ES 2.0).


6. Conclusion

Lighting is an important part of 3D visualization, but you need to consider the performance implications before placing lights in a Scene. In the next tutorial, we’ll explore the best practices for generating lighting on static objects.


Complete this tutorial