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 raymarchessteps = 50// Get world space positionpositionWS = GetPosition();// Get world space position of the pixelrayWS = GetWorldSpacePixelPos();// Get ray between world space position and pixel world space posv = positionWS - rayWS;vStep = v / steps;color = 0,0,0for 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! :)