Volumetric Lighting!

posted in The Cuboid Zone
Published February 17, 2015
Advertisement
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 )

qfX7guG.jpg

ss.png?w=1000&h=
.

Thats all! Until next time! :)
9 likes 2 comments

Comments

JTippetts
That looks a LOT better to me.
February 18, 2015 09:43 AM
Migi0027

That looks a LOT better to me.

Than my previous horrible implementation? :D

February 18, 2015 04:40 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement