Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Dynamic Volumetric Lighting replacement

Discussion in 'Works In Progress - Archive' started by Lexie, Jan 11, 2016.

  1. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646


    The sunlight in the sky after the sun ducks behind the buildings is my favorite part, It leaves a warm light in the sky before the sun goes behind the horizon. Video compression kinda compressed the colors a bit.

    Warning 117MB Download
    If you want to see this it in a build Here is a link
    Press V to turn the effect on and off. Pretty stark difference.
    Load times for this scene are long so if you do try it out, let it load.
    Note : I've compressed texture and removed Dynamic GI for this test scene

    Two more features to go until I'm happy with version 1.0.
    Slightly better transparency support and some ease of use stuff.
     
    Last edited: Jul 28, 2016
    Kenaz, John-G, Lex4art and 7 others like this.
  2. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    This is the better transparency support I was talking about. If you have really low sample rate then transparent objects would look really grainy (Right image). by averaging the results it looks a lot better (left image).


    Air density and sample count are set to bad extremes to help illustrate the effect


    Ok I think that's everything for version 1.0 Going to push this now. Still no word on an ETA from the asset store.
     
    Drommedhar, Kenaz, one_one and 7 others like this.
  3. Steven

    Steven

    Joined:
    Dec 23, 2009
    Posts:
    43
    I am really looking forward to this release Lexie. All the demos have performed very well, and look amazing. This effect can add so much to the look of a game environment. I really appreciate you releasing it as an asset.
     
  4. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Thanks, Its a shame I couldn't get my full custom lighting working easily with unity's pipeline cause that's even faster!, But I'll release that as a beta branch at some point.
     
    CWolf and John-G like this.
  5. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    Can't wait to get my hands on it. The Asset Store Team needs to speed up (no checking everything is fine, even if it means we need to wait a bit longer) xD
     
  6. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
  7. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Forum post

    Welp. Was hoping to get some advice from unity on pricing, but they set it live anyway. I guess its $40 now...
    I'm working on a build that has better density particle shaders.

    The implementation for density and transparency right now is dx9 friendly, Ill make a better performing dx11 version.
    Ill make a forum post for this asset as well.
     
    Last edited: Aug 1, 2016
    Shodan0101 and hopeful like this.
  8. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    does the package also include the better and less leaking shadows? from description its only the volumetric lighting aspect
     
  9. jdraper3

    jdraper3

    Joined:
    May 28, 2015
    Posts:
    117
    Great job on this, it really does look great! I already had a volumetric lighting solution in place, but this is way better. Here are a couple of quick screens.

    vl-night.png vl-evening.png
     
  10. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
  11. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Yeah this thread is about done, but that was a very pretty way to end it!
     
    hopeful likes this.
  12. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    What happened to the custom lighting?
     
    Gekigengar likes this.
  13. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
  14. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
  15. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Oh damn, I somehow missed he was separating those two things for now.
     
  16. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    Yeah, I'm mostly interested in the shadows and the overall fps improvement.
     
  17. Shodan0101

    Shodan0101

    Joined:
    Mar 18, 2013
    Posts:
    141
    Hi Lexie,

    Love your Hx Volumetric Lighting asset! I`m on a tight Indie budget but really close to purchasing it ;) Lexie, do you have update on your custom soft shadow system as I understand you split the "2" system for soft shadows and Volumetric lighting as separate assets on the store?
     
  18. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    @GMax @NikProductions @elbows

    Sorry for some reason I'm not getting notifications from this thread. Ill reset my settings.

    I'm still working on a way to get my shadows working with unity's inbuilt lighting. The reasons id rather get everything working with unity's lighting is it means that people wont have to write custom shaders and people can just drop it into their scene. I'm working on VR support for my volumetric lighting because a lot of people are requesting it. After that I can dedicate some time to getting the shadows working.
     
    No0B25, Drommedhar, jdraper3 and 5 others like this.
  19. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I'm on holidays right now and thought id take a stab at single pass clustered deferred/forward rendering.

    I want to switch my lighting to use this as it makes forward rendering really simple to add.
    It's kinda similar to valves single pass forward renderer except it supports 1000 lights on the screen at once instead of 18.

    Basically you cut the view frustrum up onto a 3d grid, each cell is a cluster, you then calculate using simple bounding collisions what lights will intercept each 3D cluster.

    Then in the fragment shader you calculate what cluster the fragment is in and your able to pull a list of all the lights that will probably light that fragment.

    You then loop through the list of lights and calculate all the lighting on it. This is all done in a single pass.

    The tests ive done so far look really promising. Below is a screen shot comparing 500 really dim lights using unity's rendering vs my custom single pass clustered renderer.

    Unity rendering 500 none shadowcasting point lights at 1080p deferred (148.5ms)

    Mine rendering 500 none shadow casting point lights at 1080p deferred (0.4ms)
    EDIT: Ok there was a bug that caused the shader to do some strange optimization, actual speed is more like 70ms, Still a lot faster then unity


    Massive speed improvement and because its all done in a single pass the color isn't getting compressed everytime it writes to the camera's render texture, So mine doesn't have color banding.

    I need to expand the system a little more so I expect mine to start getting a little more expensive, but i have a LOT of head room.

    This method is going to make it really easy to add forward shader support, so I can finally use MSAA and have lots of lights.

    Volumetric rendering will be way faster as well as ill be able to raymarch all the lights in a single pass as well.

    Will keep posting updates as I get time to work on it.
     
    Last edited: Oct 6, 2016
    SAOTA, punk, yc960 and 13 others like this.
  20. crudeMe

    crudeMe

    Joined:
    Jul 8, 2015
    Posts:
    92
    posting in an epic thread. Looks soo promising, godspeed!
     
  21. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    This just sounds awesome Lexie. Hope everything goes well and we will get our hands on it ;-D
    That's what Unity might need ^^
     
  22. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Ok i had another look at my prototype and there was a bug causing the shader compiler to take liberties with optimization.
    After fixing those the speed came down back to reality. From the tests I've done its only about 2x faster then unitys lighting.

    Im interested to see how well this method works in real world use though, I suspect it to only be about 1.5x faster at the end of the day, but time will tell. The plus side volumetric support should be 1.5x faster as well. also transparency will be able to be lit correctly.

    I think I figured out a way to get it to work with dx9, I just haven't had any spare time to sit down and really implement it.
     
    Arganth, yc960, Shodan0101 and 2 others like this.
  23. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    What kind of liberties were that?
    The second image looks good enough to me, so perhaps those liberties are still usefull?

    Greetings
    Chillersanim
     
  24. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The image quality looks the same as the images i posted, The shader was basically only calculating one light and then adding the results together because all the lights were in the same position/color. When i forced it to process each light correctly the cost of the shader came back down to the numbers i was more expecting. Around 1.5-2x faster then unitys lighting.
     
    Last edited: Oct 6, 2016
    chillersanim and Drommedhar like this.
  25. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    Let's just put it that way:
    - Looks better
    - It's faster
    - Better (faster) volumetric support
    - Better Transparency support

    I don't see any problem ;):p
     
    chillersanim and crudeMe like this.
  26. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Doesn't sound like a bug to me, rather like a piece of code that is smarter than anticipated. :D
    1.5-2 times the processing speed of Unity sounds still awesome to me.

    Keep up the good work!
    I'm looking forward to using your asset in my projects.

    Greetings
    Chillersanim
     
  27. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I got dx9 support added today, It will be limited to 255 lights per chunk. The camera is split up into a 8x4x8 3D grid for now, it can be increased to be able to support more lights but its going to be limited to 255 per chunk. Increasing the grid size adds more cost to the cpu but increases the speed on the GPU. not sure what the correct balance is yet.

    Its hard to pin down how fast the system is going to be. There is a cost of setting up all the data and sending it to the GPU. So if you your only rendering a couple of lights its faster to render them the standard way, where as if your rendering a lot of lights 10-15+ its faster to use this system.
     
  28. No0B25

    No0B25

    Joined:
    May 2, 2016
    Posts:
    70
    If you say that your (great looking) solution is slower at times, then how does the system perform with outdoor environments where the shadow maps would be quite complex? We don't have many shadow-casting lights as of now (only two directional lights), but are looking to increase image quality and possibly performance and your project here seems to offer both.

    Is there any rough ETA on when we can throw money your way for this? I'm asking because maybe it would fit into our production schedule to integrate it before release.

    EDIT: Oh yes, I totally forgot to ask. If you plan on releasing this at some point, is there a possibility of implementing some relatively cheap blur with falloff for the shadows (still a pretty complex effect I'm sure) and lights subtracting from the lighting (negative lights)?
     
    Last edited: Oct 10, 2016
  29. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I have a game to make and a volumetric plug-in to support on the asset store so my time is spread pretty thin.

    This is kinda my hobby project that I work on when ever I get some spare time. Still not sure if this will ever see the light of day as its hard to integrate everything with unity's API. The new method I'm trying looks to solve some of the big issues with compatibility, But time will tell.

    Recommend following this forum post and seeing where things go, But don't count on using this in your game just in case i cant get it working as well as it needs to.

    Ill put a disclaimer at the start of this post as the direction has evolved a bunch over the course of it.
     
    No0B25 likes this.
  30. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    TestScene
    Included is two exe, One using unity's lighting and the other using clustered single pass forward rendering.

    There are 132 lights in this scene.

    On my system (970m) my results with MSAA 8x

    Unity MSAA 8x
    fps - 62
    Batches - 4696
    Tris - 4.1M

    Clustered Single pass Forward MSAA 8x
    fps - 120
    Batches - 374
    Tris - 484.4K



    I would compare valves the lab render but it doesn't support non-shadow casting lights.
    Also it only supports 3 points lights... (it just uses unity's lights for non shadow casting)

    Image results are slightly more correct using my renderer, but its pretty hard to notice the difference. Only in low light conditions with multiple overlapping lights would you notice when unity falls short on image quality.

    As for clustered deferred vs Unity deferred, The speed is pretty much the same (145 fps). I think I need to calculate the clusters on the GPU for clustered deferred to be faster then normal deferred. GPU are pretty fast at depth tests so its pretty hard to beat that,

    But the big take away here is i can get forward rendering with 8x MSAA to nearly the same speed as deferred with NO AA and that is AMAZING

    If i add some screen space AA to the deferred pass it drops it down to about 130ish.

    EDIT: With no MSAA my Forward clustered renderer runs at 160fps, so its even faster then unity's deferred!
     
    Last edited: Oct 17, 2016
    Drommedhar and Elecman like this.
  31. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    Hey Lexie just checked out the 2 demos. The result on my system are like this:

    Unity MSAA 8x

    fps - ~80-81

    Clustered Single pass Forward MSAA 8x
    fps - ~131

    My System
    CPU: AMD FX 8350
    GPU: Nvidia GTX 1070
    RAM: 24GB DDR3
    Tested Resolution: 1920x1080

    Better looking lights in low light conditions would be cool. Especially as we are having such conditions in our game where there might be some fill lights (even without shadows) to give the scene some mood.
    So this currently is a huge improvement already. If the clustered deferred would be also faster (based on what you said you might be able to do), than this is perfect in every aspect.

    Are there currently any downsides one would need to work around? Because if not, I would totally go for it. ;)

    EDIT:
    Might have found a little bug so. I have DSR enabled, to run stuff at higher resolutions. I tried to run the Clustered Demo @3840x2160. Performance was good but I got artifacts:


    Maybe it's because you haven't set the true fullscreen mode. We had lots of problems with it (also concerning resolution). Maybe try and check this:
    https://forum.unity3d.com/threads/s...n-the-native-desktop-res.431860/#post-2814297

    EDIT2: Found out the artefacts are already visible on 1080p, but not that strong.
     
    Last edited: Oct 16, 2016
  32. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Thanks for the stats, Slight miss calculation in cluster position caused those artifacts. Should be fixed soon.

    Biggest downside with applying the lighting in a single pass are.

    All the shadows need to be stored in 1-2 textures. They have to be rendered before the scene is rendered. which means if you have a lot of shadow casting lights the resolution of them all will get dropped down to fit them all. It will use a 8k texture or 4k depending on the hardware.

    Also light cookies are a little harder, What will have to happen is all the cookies used in the current frame will need to be packed into another 4-8k texture.

    Those are really the only two downside.

    Edit: something i didn't mention is I'm actually doing a pre-pass depth render in my forward rendering. this means you actually render the scene twice. Once with a simple shader to write the opaque depth. and then again to actually apply the lighting. This means there is zero overdraw on the lighting. A lot of effects generally need the cameras depth texture so you end up rendering one anyway with forward these days, but in unitys example scene i was not rendering one. (unity's test would have been slower if i did.)
     
    Last edited: Oct 16, 2016
  33. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    The downsides really don't sound that bad actually.
    The question concerning Light Cookies would be, if you're able to check if a cookie on both light sources is the same and only store it once. So if we have a lot of same lights (only their cookies) in a frame, we don't run into a problem concerning texture size.

    The part with shadow casting lights shouldn't be to bad, as one already needs to think about where shadows are really needed, to keep performance on a good level (even in Deferred). And if it automatically reduces the resolution, that's fine with me ^^.

    Also great to hear that the artifacts thingy is fixed ;D
     
  34. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Yeah, The cookie thing wont be too bad, but it means you wont be able to have really high res cookies.

    My custom shadow system does shadow caching so its not too expensive to have a lot of shadow casting lights.
    I just need to modify it to work with this system and to pack the shadows into a big texture.
     
    Drommedhar likes this.
  35. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    One should already try and keep the resolution of cookies to a minimum. So it's not bad.
    Shadow caching sounds great too.

    Can't wait to play around with all of this (if it's getting released sometime in the future ;)). As always, great stuff you're creating. Keep us updated ^^
     
    hopeful likes this.
  36. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I just tested on my 1070.

    Unity MSAA 8x
    fps - ~120

    Clustered Single pass Forward MSAA 8x
    fps - ~210

    Wondering why yours is so much lower on both tests, are your drivers upto date?
    im also not seeing those artifacts when rendering at 3840x2160
     
  37. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    Do you have an Intel CPU? That could be the reason...
     
  38. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Yes, but the cpu usage in this scene is pretty small.
     
  39. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    Well I'm running an "old" FX8350. Compared to an i7 6700k this at least makes ~80FPS in Battlefield 4. So this might already be a reason ;) Will probably update soon anyway ^^

    EDIT:
    Also a friend with an GTX 1080 with the same AMD CPU also only got around 10-15FPS more than me. So it probably is the CPU somehow.

    EDIT2:
    Just got my i7 6700k with DDR4 3000 RAM and now the specs are like this:
    (value in brackets is with slide CPU overclocking to 4600MHz instead of 4000MHz)

    Unity
    ~155FPS (same)

    Clustered

    285-290FPS (310-320FPS)

    So it really is the CPU ^^
     
    Last edited: Oct 18, 2016
  40. No0B25

    No0B25

    Joined:
    May 2, 2016
    Posts:
    70
    Oh boy. Really feeling it's getting time to get a new desktop PC right now. Here are some more stats. Drivers on both the desktop and the laptop are version 373.06. The resolution is 1920x1080 on both.

    My desktop:
    i7 2600K @4.4GHz
    16GB DDR3
    GTX680 2GB
    Unity: 58fps (fluctuates between 17.0-17.6ms)
    Clustered: 119fps (fluctuates between 8.3-8.6ms)

    My laptop:
    i7 4710MQ @3.4GHz
    16GB DDR3
    GTX870M 6GB
    Unity: 40fps (fluctuates between 24.8-25.4ms)
    Clustered: 85fps (fluctuates between 11.5-11.9ms)

    Here I noticed that for some reason forcing either the integrated graphics or the dedicated GPU didn't yield any different results. Maybe the driver just didn't want to do it or something. The GPU was under full load though. Double checked the frametimes with MSI Afterburner.
     
    Last edited: Oct 18, 2016
  41. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Forcing your intel GPU to run can be way harder then it needs to be. i find the easiest way is to Unplug power and put it in low power mode.

    Thanks for the stats! looks like in general its 2x speed. The issue with this type of rendering is there is an upfront cost, so there is certain situations where normal forward rendering is actually faster. from the tests ive done there is a tipping point around 10 lights, but at the end of the day it depends on your scene.

    In general if you want a lot of lights this system is going to be a lot faster.

    Either way its a way I can do forward rendering using my shadow system, So it overcomes one of the big issues I had with my old system.
     
  42. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Unity shared their prototype for custom rendering loops, I have a feeling they will be releasing render loops that will be similar to the lighting stuff I'm doing, I really hope this takes off as it will expand unity's rendering a lot more.

    You can read about it here
     
    ksam2, CWolf, hopeful and 1 other person like this.
  43. PenDigi

    PenDigi

    Joined:
    Sep 19, 2015
    Posts:
    14
    Hey I encountered a bug where I built the example scenes into an .exe but the volumetric shaders dont work. Are there some settings I'm supposed to have to get it to work in the build?
     
  44. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    My guess is your in unity 5.6 beta, thats not support yet. I only add support once they become a release build as unity tends to change a lot with back end rendering in the betas.
     
  45. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I've made a post about a Dynamic GI solution I've been working on, You can follow my progress here
     
    zenGarden, elbows and Arganth like this.
  46. skyecrack

    skyecrack

    Joined:
    Jan 5, 2018
    Posts:
    29
    Is this still up? God I hope it is
    Bringing something like Forward+ to Unity isn't small talk. And cached shadow maps? Sign me the F*** up man.
    Honestly working with just the standard shader isn't that big of a limitation, considering the kind of scenarios this system would be most useful at (even if it was, IMO it would be worth the sacrifice) It could easily be the single most important asset on the block.
    C'mon @Lexie, this could save lives! :(
     
  47. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I put his on hold till the scriptable renderloop is further along. It is aimed to make it easier to replace the rendering pipeline in unity. Unity has plans to release their own custom "HD" pipeline that includes a lot of the stuff I've added in this thread. They plan on releasing it with unity 2018 once its out of beta.

    No idea how stable it will be or if it will even come out. They have been saying since 2016 they will be releasing it...

    If it turns out they don't release one i might put some time into it. But i still need to wait till the scriptable render loop comes out of beta.
     
    skyecrack likes this.
  48. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Yeah it makes complete sense to see how their HD pipeline goes. Right now I'm certain it will come out because we can already try it, but as usual there is devil in detail. i.e the focus in 2018.1 is more on the Lightweight pipeline. And the HD pipeline is currently missing some of the higher end features, most notably volumetric stuff. Area lights are in there already though. They have given the impression that things like volumetric lighting/fog will come to their HD pipeline later, but I wouldnt like to make any predictions about exactly what stage of 'later' that will be, eg whether they try to get it done for the release of Unity that focuses more on HD pipeline (maybe 2018.2) or whether it doesnt make it into v1 of HD pipeline.

    Anyway you are certainly one of the asset store developers who I would dearly love to see embrace the pipelines (assuming all goes well with these Unity features) and one day I hope to be talking about your own branch of the HD Pipeline :)
     
    chiapet1021 likes this.
  49. skyecrack

    skyecrack

    Joined:
    Jan 5, 2018
    Posts:
    29
    Yeah, I've looked into SRP as well. But one thing is when Unity rolls out something and we wait half a year (or more) for it to becomes usable, and other is when someone already had a tried and true system doing the same thing years before them. Not to mention some of us folks stuck on the 5.6.x, which I assume you have already tested this on.
    Anyway I'd rather pay than wait, and I'm pretty sure I'm not the only one.
     
  50. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    HD pipeline something similar to Unreal 4 presets (mobile and desktop).
    HD pipeline doesn't mean new real time technique like Svogi without baking :rolleyes:
    Nothing has been announced about a new real time rendering that does not use Enlighten or Octane and that does not do any baking.