Fully Dynamic Diffuse Global Illumination

Hello, everyone. I’d like to start a thread about my unique solution for dynamic Global Illumination. I showed this technique off recently at GDC, and it was quite well-received, so I figured I’d share some information about it here.

Unity 5’s integration of Enlighten offers incredible image quality at an amazingly low run-time cost, but because it relies on precomputation, many developers are unable to leverage it in their games, especially if their scenes are being procedurally generated at run-time. If you’re working on a procedurally generated game, or a game that otherwise is very dynamic, I believe that my algorithm may be a fantastic solution for you.

I don’t quite have a name for the technique yet, but it’s basically a variation of Reflective Shadow Maps. I originally developed the algorithm back when I was working on lighting for Minecraft. Due to the dynamic nature of Minecraft, I needed a fully dynamic solution that didn’t rely on precomputation.

Here’s the current simplistic state of the algorithm. The scene is rendered from the view of the light source at hand and information about each surface receiving illumination is stored. That information is then accessed in a post-process effect to generate the final bounced light and then blended using the albedo buffer (thank you Unity 5 for deferred rendering!).

Here’s a few screenshots of the effect.

As you can see, the technique yields very spatially-coherent results with quite good close-proximity detail. The cool thing is that it’s calculated on-the-fly, so any material, lighting, or geometry changes are reflected immediately in the indirect lighting. Another strength of this algorithm is that it works very well for large outdoor scenes, because of its spacial coherency and retention of detail. Here are some comparisons showing the effect on and off in The Viking Village.

So, how’s it perform? At the settings in these screenshots, this effect is running at around 6 ms on a GTX 980 at 1080p. It is very scalable, however, and can cost as little as 2.5 ms and as much as 10 ms depending on quality settings.

Some of the drawbacks are:

-Limited to a single bounce and a “simulated” second bounce (works well enough)
-Currently only works for directional lights. I’m looking to find a solution for other light types
-Only surfaces lit directly by sunlight cast indirect light
-Does not (and cannot in its current state) handle indirect occlusion/shadows

As quality settings increase, the result approaches each surface giving off a single perfectly accurate bounce of light without visibility/shadowing. Lowering quality consists of reducing radius of indirect light, reducing resolution of buffers for coarser approximation of surfaces, reducing sampling rate at the risk of low-frequency noise, and decreasing draw distance of the effect.

Because I am also working on updating my SE Natural Bloom & Dirty Lens asset and working on finishing my SSAO asset, development may be slowed. I’m aiming to release this as an asset in the near future. Because of GDC, most of the preliminary work is done. I have an idea for a more lightweight approach, but that may have to wait until the initial version is released.

Please, let me know what you think! If you have any questions, feel free to ask them. :slight_smile:

31 Likes

Wow, very impressive!!

Amazing :slight_smile:

Do you have to change materials to get the result ? Or works in any scene without any preparation ?

It’ll work with any shaders in any scene provided that you’re using deferred rendering.

That’s so beautiful. Im hooked on outdoor scenes and still trying to understand what Global Illumination exactly is and how it works in these scenes. Looking at the examples brings me a bit closer to understanding it:)

This is great.

Great, that is a big perk. Is there a release date window ?

1 Like

well he did say “near future”, so … probably in something like 2-3 weeks? maybe? :slight_smile:

Hmm, with it working from a DL and looking at the top pictures it reminds me of CE’s LPV implementation. Which of course isn’t a bad thing, as long as performance is good it looks like a great solution.

Can’t wait. Thread subscribed.
Price?
ETA?

Didn’t see any dx11 requirement, so it will be mac compatible, right?

I don’t think it needs DX11 to work … just deferred rendering

Looks aAaaaAwesome. I’ve just finished baking a super complex scene in unity 4 and its 32 bit limitation have almost made me kill myself with so much crashing. Tried with unity 5 trial and precomputation took forever so switched back to U4. Finally I baked with just 2 hours, very little time for the glory I got afterward and did not crash becaus had to do ridiculous tricks to keep ram comsumption low, but still this assets delivers same ressults as baking with no lenghtly baking so I would jump in with no doubts.

1 Like

Looks fantasmic :slight_smile:

I would like to know if this will support Unity 4 as it also has deferred lighting. As it computes fast, could it be used used to bake high quality lightmaps?

Please paste more screenshots because this is looking freaking amazing.

For that SSAO you mention please add depth cutoff.

I’ve just finished a very complex scene of Tokyo Shibuya lit with Beast, find it in the WIP thread, if you license me a trial I could compare the results. I’ll update screens later today as these are quick grabs from editor as I needed a rest.

Yep, no dx11 requirement for now.

Hmm… Using this algorithm to do gpu-accelerated super fast baking of lightmaps is an interesting idea. I may think about this more.

Unity 4 has deferred lighting. Unity 5 has deferred rendering. There’s a big difference there, enough to where implementing something like this as a post effect in Unity 5 is trivial, and doing so in Unity 4 would be much trickier. It would at least involve custom shaders and would have an overhead cost.

It’s important to note a current limitation of this algorithm; only surfaces illuminated by a directional light will give off indirect light. That means that for now, spot and point lights are not supported, and neither are emissive surfaces. It’s real-time GI, you gotta cut corners somewhere.

2 Likes

Lol, I did not notice the deferred Rendering instead of Lighting. Sorry.

You could consider implementing spots and emisive surfaces for the lightmap version, if the ligthmap feature is ever implemented. This would be like a blazing fast Beast for unity 5.

Can I ask what buffer information from the deferred rendering you are using? I am curious if you need a lot of the info used or if when doing forward rendering we can do fast shader past to generate the buffer that you need? (or just write it to a another render target during the forward pass)

Just albedo. Yeah, it would be possible to get albedo by rendering the scene once more with a replacement shader (though, a terrible option to render the scene again just to get that information, in my opinion), or by using custom shaders that write to an additional render target. I’m not sure if it was a bug or limitation, but I recall MRT not being possible with Deferred Lighting, only Forward (in Unity 4).

2 Likes

Cool, we are doing forward rendering for our game and using MRT would be doable (I need to test if it’s still working in Unity 5 ;)). Our game is all about moving color around (http://www.troubleimpact.com/games/2013/2/25/color-thief.html) and realtime GI would be really useful, but the current Unity 5 precomputation step is just too slow to be useful for us. We only have one big directional light (the sun), so this sounds really good. Let me know if you need people to test it before release.