Dynamic Volumetric Lighting replacement

I was really unhappy with the quality and performance of Unity’s shadows. I tried a few ways to speed it up but they all relied on unity’s lighting in the back end.

So I’ve completely replaced Unity’s dynamic lighting.

EDIT: Test Build (updated 3/9/2016)

Features

  • Out performs unity’s shadows

  • Real time Volumetric lighting

  • Better smooth shadows

  • Way less light bleeding, shadow acne, peter panning

  • Smooth Shadow distance fall off (No more pop in shadows)

  • Coloured Light cookies

  • Multi Camera friendly(reuses shadow maps from other cameras)

  • Can handle Higher res shadow maps (not recommended for most GPU’s).

  • Shadow quality can be changed at run time with out needing to change settings profile (Why unity)

  • Currently supports point, spot lights and Directional light

  • shadow caster exclusion list (great for torches)

To do

  • Area lights
  • Soft shadow on directional light.
  • Cascade Directional light.
  • LOD friendly

Downsides

  • Doesn’t support transparency (supports alpha cut out and alpha overlay though)
  • Only supports Standard shader family
  • Doesn’t interface with light probs or enlighten
  • Edit: Currently Only works in deferred shading path.
  • Edit: Uses VRAM to increase performance (size set by user) Still out performs unity if buffer size is 0

Some of these downside could be fixed but I’d need Unity source or their Render API improved.
The game I’m working on doesn’t need transparency and is procedurally generated, So most of these downside don’t apply to me.

Going to finish up directional lighting this week and hopefully have a build ready for testing soon.
If anyone has any feature requests, I’d love to hear it!

33 Likes

Very interesting, any chance you could show a greater variety of settings, such as a forested scene, that sort of thing?

Yeah, i need to work on some example scenes. I might just buy a premade one off the store, probably easier then wasting a day.

This looks awesome. I’d like to see a demo with much stronger volumetric effects - to see how far it can be pushed. I’d also like to see how it interacts with enlighten, and how it looks when two different colored light volumetrics interact/intersect. I’m really stoked about this, as I’m having endless shadow gap issues. You also mention that directional and area lights are to do - does that mean that this only works with point and spot? Or only point?
Thanks in advance!

PINNED

And agreed with the previous posters.
What do you think you’ll set as start price?

Fixing shadow acne looks amazing. We’ve had a lot of trouble with that in our procedural game.

The limitations do seem a little hard (only working with standard shaders and no transparency). Depending on price it’s definitely something I’d be tempted to look into and research with to see if it fits our game.

Interior would be good to have a look at also. An interior with a bit more substance than what the video shows (on the light bleeding part). Thanks!

Right now it works with spot and point lights. I should have directional done by the end of the week. Area lights will probably be the last thing I add. Unfortunately my lights don’t interact with enlighten, I’d need unity’s source to get that working. you might be able to fake it by having a unity light in the same place during the baking process, but I haven’t tested it.

Here’s a picture of stronger scattering and colour mixing, Ill add more scatter functions soon, right now it scatters in all directions with the same strength

If i sell it, probably around 50-60, but ill have to do some more research first.

Ill include a few scenes in the demo, its hard to show off this effect with video and screen shots. If anyone has any recommendation on scenes, id love to hear it.

3 Likes

Want.

Nearly got cascade shadow maps generating today. Couldn’t find a way to limit the render area in a command buffer so i had to make a custom blit shader to copy 4 textures into one.

Note: color is compressed in the below image

2 Likes

@Jesper-Mortensen or @KEngelstoft have some idea of how to render lighting to enlighten without unity lights or tip for integrating other lighting systems such as this one?

3 Likes

Good one. I have lots of issues with shadow acne, a.k.a banding in my game, also (to less degree) peter panning. Too bad you can’t make this work with legacy diffuse shader (which is what I’m using for my game to get oldschool flatshaded look), otherwise it’d be an instant buy from me (don’t care about transparency either or interfacing with probes).

Those red and blue screenshots look absolutely awesome. :stuck_out_tongue:

You can modify the internal standard shader to get flat shading, we do it for our game.

So this becomes useless if it can’t mix smoothly with Enlighten GI.
I mean this will work great with only real time lightening games.

Amazing work dude, fully credit to you on trying to do something on your own and improve on things where a large company has.

My question is, how is mobile performance?, will it be suitable to use on mobile devices.

Also I feel Unity should help you with what you need, the sources etc.

1 Like

So if I understand correctly, in essence it’s similar to my own implementation of lights:

Sounds like an increase in shadowmap precision, probably R16->R32, doubling memory use. Atleast, for point lights as those don’t support dedicated depth formats.

So you have a unique shadowmap for each light? Your memory requirements would then scale with the number of lights, while Unity lights have a constant requirement.

I may be wrong here, but this is due to keeping shadows over multiple frames? As that’s the only way I’ve found to increase the performance of unity lights significantly, and the only other way I found was clipping pixels covered if they’re not in range of the light. You’ve also disabled to ‘wiggling’ of torches in the viking village demo, further increasing the chances of this being correct.

Internally Unity only has 1 shadowmap of each required quality, and draws over the content just before it renders the light onto the screen. This is why there isn’t a update-per-script option like on reflection probes, there is no per-light buffer you can keep.

It would be nice if you can include the downsides of these things in the OP:

  1. Your lights use a lot more memory than Unity’s, especially if you have more of them
  2. Your lights only outperform Unity’s if the shadow casters don’t move and you therefore don’t update the shadowmap
  3. This only works in deferred.
  4. A related problem to 2); As the code is slower but runs less, if something happens that has to update multiple lights you’ll get a frame spike that may be higher than what you’d get every frame with builtin lights.

My suggestions:

  1. LOD support. it improved performance for me a LOT; from ~70% of builtin ms to ~20% or so iirc.
  2. I don’t know how you’re rendering into your shadowmap that makes this standard shader only but you could use Camera.RenderToCubemap with a replacement shader to generate the shadowmap, removing the standard shader requirement.

I’d love to be proven wrong, and that this isn’t what I described above as that’d mean there are lots of further improvements to be made on top of a good base.

Great job at the volumetric lighting though, looks awesome! Next step is voxelizing the world in range of the point light and conetrace some GI through it :stuck_out_tongue:

1 Like

Hello Lexie,

I’ve been following your progress on Hitbox Team - this is looking really promising. Definitely interested :slight_smile: ! Especially the volumetrics. Though I would need it to play along with light probes and Enlighten.

So far, I’ve managed to create a sort of fake lit-fog with particles which look OK at far distances:

…but it doesn’t look good when close to camera/light sources, as you can see in this vid:

https://vimeo.com/151343852

Your implementation would really bring my project to a whole new level.
Keep up the excellent work! :slight_smile:

4 Likes

This looks pretty good!

A must have!

I haven’t done any research into making it work with enlighten yet. My game is procedurally generated so figuring out if i can get it working with light probes and enlighten is at the end of my list. My guess is I’ll need some enlighten API opened up.