Light Up Your Game: Unity Lighting Essentials

Lighting is a crucial aspect of creating visually stunning and immersive environments in Unity. Whether you’re developing a game, architectural visualization, or a simulation, understanding how to harness the power of Unity’s lighting system can significantly elevate the quality of your project. In this comprehensive guide, we’ll explore the essential concepts, techniques, and tips to help you master Unity lighting.

Understanding Unity's Lighting Pipeline

In order to get realistic lighting, Unity uses what is called a physically-based rendering (PBR) pipeline to simulate realistic lighting in its virtual environments. 

Some important components to point out.

Global Illumination (GI) : Unity uses real-time Global Illumination to simulate light hitting surfaces. Key components for making Global Illumination work include baked lighting, real-time lighting, and mixed lighting. 

  • Real-time Lighting – This type of lighting is used for dynamic lighting calculations that occur at runtime. It’s best used for when lighting conditions change in response to something a player has done. A major drawback is that it is very costly in terms of resources, so it should be used sparingly.
    • Features
      • Dynamic Shadows – Since real-time lighting is calculated at runtime, this allows for dynamic shadows that will respond to moving objects in the scene.
    • Use Cases
      • Day-night cycles, moving light sources (flashlights), and environments where lighting conditions frequently change.
  • Baked Lighting – Baked lighting involves precomputing lighting information offline and storing it in lightmaps, textures that represent the lighting of a scene. This technique is ideal for static environments where lighting conditions do not change during gameplay.
    • Features
      • Static Scenes – Baked lighting works best for scenes where the majority of objects are static.
      • Improved Performance – Thanks to the majority of light calculations being done at runtime, this greatly improves performance. 
      • Lightmap UVs – Objects in the scene need to have appropriate UV mapping to receive light information accurately.
      • Reflection Probes – Baked lighting can be complemented with real-time reflection probes to capture dynamic reflections in an otherwise baked environment.
  •  Mixed Lighting – This is a combination of both real-time and baked lighting techniques within the same scene. This approach allows developers to enjoy the benefits of both dynamic and static lighting.
    • Features
      • Dynamic and Static Elements – Mixed lighting is suitable for scenes where some elements need to respond dynamically to lighting changes, while others remain static and can benefit from baked lighting.
      • Hybrid Approach – Real-time lights can coexist with baked lightmaps, offering a flexible solution for achieving both visual fidelity and performance optimization.
    • Use Cases
      • Useful in scenarios where certain parts of the environment, like characters or moving objects, require real-time lighting, while the overall scene lighting remains relatively constant.
With a clear understanding of Unity’s PBR Pipeline, we can now look at different Light Sources and see how they can fit into being real-time, baked or mixed in our scenes.

Light Sources

Unity provides multiple forms of Light Sources that will help us add all the illumination that we will need in our scenes.

  • Directional Light – These types of lights simulate the sun and outside lighting for a scene. They emit parallel rays that produce uniform lighting across the entire scene. They have infinite range and can also cast shadows. You should also consider adjusting the skybox to help complement your directional lighting.
    • Use Cases – Lighting outside scenes and acting as a light source similar to the sun.
  • Point Lights – These are omni-directional lights that will emit light in all directions from a specific point in space, which creates a spherical pattern of light. They have a limited range and their intensity diminishes for objects taht are farther away from the light source. Point lights can cast shadows, but this does come at the cost of computational resources.
    • Use Cases – Great for simulating light bulbs, lamps and candles. It can also be used to emphasize certain areas in a scene. 
  • Spot Light – These are cone shaped emissions allow for a more focused and directed form of illumination. They can have the angle of the cone and intensity customized as well as produce shadows.
    • Use Cases – Great for flashlights, vehicle headlights, or a spotlight effect. Spot lights are also great for highlighting objects.
 
  • Area Light – These lights simulate larger light sources, providing soft and realistic lighting. They can be rectangular or disc shaped. The big drawback with area lights is that it must be baked in order to work.
    • Use Cases – Great for soft, diffused lighting, such as from windows or large panels. 

Things to Consider For Optimization

Lighting can become very costly to your game in terms of resources, so it’s always a good idea to minimize and optimize your lighting as much as possible. This is especially true for  VR developers. Consider learning more about the following techniques.

  • Baked Lighting – Baking your lights and using lightmaps helps reduce real-time calculations significantly. I’ve already made a tutorial on baked lighting, which can be checked out here
  • Limit Dynamic Lighting – Whenever possible, make sure you either choose Baked Lighting or Mixed Lighting to help reduce real-time calculations. 
  • Light Probes – Light Probes are an invaluable tool in Unity for creating realistic lighting effects. These probes store information about how lighting behaves in a particular area and can be used to create dynamic lighting effects. A tutorial on them can be found here.

There is still a ton to cover when it comes to lighting, but this introduction should help start you off on your journey to learning how to light up your scene! 

1 thought on “Light Up Your Game: Unity Lighting Essentials”

  1. Great informative video. I am wondering about LODs and how to light the game with the different types of lights in the games and avatars with LODs.

Comments are closed.