Illuminating the Dark: Crafting Complete Darkness in Unity

Ryan Rockwell
Unity Coder Corner
Published in
4 min readDec 24, 2023

In the realm of game development, darkness is not merely the absence of light; it’s an entity that shapes the player’s experience, accentuating the unknown and heightening tension. Me and my fellow developer Brandon have decided on a building our first horror game “Lanterns Grip”, and to make it feel like a true horror experience we needed to engulf the player in true darkness with nothing but a flicker of light. We will explore the mystical arts of creating complete darkness in Unity and how to bring a single source of light to life within it. This guide is perfect for scenes that require a single area light, like the flickering lantern in our upcoming game, to reveal the mysteries shrouded in shadows.

Understanding Unity’s Lighting System

Before we plunge into the abyss, it’s crucial to comprehend the core of Unity’s lighting system. Unity offers various types of lights, each with its purpose and behavior. For our task, we require a setup that allows for total darkness, illuminated solely by our lantern’s area light.

Click through tons of different lighting options to make the scene feel the way you want!

Setting the Scene for Darkness

The first step to achieving impenetrable darkness is to adjust the ambient light. This global illumination affects every corner of your scene and must be tamed to prevent unwanted visibility.

  1. Navigate to Window > Rendering > Lighting Settings.
  2. Set the Environment Lighting Source to Color.
  3. Change the Ambient Color to pitch black.

Adjusting the Light Source

With the ambient light subdued, we turn our attention to the lantern. We’ll be using an Area Light to simulate the lantern’s glow.

  1. Create an Area Light by right-clicking in the Hierarchy, selecting Light > Area Light.
  2. Position the light to match the location of the lantern in your game object hierarchy, if you’re using a lantern. The same applies for any light source however.

We got our lantern from the synty studios asset packs, which you can checkout at syntystore.com. We’re using dungeon realms, and dungeon packs for our game.

You can slightly see in the dark in front, an enemy approaching the lantern…Imagine running through a dark room and this is chasing you!

Fine-Tuning the Area Light

The Area Light in Unity doesn’t cast light in all directions; instead, it emits light within a defined shape and direction, perfect for our lantern’s glow.

  1. Adjust the Range to control how far the light travels.
  2. Modify the Width and Height to match the lantern's physical dimensions.
  3. Play with the Intensity and Color to simulate the flame's flicker and warmth.

For us, we chose a range of about 2 to default. We will be using a script to create an artificial flickering to appear as though the flame is lighting the way.

Embracing the Shadows

To deepen the darkness, we must ensure our light casts realistic shadows.

  1. In the Area Light settings, set the Shadow Type to Soft Shadows.
  2. Adjust the Baked Shadow Radiusto create a more natural transition from light to dark.

We’re not applying any shadow radius until later, because we’re creating a flicker. The flicker is adjusting the radius and intensity and the range of the light source so quickly that there didnt seem to be a real adjustment needed here yet and the default 0 worked for us. We’re probably going to change this later though as we adjust our flicker script for a more natural transition.

The Final Touch: Post-Processing

Post-processing is the final spell to cast, enhancing the contrast between light and dark.

  1. Add a Post-Process Volume to your scene.
  2. Enable Color Grading and lower the Post-exposure to darken the unlit areas further.

Testing the Darkness

Now, it’s time to test. Play your scene and witness how the lantern’s light becomes the sole guide through the consuming darkness.

Wrapping Up the Shadows

Creating a scene draped in darkness, with only an area light to guide the way, is a powerful method to evoke mood and focus player attention. By following the steps outlined above, you can craft an environment where every flicker of light promises both safety and peril.

We hope this guide illuminates your path as you delve into Unity’s lighting mechanics. Stay tuned for more insights and behind-the-scenes looks at our game development process.

If you want to learn how we made our flicker script, or how to set up post processing and a first person camera, comment to let us know.

--

--

Ryan Rockwell
Unity Coder Corner

Unity C# Developer and Software Engineer with 4 years experience in 2D/3D and marketing applications.