Different Lights in Unity.

Michel Besnard
6 min readFeb 5, 2022

--

Objective: introduce the Reader to the four different light sources available in Unity.

https://www.moneytalksnews.com/wp-content/uploads/2017/08/shutterstock_400396579-4096x2730.jpg

Have you ever wondered how to set up basic light sources in your Unity Scene? Or how to pick the correct one for the effect you’re trying to create? Well, take a few minutes to read this short article and get a glimpse of the basics…

Light sources help Unity calculate the effects of lighting on the shading of the Game Objects present in your Scene. The shading will depend on the direction, intensity, and color spectrum of your light source. You adjust these via the Properties of your source.

These light properties will vary depending on the render pipeline you are using for your Project. If your Project uses:…

https://docs.unity3d.com/2022.1/Documentation/Manual/class-Light.html

Types of Light in Unity

Unity has four different types of lights. These are:…

  • Point Light: emits light in all directions equally (located in the Scene).
  • Spot Light: emits light in a cone shape (located in the Scene).
  • Directional Light: emits light in one direction only (located infinitely far away).
  • Area Light: rectangle-shaped surface, emits light in all directions from only one side of the rectangle (located in the Scene).

Point Lights

When dealing with Point Lights, think of a lightbulb dangling from the ceiling. Light is emitted in all directions equally, and its intensity diminishes the further it gets from the source. Unity states in its documentation that “light intensity is inversely proportional to the square of the distance from the source. This is known as ‘inverse square law’ and is similar to how light behaves in the real world”.

Effect of a Point Light in the scene

Spot Lights

Similar to a Point Light, the Spot Light lives in your Scene and illuminates objects up to a defined range. The only real difference between the two is that the Spot Light projects a cone-shaped area of illumination. Its angle can be adjusted up to 180 degrees. A good example of this light would be in a searchlight from a guard tower, a flashlight, or headlights from a vehicle.

Effect of a Spot Light in the scene

Directional Lights

Directional lights are infinite. They represent a large light source coming from outside the limits of the world you’ve created. No matter where they are placed in your Scene, they will illuminate all game objects in the same way (imagine the sun shining down on your Game Scene). It doesn’t matter where you place a Directional Light in your Scene, everything is illuminated the same, and since you are not able to define the distance from the Directional Light to the Scene, the light does not diminish. This can be a useful method to add convincing shading to your game objects.

Every time you create a new Scene in Unity, that Scene comes with a Directional Light by default which is linked to the Procedural Skybox. This can be changed very easily by deleting the Directional Light and creating a different light for your Scene.

Effect of a Directional Light in the scene

Area Lights

An Area Light is a rectangle-shaped object that emits light from one side of its surfaces only. This light is emitted evenly in all directions across that surface area, and the size of that surface is determined by the Range settings of its Properties. Similar to Point Lights or Spot Lights, the intensity diminishes the further away it travels. This leaves you with a shading that tends to be softer than other types of lights. Since Area Lights need to be baked into your Scene, you need to set the affected game objects to “static” in the Inspector, or else this will have no effect.

Effect of an Area Light in the scene

Creating Lights in Unity

You select which type from the Menu GameObject > Light > (pick the one you want). You then use the Gizmos to position and adjust the light source in your Scene.

Creating a light source.
Enable scene view lighting (the “sun” button on the toolbar ~ looks like a lightbulb) to see a preview of how the lighting will look as you move light objects and set their various properties.

Basic Principles for Positioning and Adjusting Lights

Try not to place a light so it shines directly perpendicular to a flat surface. Instead, try to angle the light slightly so it creates shaded areas and helps accentuate the shapes of your game objects. This will make the Scene much more interesting and believable.

You want to think of Spot Lights and Point Lights as a means to illuminate the areas of the Scene to which you wish to draw the attention of your Player. Whereas you want to keep certain areas dark to avoid notice (maybe there’s nothing to see, or maybe a creature is lurking in the shadows).

Since their range is limited, you want to make sure you extend the “cone” or “sphere” beyond the object you wish to illuminate. Not doing so may leave the game object just outside the range and leave it in the dark.

Area Lights are good for creating realistic urban lighting (thing street lights, or interior home lights).

You can adjust the color and brightness of your light source to match the “feel” of your environment or the technology of the day (think new LED vice old incandescent bulbs). These are found in the Inspector tab.

What is Culling?

When it comes to lighting, Culling is defined as telling a light source to ignore certain game objects. For the purpose of this explaination, let’s stick to Culling in a URP Project setting.

With the Directional Light shining down from above, the light is blocked by the ceiling.

In order to do Culling, you need to tell a light source to ignore game objects attached to a layer in your game Scene. An easy example of this that I was shown, is to start with a Directional Light and set it up to point straight down so the light is coming from right above your Scene. You will find, as in the case of this “room” shown above, that the ceiling (game object) is blocking the Directional Light from illuminating the inside.

To resolve this issue, we need to set the ceiling to its own layer, then tell the Directional Light to cull (ignore) that specific layer by unselecting “Ceiling” in the Culling Mask dropdown..

Set a new layer, then attach this layer to your Ceiling game object. Afterward, tell your Directional Light to cull (ignore) your ceiling by setting the Culling Mask to ignore the associated layer, and shine down into your Scene.

You then adjust the properties of the Directional Light to suite the atmosphere you’re trying to convey, and evenly illuminate your Scene.

I hope you have found this short article informative. Unity has excellent documentation on lighting here for those who wish to dig deeper into the subject. Join me in future articles as I continue to expand my own knowledge. As always, thanks for reading! :)

--

--

Michel Besnard
Michel Besnard

Written by Michel Besnard

Military member with 35+ years of service, undertaking an apprenticeship with GameDevHQ with the objective of developing solid software engineering skills.

No responses yet