Lighting and shadows

Welcome to the world of light and shadows! Here, we’ll introduce the core concepts of lighting in game development. Lighting not only brings your scenes to life but also sets the tone, mood, and depth of your environment.

In this section, you’ll explore the five fundamental types of lights:

  • Point Light: Think of it as a glowing orb, casting light in all directions from a single point, like a light bulb in an 80s scene.

  • Directional Light: The go-to for large-scale sunlight effects. Rays come from a single direction, perfect for mimicking natural sunlight.

  • Ambient Light: This is your scene’s “background glow,” evenly illuminating objects without any particular source.

  • Hemisphere Light: Imagine a gradient skybox—light comes from above, usually softer and more natural.

  • Spot Light: A focused beam, like a flashlight or a stage spotlight, creating dramatic effects with precision.

Light Sources and Shadow Play

To make this tangible, we’ve included an interactive screenshot featuring a Box, Cone, Torus, and a Saturn-like sphere. All objects are illuminated by all active light sources, creating a vibrant interplay of brightness and shadows.

You can:

  • Toggle each light source on and off.

  • Adjust shadow settings: Cast Shadows and Receive Shadows can be activated for both lights and objects.

  • Observe how light and shadow interact dynamically across the scene.

For added clarity, the positions of Point, Spot, and Hemisphere Lights are marked in the scene. If you prefer a cleaner view, you can hide these markers with a quick toggle.

Dive in and discover how combining lights brings your scene to life—watch as objects bask in collective radiance and shadows dance across the environment! 🌟

Can you make the blue box cast a shadow?

Directional Light: The Sun of Your Scene

If there’s one light you’ll find in nearly every game, it’s the Directional Light. Why? Because it’s the digital equivalent of the sun—powerful, versatile, and the ultimate mood-setter. Whether you’re creating a sunny meadow, a dramatic sunset, or a creepy twilight, the Directional Light is your best friend.

Parameters of Directional Light Here’s a breakdown of the key parameters you can tweak for a Directional Light, complete with an interactive screenshot so you can play around and see the impact for yourself. 🌞

  • Intensity: How bright do you want your scene to be? Adjust this value to switch from a soft glow to scorching desert sunlight.

  • Color: Choose the light’s color to set the mood. Cool blues for moonlight, warm oranges for sunrise, or even eerie green for alien worlds. 🌅

  • Shadow Bias: This parameter helps you combat “shadow acne,” those pesky artifacts in shadow rendering. Tweak it to keep your shadows clean and sharp.

  • Shadow Size: Defines the resolution of the shadow map. Higher values result in sharper shadows but may impact performance. Perfect if you need crisp details in close-up shots.

  • Shadow Near & Shadow Far: Control the range within which shadows are visible. Use these to optimize performance by focusing shadows only where they matter most.

  • Shadow Radius: Soft or sharp shadows? Increase this for soft, natural-looking shadows or decrease it for razor-sharp edges.

  • Shadow Area Width & Shadow Area Height: These parameters define the coverage area of the shadows cast by your light. Perfect for customizing the light’s effective shadowing zone.

  • VSM Blur Samples (VSM Mode Only): If you’re using Variance Shadow Mapping (VSM), this parameter controls the softness of the shadow’s edges. Higher values create smoother, more realistic shadows.

Important Note

Rotational transformations on Directional Lights and Spotlights do not have an effect, because they have a target field instead. To change their direction, adjust the target rather than rotating the light itself.

Experiment Time Dive into the interactive screenshot below! Adjust the Directional Light parameters and watch the magic unfold:

  • Shift the light direction to simulate different times of day—from dawn’s first light to the eerie shadows of dusk.

  • Play with intensity and color to completely transform the scene’s atmosphere.

  • Fine-tune shadow settings for that perfect cinematic look.

Ready to recreate the golden hour or a mysterious moonlit night? The Directional Light is your toolkit for capturing the drama of light and shadow in every frame. 🌓