True Volumetric Lights (Now Open Source)

Here is the demo as promised. You can test it for yourself. Half resolution rendering still has its issues and there is room for improvement. The motion shimmering will never really disappear though. Not without temporal reprojection.
The scene is taken from Unity’s Blacksmith demo. There are two dynamic lights and dynamic GI. Apart from the volumetric lights, there is only custom tone mapping + eye adaptation + bloom. No AA.

I plan to release the source code in the matter of days. Enjoy

4 Likes

On an ati 5870 I got very good frame rates at half resolution.
Around 60 fps with vol. lights on and 66 fps without.

Well done!

From the testing that I’ve done on my volumetric rendering, I’ve found that you have to render at quarter resolution for it to be viable for mid to high end hardware if you want to render more then 1-4 lights. It also means you have to have a better down sampling, blur and up sampling shaders to hide all the awful artifacts that quarter/half resolution gives you.

The downside of having more complicated sampling methods is that its slower at rendering a few lights, but the upside is that you can render a lot more and still have acceptable results to use in a game.

Yeah, shadow casting lights are pretty expensive. Lights without shadows on the other hand require only 2 or 3 ray-marching samples per pixel and are relatively cheap. I guess it depends on what kind of game you’re making.
Do you think quarter resolution would work in this demo where the light shines through small cracks in the wall? I’ll have to try someday.

I’d be curious to know how you make quarter resolution look good. How do you make it stable in motion? Would you share with us (or PM me)? I use min or max depth buffer downsampling, depth-aware gaussian blur and bilateral upsampling (nearest depth for edges, bilinear for non-edges or lerp between the two)

@Michal_1 some context about the system of @Lexie Dynamic Volumetric Lighting replacement - Community Showcases - Unity Discussions

Only just discovered this thread, which is surprising considering I have a huge thing for volumetric fog. That you plan to share your source code is just great, thanks so much for going down that path.

Off to test the demo now. Cheers.

Demo is lovely. When you release the code I plan to do some custom stuff by (mis)using the 3d noise texture - all will be revealed :wink:

Here is a demo of the same building using my volumetric lighting. Default is quarter resolution, you can change the settings with the buttons in the top corner. Hold right mouse button to enable fly cam.

I’ve disabled all post processing and also the phase function on the light as well as 3D noise texture, Just so there isn’t any extra stuff hiding the artifacts. Chances are mine is slower at rendering one single light but the results of my half resolution and quarter resolution are a lot nicer then the simpler method of low res rendering. The goal of the system is to offset the extra cost of the more advanced sampling with the speed increase of rendering multiple lights at quarter/half resolution.

I’m still thinking about selling this on the asset store, I’ve been working on making volumetric lighting for many lights feasible for some time now, so I’m not sure if ill open source it or not. Would be nice to get something back for this time spent.

I’ve rewritten how the half resolution rendering works to make it look better. Here’s updated version. It is more expensive now but it looks almost identical to the full resolution version. It is surprisingly stable in motion too. Even without temporal filter. This new technique should work reasonably well with quarter resolution as well. But I’ll probably release it without it to get it out of the door as fast as possible.
And I’ll make a list of things that I know could be improved.

1 Like

No problem. I understand. Hey, I’ll buy it just to take look!

The demo looks impressive. I like how the image is clean even with very low resolution. No bleeding, no halos. Great work. I don’t like how soft it all looks, but I understand that it could be necessary if you need better performance. Anyway, your upsampling is superb.

Thanks! Yeah the downside is the softness, half resolution isn’t as bad and there is a setting to make it less soft but then artifacts from the low sample rate of the frequency start to show. So you can choose what is more important to your scene.

Here is an example with the setting off that makes it a lot sharper, this is also at quarter resolution.
Although Off looks way better, on hides a lot of artifacts when you have small beams of light.

Keep in mind that Unity will be releasing their own volumetric fog sometime after Unite Europe (source http://unity3d.com/pages/adam)… In your case, faster/better lighting/shadows would better justify an Assetstore release, IMHO.

Also, even if Unity releases their own solution, impatient unity users might very well buy your’s (a phenomenon that can be observed in the very entertaining Candela SSRR threads, for example).

@Michal_1 Played around with your demo and I’m getting approx. 0.7ms difference between volumetrics on/off. Around 0.4ms with half res. (4790K + GTX770). I’m really curious now, how the performance will scale with more lights.

Looks gorgeous :slight_smile: Can’t wait to try it in my project!

I’m way too excited about this, need to stay calm and patient :smile:

Oh, man. I didn’t know about it. This is what I ultimately wanted to do. I started with this traditional ray marching approach because it is very straightforward and relatively easy to do, but I really wanted to implement this compute shader + 3d texture based variant. Oh, well.

It is not really about number of lights. You’re paying for every lit pixel. So, it is more about number of overlapping lights (overlapping in view space). 10 small non-overlapping lights should give you better performance then one fullscreen light. Speaking only about the volumetric effect here. But yeah, you should be fine with GTX770. Same technique + half resolution rendering was used in several AAA console games in the past.

I have finally found the time to put it on GitHub. I’ll update the first post to make easier for newcomers.

4 Likes

If you sign up (for free) then you can also get access to nvidia gameworks volumetric fog source code on github, which might be of use to those learning and experimenting with techniques. Their implementation is a standalone example right now, not integrated into Unity or UE4.

It suppose this is part of the gameworks program where you have to slam the nvidia plash screen on your product?

Probably, I haven’t checked the license yet. I mention it here simply on the off chance that techniques used in it are of interest to those developing their own volumetric fog/lighting solutions.

Sorry, didn’t mean to spoil your day :frowning: it’s been announced at GDC16’

Did some quick testing. I’m getting some black squares popping in and out at random screen positions, except when using quarter res. It’s really nice that the fog gets reflected by SSR! It does not to seem to get affected by GlobalFog though (I know, fog affected by fog ) so at least I’ve made the density decrease, based on the light’s distance from the camera, and tried to mimic fog using the directional light’s vol-fog, but it’s way too bright. Performance-wise: heavy, but I haven’t played around enough. First screen :):

4 Likes

Also checked it out in our project (and also made a script which fades out based on a distance).
Looks great and the performance drop is not that big (considering the effect we get).

I also see some random black squares on the screen sometimes.
I get these a lot if I use spot lights so. But can’t get what is causing it (using spot lights without volumetric lighting does not produce these artefacts).

But all in all nothing is completly broken. Maybe we can sort these artefacts out.

One note so:
If I switch to full resolution on the camera, I get the following error (and a lot of stuttering):
Dimensions of color surface does not match dimensions of depth surface
UnityEditor.DockArea:OnGUI()

But not that I want to run it with this setting anyway :smile:

EDIT:
Screenshot of the artefacts with spot lights