Deferred Lighting Exploration :
This time, we’re diving into deferred lighting, a powerful technique that adds stunning depth (ahah) and realism to 3D scenes. Follow the video tutorial for a deep dive into the workflow and process that brought this beautiful result to life
Key Concept: Screen Space Shading
Instead of applying materials directly to geometry, this method uses a Lookup Table (LUT)—a highly sophisticated one!
The inspiration? A timeless paper by Simon Green, an NVIDIA developer, presented at GTC 2010: Direct3D Effects by Simon Green
Fun fact: Many low-poly games still render water using this technique as base!
How It Works
-
Extracting Normals in Screen SpaceTo cast light, we need normals—but working with only depth, we have to generate them. Using GLSL, we combine UVs (vec2) with depth to create a vec3.
The Magic Formula:
For normals, calculate directional vectors using texture neighbors:
-
directionX = right - left;
-
directionY = down - up;
-
normal = normalize(cross(directionX, directionY));
-
This is called finite differences, a technique also used in raymarching
See this example from "shader toy" : ShaderToy link
In our case this "finite difference" is the actual pixel size , the uniform uTD2DInfos[0].res gives pixel size (x, y) and resolution (w, z), essential for calculating normals.
Here below a picture of the extrude glsl inside the meshY.
In the palette under point cloud you have depthProjectionCOMP that is actually doing the same thing even better since take in conisderation the camera field of view.
But i like to keep stuff simple so i wrote mine.
In the deffered light shader the part that calculate the normals looks like this :
At the heart of this process is the render equation, which dictates how light interacts with surfaces. By constructing a BRDF (Bidirectional Reflection Distribution Function), we breathe life into materials like liquid or other complex surfaces.
For the full breakdown, check the video—I walk through the entire pipeline to demystify each step!