Course contentsShow
← Unity Game Development
Lesson 596 of 8289. Rendering and VisualsFree lesson

Implementing Real-time Global Illumination with Screen Space Effects

You will integrate screen space global illumination techniques to add dynamic, high-fidelity light bounces that react instantly to changing scene conditions.

In this lesson, you will learn how to leverage Screen Space Global Illumination (SSGI) to simulate dynamic, multi-bounce light interactions using only the data currently visible on your screen.

The Concept of Screen Space GI

Traditional Global Illumination, like baked lightmaps, is static and cannot react to moving objects. While Light Probes add dynamic light, they lack the high-fidelity detail of surfaces bouncing light onto one another. SSGI bridges this gap by using the information already stored in your frame buffers—specifically the Depth, Normal, and Albedo (color) buffers—to calculate where light should bounce in real-time.

Because this technique only considers what is rendered in the current camera view, it is computationally efficient enough for real-time applications. If a bright red object moves next to a white wall, the screen space effect samples the red object's color and "bleeds" that light onto the white wall, updating instantly as the object moves.

Implementation Logic

In the High Definition Render Pipeline (HDRP), you typically implement this by configuring your Volume settings. Under the "Screen Space Global Illumination" override, you control the quality and sample count. If you are building a custom shader approach, you would perform a sampling pass in a fragment shader:

// Conceptual trace of a reflected light vector
float3 screenPos = CalculateScreenUV(worldPos);
float3 normal = GetWorldNormal(screenPos);
float3 indirectLight = SampleScreenBuffer(screenPos + (normal * offset));

// Blend the sampled light into the final surface color
finalColor += indirectLight * albedo * intensity;

When implementing this, keep in mind that SSGI is inherently limited by the screen's contents. If an object is behind the camera or occluded by a foreground element, the "bounce" light will disappear. This is why we often combine SSGI with lower-resolution Light Probes or Reflection Probes to ensure that when a light source leaves the screen, the environment remains grounded and doesn't flicker or go completely dark.

Key Takeaway: Screen Space Global Illumination provides immediate, dynamic light interaction by sampling visible screen buffers, offering a high-fidelity alternative to baked lighting for moving objects without the heavy cost of ray-traced solutions.