In this lesson, you will learn how to choose between Forward and Deferred rendering paths by understanding how they handle lighting calculations in your scenes.
The Core Concept: When Lighting Happens
The primary difference between these two paths lies in when the engine calculates the light interacting with your surfaces.
Forward Rendering
Forward rendering calculates lighting during the base pass for every object. As the GPU renders an object, it loops through every light affecting that object to determine its final color.
- Pros: It is faster for simple scenes, supports Multi-Sample Anti-Aliasing (MSAA), and handles translucent materials much more efficiently.
- Cons: Performance drops significantly as the number of lights increases. If you have 100 lights in a room, every object in that room may have to calculate all 100 lights, leading to a high "draw call" cost.
Deferred Rendering
Deferred rendering breaks the process into two stages: the G-Buffer Pass and the Lighting Pass. First, the engine writes geometry data (base color, normals, roughness, etc.) into a set of textures called the G-Buffer. Then, it calculates lighting as a post-process effect, using that stored data.
- Pros: Lighting cost is decoupled from geometry complexity. You can have hundreds of lights in a scene, and the cost only depends on the number of pixels those lights actually cover.
- Cons: It consumes more memory due to the G-Buffer textures, requires specific Anti-Aliasing solutions (like TAA), and has limited support for complex transparency or custom lighting models.
Practical Application
In your DefaultEngine.ini or Project Settings, you can switch between these. Use Forward if you are targeting mobile hardware or VR where MSAA is critical and geometry counts are low. Use Deferred for high-fidelity desktop games where you want complex, dynamic lighting setups:
; Example of setting the rendering path in your project configuration
[/Script/Engine.RendererSettings]
r.ForwardRendering=True
Key Takeaway: Choose Forward Rendering for performance-constrained mobile/VR titles with few lights, and Deferred Rendering for complex desktop scenes that rely on many dynamic light sources.