Search Unity

[RELEASED] Hx Volumetric Lighting

Discussion in 'Assets and Asset Store' started by Lexie, Aug 1, 2016.

  1. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Hx Volumetric Lighting is the easiest way to get high quality volumetric lighting in your Unity scene, adding depth and realism with rays of light and fog of variable density. It's easy to use and runs efficiently.




    Asset Store link

    Documentation

    IMPROTANT - Unity 5.6 currently has a bug with rendering Particle emitters in a command buffer. So Density particle support is unsupported in 5.6 till unity fixes the bug.

    Features

    • Supports Shadow casting lights
    • Supports multiple lights - any number and combination of point lights, spot lights, and directional lights.
    • It's dynamic - you can move lights around in real-time.
    • Vary the air density with your own particle emitters or 3D noise.
    • Use height fog to get a low hanging fog look.
    • Mie scattering for more realistic results
    • Supports transparency (included standard shader)
    • Supports light cookies.
    • Supports low resolution rendering with advanced up-sampling, allowing faster frame rates.
    • Easy to use. Just drop a few scripts on your camera and lights.


    Requirements

    • Forward/deferred render Path *
    • Linear Color space is recommended (gamma version awaiting approval)
    • Directx 9/OpenGL3 and above.
    • Shader Model 3 and above.
    • Desktop and console support.(mobile is not supported)
    • Custom transparency shaders will need to be modified

    *Is not friendly with MSAA in forward rendering mode (yet), Has the same issue as the directional light shadows because its a screen space effect.

    Roadmap

    • Downsampling depth speed improvements
    • Better depth downsampling
    • Various speed improvements
    • Refactoring of existing code
    • VR support (untested, may already work)
    • Faster transparency and Density support for dx11 (currently using dx9 implementation)
    Known Bugs
    • [2017.3 beta] New version has been submitted to fix compatibly issues with the beta, should be live before the end of Nov

     
    Last edited: Nov 21, 2017
    saukki, chelnok, Lex4art and 18 others like this.
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Excellent work, will be picking this up in the very near future.
     
  3. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    @Lexie - What about using this with UBER or ShaderForge, etc.?

    Also, would it work with water solutions, like AQUAS or Ceto, and sky solutions like TrueSky, and Time of Day?

    Just curious how this behaves in the wider world of Unity environment plugins.
     
    Last edited: Aug 2, 2016
  4. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    it will work with any none transparent shaders you make in ShaderForge and will work with any of the none transparent versions of UBER.

    Transparent versions would need to be edited. Its only a few lines of code.
     
    hopeful likes this.
  5. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I'll push a new build tomorrow that adds some features / bug fixes.
    • Included shader variant collection to fix frame skips when using occlusion culling and different light settings.
    • Gamma support.
    • Option to remove random noise in final apply (used to remove color banding)
     
  6. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I've owned almost all volumetric/fog solutions that have been in the Asset Store over the years and I have no hesitation in saying that this is the best one :)
     
  7. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Hey @Lexie how many custom shader keywords are you using?
     
  8. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    For working custom transparency shaders it adds 6.
    The spot point and directional lights use 12-14. But no other shaders reference most of these keywords.

    I'm cutting these numbers in half in the next build. I was using keywords for features that where turned off (for debugging purposes)
     
    Last edited: Aug 2, 2016
    hopeful likes this.
  9. chiapet1021

    chiapet1021

    Joined:
    Jun 5, 2013
    Posts:
    605
    Thankfully, they're doubling the shader keyword limit in 5.5!
     
  10. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    6 keywords is not terrible in the end although I do find myself avoiding using the keyword heavy assets. This looks really great and while I have something else for mobile thankfully, this looks the bees knees for desktop use
     
  11. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    That's awesome :D I'm running out
     
  12. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    :) they need to!
     
    hopeful likes this.
  13. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I've pushed an update that adds Gamma support, Automatic shader warming and cuts the shader keyword usage in half.
    Just awaiting approval. Transparency only needs 3 keywords now.

    I'm currently working on some web demos and some demo videos to show off the tool.
     
    punk and hopeful like this.
  14. Misciagno

    Misciagno

    Joined:
    Jul 27, 2013
    Posts:
    88
    Has anyone tested how well this works with Alloy?
     
  15. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    What are the expected performance for the asset? Can you post some screenshot or demo with profiler readings?
     
  16. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    Looks just brutal :D

    has anybody tested this with UBER and/or SEGI?

    performance? :)
     
  17. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    "*Is not friendly with MSAA in forward rendering mode (yet)"

    I guess that means VR is basically out of the question at this moment depending what the "not friendly" part means? :)

    Added to wish list anyways.
     
  18. S_Darkwell

    S_Darkwell

    Joined:
    Oct 20, 2013
    Posts:
    320
    @Lexie: This looks fantastic!

    Three questions, though:
    1. How does this interact with emission light sources?
    2. How would this asset interact with an asset such as SEGI (https://www.assetstore.unity3d.com/en/#!/content/64763)?
    3. Is the current price expected to be the final price, or is the price expected to raise over time?

    Thank you and be well!
    - S.
     
  19. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The volumetric effect doesn't get effected MSAA, So if you have really strong volumetric rays going behind an object, the volumetric effect will have an aliased line which can give the effect of AA being turned off. I'm looking into applying the effect before the MSAA resolves.


    It wont interface with SEGI bounced lights, but you could have this running along side it. The way SEGI stores its information should mean I can add support for it. I'm waiting till @sonicether adds cascade volumes before I look into support

    Uber should work out of the box for any opaque shaders, The transparent ones will need a modification, There is a tutorial in the docs.

    Ill answer performance below.

    1) It only interacts with dynamic light sources right now (spot, point, direction). The baked data of enlighten isnt in a format that i can access/raymarch. I'm looking into using light probes to get some ambient light added.

    2) see above answer

    3) no idea.

    Performance is hard to pin down. it depends on the amount of volumetric lights in your scene, how many pixels each light volume takes up, sample count and the volumetric resolution your rendering at. I've spent a long time working on upsampling to make quarter resolution rendering a viable option.

    So far every studio that has tested out my volumetric lighting has reported better results and performance then the methods they where using before.

    I'm working on a video and and some test scenes right now. Hopefully ill have them live soon.
     
    Last edited: Aug 3, 2016
    Drommedhar, IronDuke, Ostwind and 3 others like this.
  20. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I'm currently working on adding unity Terrain support for all the tree and grass shaders, I'll also convert all the other transparency shaders while I'm at it.
     
    Drommedhar and nxrighthere like this.
  21. Drommedhar

    Drommedhar

    Joined:
    Sep 24, 2013
    Posts:
    78
    So far I love the way the Volumetric Lights look and how low the performance impact is.
    But I have a rather simple question:
    Is there a reason why you locked the Extinction value to a max of 0.5f? Because I manually set it up to 2.0f because I want fewer geometry being visible "inside" the light and it looks fine to me. Just want to double check if there is anything which we should know that can happen by doing this.
    Great asset already *thumbs up*
     
  22. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Wont impact speed at all. I limited it to 0.5 because I didn't think people would need it to go any higher. Good to hear its working well.
     
  23. iamsam

    iamsam

    Joined:
    Dec 22, 2013
    Posts:
    233
    This looks amazing, great job!!! Do you have any or plan to do a demo of an indoor scene to see how the asset can help boost it.
     
  24. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I got it working automatically with unity's tree shaders. Before the billboarded trees at a distance wouldn't render correctly.


    I needed to do this before I could make marketing material because all of the scenes i've bought off the asset store used the inbuilt tree shaders.
     
    nxrighthere, Drommedhar and punk like this.
  25. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    And Speedtree ...? :)
     
  26. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Speed tree is all alpha cutout. So the system should already work with it.

    Generally anything that writes to the depth buffer is supported.
     
    Drommedhar and hopeful like this.
  27. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    1.0.1 should be live now/shortly.

    Nothing major in this update. Just some steps towards gamma support and halved the shader keyword usage.
    It now auto warms up all the shaders needed in your scene, so you wont get little hiccups if a new shader is needed during a playthrough. The settings for this are in the advance section.

    I'm pushing 1.0.2 now, The changes in 1.0.2 are
    • Finalized Gamma support
    • Fixed transparency issues
    • Added tree creator billboard shader support (will need to turn on transparency support)
    • Added a few inbuilt transparency shaders that you can use.
    • Fixed issue with single ambient light not applying the right color.
    • Fixed bug in fog height calculation...
    • Fix bright spot on directional light
    • Added scene view support in unity 5.4+
     
    Last edited: Aug 6, 2016
    AdamGoodrich, ZJP, elbows and 2 others like this.
  28. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Just replaced my existing solution with yours I'll post some pics/review soon, but first impressions are fantastic, tons of options, great performance, thank you loads for doing this
     
  29. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    @Lexie is there a way to 'Tint' the volume? eg I have a point light that's orange and I want the volume to be tinted a different color. The Color option kinda does, but when I use that option the volume no longer respects the light Intesity
     
  30. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Hmmm, It should still use the lights intensity when you override the color. I should probably add a slider for a custom intensity though.

    Normally if you wanted to tint all the lights slightly blue (eg far cry primal at night),you would add a directional light with some ambient strength and the ambient color set to blue. this would make distant lights slightly blue because the directional light would calculate all the ambient lighting between it.
    Note: there is a bug with single color ambient lighting, it's fixed in the next build. (use gradient mode in the meantime)

    I'm adding some features so you can override the ambient lighting in case you want different values then the ones set in lighting-> ambient
     
    Last edited: Aug 6, 2016
    punk and hopeful like this.
  31. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I've been experimenting with some gradient options for volumetric lights. They look really cool but unless I modify unity's internal lighting shaders the lighting in the environment doesn't match. I'm thinking if I add a fog color to the air it could achieve something similar and allow people to tint all the lights in the scene. @punk

    Volumetric lighting in a density particle cloud - Left is a red to blue gradient, Right is all the same color red.
     
    Ostwind and AdamGoodrich like this.
  32. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    That looks groovy!
     
  33. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Ok i think I've finalized the tint and ambient lighting stuff. Here is a preview of the new menu


    Ambient stuff allows you to override unitys ambient lighting settings in the window->lighting->ambient.

    Tint mode allows you to either tint everything by a color, or do edge tinting or gradient tinting, Gradient and edge tinting can give you an effect like the image above.
    Hopefully I can get this in 1.0.2. Ill double check all the code tomorrow and push a build.

    Thanks for the suggestion of a tint feature @punk
    If anyone else has any feature requests, let me know.

    I know a few people that use the Sunshine plug-in to render custom shadows and volumetric lighting, and although my volumetric lighting has a better/faster volumetric pass, it doesn't give you some of the nice features like custom shadows. This is holding a few people back from converting over to using my system.
    So the next feature I'm going to add is support for sunshine custom shadows, this means users can get the best of both worlds. The custom shadows from sunshine and the better/faster volumetric rendering of my system.
     
    Last edited: Aug 7, 2016
  34. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    That looks neat ;)
     
  35. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    I own Sunshine already and use it for volumetric lighting. is there any advantage on this asset for me?
     
  36. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    My volumetric pass has better quality at half and quarter resolution, This means you get better quality to performance using my system. It also has a lot of extra features that sunshine doesn't have. For example my system supports directional, point and spot lights.

    My system uses unity's shadow maps to render all the volumetric lighting, where as sunshine renders its own custom shadow maps for its directional light (generally slower then unity can render them because it doesn't do shadow culling).
    But sunshine does have some nice features with its custom shadow maps like only rendering the shadow maps once, or only updating one shadow cascades per frame. So I'm working on a build that will interface with sunshine's custom shadow maps so users can get the best of both worlds.

    tldr. mine has better performance to quality then sunshines volumetric lighting + supports more light types, but if you want to keep sunshines custom shadows I'm working on a build that works with it.

    hope that answers your question.

    I've updated the hxVolumetricLight script. The editor is a lot nicer now and has more override features. Should make it into 1.0.2. If you enable the little tickboxs on the left it allows you to override any of the global volumetric settings.

     
    Last edited: Aug 8, 2016
  37. Skyfly

    Skyfly

    Joined:
    Jan 25, 2014
    Posts:
    110
    Has anyone tried it with VR?
     
  38. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Partially supported at this stage. I tried it with a DK2 and it seemed to work ok, but not when single pass stereo rendering was on.
     
    Skyfly likes this.
  39. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    As @elbows said its not fully supported yet, Its on my the road map though. I have some ideas on how I can improve the results using information from both eye and adding single pass stereo rendering should speed it up.

    In other news 1.0.2 should be live. Let me know if there are any issues.
     
    Skyfly, punk and Marked like this.
  40. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    Is it possible to create a rectangular beam of light instead of a cone-shaped spotlight? I tried using a cookie, but that only affects the shape of the light when it hits a surface, not the shape of the shaft itself.

    I'm thinking something like the geometric fog in this asset, although I'd like a higher density: https://www.assetstore.unity3d.com/en/#!/content/2807
     
  41. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    This plug-in is more focused on adding volumetric lighting to unity's in-built lighting. What your talking about would require an area light to work correctly. I could give the spot light a feature that turned it into a rectangle, But the shadows would look as though they where coming from a spot lightlight.
     
  42. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    324
    We bought this yesterday and are blown away with the results!

    https://gyazo.com/3a87f130e13b801e86737e5835cf686b
    Right now we're using it to build the trailer for HoloBall (PSVR launch title), but I'd love to get some of these effects in VR! We have about 4 weeks left until submission needs to happen.

    Any ETA on VR support?
     
    Skyfly, punk and Ostwind like this.
  43. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Just dropped you a review, i'm getting very results, great work - here's a pic

     
    Dreamaster and Lexie like this.
  44. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Hopefully have a beta in 2 weeks.
     
    pixelsteam, Skyfly and shawnblais like this.
  45. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    324
    That would be rad. Thanks!
     
  46. HR0THVITNIR

    HR0THVITNIR

    Joined:
    Nov 21, 2013
    Posts:
    24
    Didn't see anything in the docs or thread about lighting from emissive materials. Any chance this is on the roadmap?
     
  47. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Not with enlighten, its not stored in a way that is accessible. I might be able to use light probes to gather the ambient lighting and store it in a 3D texture, but it would be a dx11/unity5.4 only feature.

    SEGI would be doable, but ill wait till thats more stable before adding support.

    Ill do more experimental stuff after i get everything else working 100%
     
    punk and Crossway like this.
  48. HR0THVITNIR

    HR0THVITNIR

    Joined:
    Nov 21, 2013
    Posts:
    24
    Was planning on trying out SEGI at some point, so yeah, hoping these two projects can work well together (at some point - also, I don't see being DX11/Unity5.4 only as a problem).
     
  49. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I wanted all the base features to work in 5.1.4+ and directx9 more advanced stuff will come later.
     
    Crossway likes this.
  50. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hey Lexie, do you have benchmarks in ms cost for the effect vs not applying the effect? thanks!
     
    CWolf likes this.