So one topic that we all hear over and over is VOLUMETRIC LIGHTING ( caps intended ). Why? Because its so damn awesome. Why not? Because it can get expensive depending on the hardware. So after countless of tries I scrapped the code I’ve been wanting to shoot then resurrect then shoot again and just wrote what made sense, and it worked!
The implementation is actually really simple, in simple terms I did it like this: ( I havent optimized it yet, E.g. I should do it all in light view space )
// Number of raymarches steps = 50 // Get world space position positionWS = GetPosition(); // Get world space position of the pixel rayWS = GetWorldSpacePixelPos(); // Get ray between world space position and pixel world space pos v = positionWS - rayWS; vStep = v / steps; color = 0,0,0 for i = 0 to steps rayWS += vStep; // Calculate view and proj space rayWS rayWSVS = ... rayWSPS = ... // Does this position recieve light? occlusion = GetShadowOcclusion(..., rayWSPS); // Do some fancy math about energy energy = ... * occlusion * ... color += energy.xxx; return color * gLightColor;
Results: ( Its not done yet )
Thats all! Until next time!