Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Volumetric fog?

Discussion in 'Graphics Experimental Previews' started by id0, Apr 20, 2018.

  1. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    384
    There is a volumetric fog option in HDRP Scene Settings Volume, but I don't understand how to use it. Or it's not working yet?
     
  2. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    It's not working yet.
     
  3. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    141
    New refraction also not woking yet or its only my issue? Have black areas inside of objects with both ray types
     
  4. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Last edited: Apr 21, 2018
    FROS7 likes this.
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    Patience all :)
     
    JakubSmaga likes this.
  6. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
  7. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Although note that a couple of the latest fixes and turning on of volumetric lighting codepath by default are shown in the changelog under the 2018.1 undecided section, rather than the previous ones which fell under 2018.1.0f2 in the changelog.

    I'm confused about when I might expect to be able to try this stuff using a publicly available unity version. So I'm going to resist making assumptions although I hope for the best.
     
  8. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Is there something volumetric-fog specific in 1.1.5 or are you posting in the wrong thread?
     
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    Well 1.1.5 is supposed to have this enabled by default? I am happy to remove my posts about it if that's not the case. Edit sorry for confusion, I guess we still need to expose it manually. I could have sworn the plan was to turn these on by default for this version.
     
  10. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Its very easy to get confused about this stuff and I hope some of the unnecessary confusion is eliminated soon. For example it is great that the changelogs for the pipelines are there and contain useful info. But since we are presently used to getting versions labelled as 1.1.5 etc, rather than Unity version number, there is certainly room for confusion when trying to match things up to changelog notes. Likewise 2018.2.b1 coming out before 2018.1 final release preparations are complete leaves me wondering whether any of the more recent changes are in the 2018.2 beta yet or not, and whether some stuff on github that doesnt work with the public version of 2018.1 beta will work with the 2018.2 beta.

    I mostly figured out that the latest stuff thats been mentioned in this thread in recent days is not in 1.1.5 because of what I already understood from the changelog, and the 1.1.5 release looks to be s snapshot of the 2018.1 branch on github which doesnt have these latest commits relating to volumetric fog.

    Anyway although I am completely in favour of the policy of not nagging Unity for release estimates that they cannot provide, I think there is enough volumetric stuff on github now, and mentioned enough in changelog, that someone from Unity might be able to provide just a little more clarity about the timing/versions to expect this stuff, in relation to either 2018.1 or 2018.2 versions of Unity. Or at least confirm or deny whether I have read the available information correctly.
     
    hippocoder likes this.
  11. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Since I asked for clarity about my reading of the changelog etc, I suppose I should explicitly spell out what I think it means:

    2018.1 release version has a couple of fixes and improvements related to volumetric lighting, but still not on by default.

    A presently undecided version of 2018.1/pipeline will enable volumetric lighting code path by default, and already contains a number of fixes relating to volumetric fog and density volumes. I would like to know if its possible we'll actually end up getting to try these with a 2018.2 beta version before the suitable 2018.1 release is available, or am I barking up the wrong tree?

    I suppose I should also point out that the link to the changelog earlier in the thread is likely tied to a specific version of the changelog, and hopefully the following link will always reveal the latest version:

    https://github.com/Unity-Technologi...eRenderPipeline/HDRenderPipeline/CHANGELOG.md

    Finally if someone can remind me whether its possible to manually turn on the volumetric lighting code path with existing version, and point me in vaguely the right direction, that would be great. I understand what fixes I'll be missing, but without these does it work at all at this point if enabled manually with, for example, 1.1.5?
     
  12. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Hey @SebLagarde,

    Could you answer @elbows's questions or just give us an update on the topic? We're all really excited about this feature.

    Greets,
    Jakub
     
    Last edited: Apr 30, 2018
  13. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    141
    @elbows just grab master branch from github and open it with 2018.2 beta. Working perfectly for me
     
  14. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Massive thanks for the tip :D Never really being sure whether theres much point trying the master branch with any particular Unity beta release at a particular moment in time has been one of the main frustrations for me, there was a time when the available unity version was quite far out of sync with master HD pipeline so I stopped trying, sounds like I should have tried again with 2018.2 beta, cheers!
     
    hippocoder likes this.
  15. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    I think I'll wait until it is available from package manager! That's quite enough putting my foot in things for one day :)
     
  16. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Yay, I got it working using github master and 2018.2b1, thanks for the tip!

    It's in about the state I expected - some limitations of the technique (eg ghosting when moving the lights themselves quickly), lack of area light support etc. And a bit of flickering/vibrating shadows in the volume which are obviously more notable if certain settings are cranked up to silly values, and can hopefully be improved over time.

    Spotlight set to box shape works quite well with the volumetric fog as far as I can tell in my very brief testing :)
     
    hippocoder likes this.
  17. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    384
    Yeah, it's working now, but also it very slow and glitchy.
     
  18. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    Wait, how do you guys make the master branch work with x.2 beta?
    Oh got it to work, missing a crucial files from the repo :p
     
    Last edited: Apr 27, 2018
  19. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    I note the local fog density stuff supports a noise texture as of an hour or so ago on master branch. Comes with a utility to convert a 2d texture to a 3d one.

    I cant say I had any luck getting it working yet.
     
  20. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    Sounds like the HD team are busy creating masterpieces of their own. Can't wait.
     
  21. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    If I am still following along properly, the changelog is presently slightly out of whack with reality when it says the following:

    Out of whack with reality because subsequent updates (which are also covered in the changelog) mentioned that VolumetricLightingController has been re-implemented to be part of the Interpolation Volume framework, so its not a component you stick on your camera any more, you now set it up like other scene settings.

    I tried it both before and after that change so the out of date instruction in the changelog leapt out at me and I thought I may as well mention it.
     
  22. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    and it seems the last update remove directional light support
     
  23. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Not deliberately. I speculated to myself that this was due to them forgetting something when the volumetric dimmer parameter was added to lights the other day.

    And indeed, I had a quick look and think there is a little bit missing from GetDirectionalLightData in LightLoop.cs.

    A line such as the following is required to add the dimmer value to the directionalLightData:

    directionalLightData.volumetricDimmer = additionalData.volumetricDimmer;
     
  24. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    I raised it as an issue on github and they pushed the fix already - how I love this era :)
     
    glenneroo and hippocoder like this.
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    Oh wow, that was fast :D
     
  26. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Can get some lovely results by using a cookie on spotlights. I've also been playing with Ultra mode (by changing volumetric lighting preset value to 2 in both ShaderConfig cs and hlsl files).
     
  27. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    Oh you can do that? haven't dig deeper into HDRP, Nice
     
  28. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    I'm still waiting calmly for a public preview build with volumetric fancy wonders :D
     
    JakubSmaga likes this.
  29. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    Can you point me which hlsl files that you changed?
     
  30. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    719
    Same here :D
     
  31. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Reanimate_L likes this.
  32. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
  33. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    upload_2018-5-9_2-45-19.png
    Man i love you HDRP Team
     
  34. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    I got the noise texture working - there was a bug in an error message so I didnt know what texture format it was expecting. I raised that issue on github and having fixed my local copy in the meantime determined the format should be Alpha8. I havent attempted to use a totally appropriate texture yet or mess around with my own 3D textures (rather than use the 2d->3d converter provided) but the functionality works.
     
  35. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    71
    I wonder if that "ghosting when moving the lights themselves quickly" limitation is something that can be improved or fixed in the HD pipe... or we need to live with it. Making a moving flashlight / car headlight would be awesome without that ghosting!

    WOW... great!!!!
     
  36. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    I have yet to fully explore the entire codebase and code comments for this system, but I think I saw some comments in there about needing to disable use of the history buffer for lights that are moveable. But the history buffer is there for a reason, I believe so that a lower voxelization resolution can be used and results accumulated over a number of frames to compensate, or something of equivalent effect. So it is reasonable to anticipate that a solution to ghosting is feasible, but at the expense of a different type of visual quality.
     
    cfree likes this.
  37. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    i don't see any ghosting on ultra settings
     
  38. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Ultra does not change the ghosting issue for me, nor would I expect it to. Lets try to establish why we are not seeing the same thing:

    a) the ghosting doesnt happen if not in play mode, eg I can change the transform position on a point light very quickly and there is no trail, so long as I am not in play mode.

    b) in play mode, a point light that is changing its position at any kind of speed should leave a ghost trail. Sometimes this effect actually looks quite nice but will not be the desired result at all for many situations. Its even more obvious with, say, a large spotlight set to box shape and moving rapidly left-right etc.

    c) moving the camera does not lead to this ghosting, just moving the lights themselves.

    d) not sure if it shows up less with lower framerates or the other way around, and since ultra mode is quite heavy perhaps this is a factor affecting your results, I have no idea.
     
  39. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,427
    Ah. . . . i haven't try moving the lights. That might be it.
     
  40. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Ah yes that will be it.

    And just in case anyone mistakes my posts about this issue, its something I always expected to see with this technique and I'm not complaining about it, just talking about it and how it sounds like there will be a workaround for it (with a different side-effect) at some point.

    Anyway I think its time for me to poke at the code and see if I can misuse the density texture facility :D
     
    cfree likes this.
  41. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    It didnt turn out to be very hard to bypass the volume texture atlas and use a 3D RenderTexture from a fluid sim instead. The results are a lot of fun, although I am not suggesting this is an especially practical technique due to the simulation cost to the GPU. Great for some non-game scenarios though and I'm still getting over 60fps with a 1080ti, even at this early stage of the HD pipeline and me running the fog in Ultra mode and my fluid sim at 128x128x128 res.

    Crude, early video of it working to follow at some stage in the coming week.
     
    cfree, one_one and hippocoder like this.
  42. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Early tests using the aforementioned realtime fluid sim:





     
  43. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    384
    Awesome!
     
    elbows likes this.
  44. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Cheers. One more test for now, this time with a directional light and trees with wind. Not going for a 'realistic' look, just having a play around to see what might be possible.

     
  45. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    Like it a lot, nice one.
     
    elbows likes this.
  46. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    384
    Wow, how did you do this?! Will you share it somewhere?
     
  47. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    I always intended to share the sim code eventually, once I had finished using it for some of my own 'art' type projects. Especially since it was originally based on other code that was generously shared (3D fluid sim example by Scrawk, from method described in GPU Gems). Over the years I've used a variety of 3rd party assets to render the results of the sim, usually by using the density 3d texture from the sim in conjunction with 3rd party fog systems, but I've also used the velocity vector texture from the sim to drive GPU particle systems. Those assets arent free and usually required a small amount of code hacking, since my integrations are experimental rather than polished. So I figured I'd wait for the next generation of Unity stuff, the volumetric fog in HD pipeline and also the new VFX GPU particles coming later this year, and then see how best to go about sharing. Especially since these new Unity systems require compute shaders and my sim is all compute shader based.

    As I said in a previous post, I dont really consider this particular sim to be an ideal candidate for volumetric fog animation, for performance reasons. It's sort of semi-practical for certain limited scenarios so I try to keep an open mind, and I do intend to experiment with lower sim resolutions at some point to see if it is more workable than I have sometimes assumed. At this stage it is probably best to think of these experiments as an attempt to encourage others to come up with animation for volumetric fog that go beyond simple static texture UV animation, and even if I get the performance of my system right one day it is unlikely, though not impossible, that I will be the person to attempt a proper, well integrated Unity solution that comes with the tools and features that people would really expect from a game engine.
     
    Last edited: May 21, 2018
    Paddington_Bear and id0 like this.
  48. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    71
    I friends!
    I need help to play with the new Volumetric Lights... i have the default scene in 2018.2 beta and the last HD render pipeline code... how can i set the scene to have volumetric fog, and the lights to affect the fog?
    Thanks!!
     
  49. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    384
    You must create GameObject/Rendering/SceneSettings, and change fog to Volumetric. After that all lights in the scene will be automatically volumetric. But if you download HDRP in package manager is not there yet. You need to use github version.
     
  50. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    719
    I have been trying that since it was first available but it never worked for me, maybe I'm missing something that's right in front of me. Just waiting now for a release as a package to see if I can get it working then.
     
unityunity