• entries
29
99
• views
51772

# Volumetric Lighting!

1609 views

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 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! :)

That looks a LOT better to me.

That looks a LOT better to me.

Than my previous horrible implementation? :D

## Create an account

Register a new account