Working with lighting

In the previous sections, we explored the uses of cameras for Unity games. Just like in the real world, cameras need lights to show us objects. In Unity games, we use multiple lights to illuminate the game environment.

In Unity, we have both dynamic lighting techniques as well as light baking options for better performance. We can add numerous light sources throughout our scenes and selectively enable or disable an object's ability to cast or receive shadows. This level of specificity gives us tremendous opportunity to create realistic game scenes.

Perhaps the secret behind Unity's ability to so realistically render light and shadows is that Unity models the actual behavior of lights and shadows. Real-time global illumination gives us the ability to instantiate multiple lights in each scene, each with the ability to directly or indirectly impact objects in the scene that are within range of the light sources.

Indirect light refers to lights bouncing off objects and reflecting on other objects.

We can also add and manipulate ambient light in our game scenes. This is often done with Skyboxes, a tri-colored gradient, or even a single color. Each new scene in Unity has default ambient lighting, which we can control by editing the values in the the Lighting window. In that window, you have access to the following settings:

  • Environment
  • Real-time Lighting
  • Mixed Lighting
  • Lightmapping Settings
  • Other Settings
  • Debug Settings

No changes to these are required for our game at this time. We have already set the environmental lighting to our Skybox. In Chapter 12, Adding Audio and Visual Effects to Our Game, we will look at Fog, which is available under the Other Settings section of the Lighting window.

When we create our scenes in Unity, we have three options for lighting. We can use real-time dynamic light, use the baked lighting approach, or use a mixture of the two. Our games perform more efficiently with baked lighting, compared to real-time dynamic lighting, so if performance is a concern, try using baked lighting where you can.

In addition to ambient lighting, there are four types of light: directional, point, spot, and area. We will look at each of these in the following sections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset