Monthly Archives: September 2012

Adding Volumetric Light Scattering to Rebirth Engine

I’ve just implemented a post-process volumetric light scattering effect.

Volumetric light scattering is a very handy effect we can use for lots of things. For example I wanted to make a scene with a mysterious light hovering in the woods.

The following video shows my scene. Of course it’s powered by Rebirth Engine, and everything is real-time (take a look at the dynamic shadows on the floor):

Implementing this effect is really straightforward, I followed this amazing article from GPU gems http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html.

All we need to do is:

  1. We draw a simple version of the scene where every occluding object is drawn in black (the light source remain bright):

2. Then we process the occlusion scene using a light scattering shader like the one presented in the GPU Gems article and we blend the result over the original scene:

What the GPU gems shader does is basically compute the ray from the current pixel (the pixel we are processing) to the light source in screen space and check whether the ray hits the light or if there’s any occluding object. Unfortunately we have to sample neighboring pixels too, i.e. we have to sample the texture more than once for every pixel.

We can save some cycles by reducing the number of samples we use or by using an occlusion texture resolution smaller than the screen resolution.

The shader from GPU Gems also has some parameters we can change to tweak the effect, we can pass them to the shader in real time, but it’s recommendable to set the number of samples as a constant parameter and re compile if we want to change it because of the performance (Using a loop whose limit is a variable instead of a constant in a shader is really inefficient).

This is it for now; I’m going to enhance my scene adding new effects so keep posted for future updates.

Advertisements

Welcome

RebirthEngineLogo

Hi, my name is Angel. I’m from Spain and I’ve been investigating and working on 3D graphics for three years (mostly on my own). Rebirth Engine is the culmination of those years of studying real-time 3D topics. You can check its features in the following video (please watch the video in HD):

If you want to know more about it, please visit: https://graphicprogramming.wordpress.com/rebirthengine/

For now I can’t upload the whole engine code, but don’t worry, from now on I will explain on this blog some of the algorithms and effects used in the engine. If you want me to explain something in particular, please leave a comment or send me message through this form:

https://graphicprogramming.wordpress.com/contact/

If you don’t want to get lost, you should have some C++,DirectX and HLSL knowledge. There are plenty of great books that you can use to gain a good level, I can recommend you some of them if you want to.

Last but not least, this blog is not going to be all about my engine. I’m currently working with Unreal Engine 3 and CryEngine 3 so I want to write about them within a near future, I will also write about others graphic libraries besides DirectX 9.0c like D3D11 and OpenGl.

That’s all for now. See you soon!