Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Volumetric fog?

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

  1. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    I'm not feeling well but perhaps the following screenshots and checklist that I've just cobbled together will give some clues.

    Make sure HD pipeline is working.
    Make sure Volumetric Fog and Volumetric Lighting Controller are added to scene settings via 'Add component overrides...', and that boxes next to options in these components are ticked (eg by pressing All).
    Make sure Volumetric is selected in Scene Visual Environment Settings.
    Default Mean Free Path is a very high number - either make this number very low to see the fog clearly, or create a new gameobject and attach a Density Volume component to it, scale and position the gameobject appropriately, play with Mean Free Path setting in this Density Volume.

    Vol1.png

    Vol2.png

    Vol3.png
    Vol4.png
     
  2. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    320
    This is correct settings:
     

    Attached Files:

    RoxasXD likes this.
  3. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    Ah thanks man! this is what I was missing. I knew it was right in front of me, just didn't think I would need to change it in the Visual Environment to enable it.
     
    elbows likes this.
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,811
    On 1.1.8 at the moment via package manager - still no pm release for volumetrics.
     
  5. EngineArtist

    EngineArtist

    Joined:
    Nov 3, 2016
    Posts:
    7
    Can the fog be localized to a volume, say, a cube, like in the image below? Or would that require a special volumetric material of some kind?
     
  6. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    The system has density volumes. You can set the overall fog to be imperceptible or only subtly affecting the sky for example, and then have density volumes covering areas where you want very visible fog, just like in your image. You can also attach 3D textures to density volumes to have more control over how they look.
     
  7. manran

    manran

    Joined:
    Jan 30, 2014
    Posts:
    34
    hello guys i've read your wonderful inputs, may be you can help me , in my scene the volumetric rays don't appear. I've already edited the shaderconfig.cs files but no luck . You can see the scene here. I'm using Unity 2018.2.0b4 , HDRP 1.1.10
     
    Last edited: Jun 8, 2018
  8. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    Did you mean version 1.0.10? I haven't used that one but I know that Volumetric Fog is available in the newer versions of HDRP from the Package Manager, so version 2.0.0 or if you get the master branch on GitHub.
     
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,811
    1.1.10-preview is the latest package manager version, and it's not enabled there yet.
     
  10. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    Ah, 2.0.0 might be in staging. I keep forgetting I have that enabled in my manifest file, you could also download those versions from the Github Tags. That's where I usually check to see if there's a new package version
     
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,811
    I work using Unity collab, so there's a team. I can't go and overwrite other peoples packages with manual downloads but the staging thing sounds like a good idea if it will also get sent across.
     
  12. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    Yea that's just an update to the manifest file so if collab allows commits from those folders then you're good. Haven't tried Collab myself (I use another SVN) so I'm not sure but I would guess it should since it's developed by unity and they probably thought of using Package Manager with it.
     
  13. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    65
    Please, show us your scene after you manage tho get the Volumetrics working :)
     
  14. manran

    manran

    Joined:
    Jan 30, 2014
    Posts:
    34
    Still not working for the moment, but i will show it once it works

    Please can you show me step by step how to activate it or establish the volumetric fog in a scene ?For example yous ay it's in the package mnager, i've searched but the is no such Volumetric Fog package. Thanks
     
  15. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    @manran First you need to edit the manifest file in the Packages folder
    Add ( "registry": "https://staging-packages.unity.com", ) - Ignore the version numbers for now
    upload_2018-6-9_0-32-42.png

    After you can open the package manager and it will show the newer versions that aren't available by default (I believe these are packages that are being tested before full release)

    Example - For me, 2.0.1 makes the camera washed out for some reason so 2.0.0 is the highest I can use these aren't fully released packages so something could go wrong with a version and it's probably known already.

    upload_2018-6-9_0-36-48.png

    After that's installed add a Scene Setting to your scene Game Object -> Rendering -> Scene Setting (Configure it for your scene) - If you have one already skip to the next step

    Now you will add the components needed for volumetric lighting to the scene settings
    Volumetric Vog and Volumetric Lighting Controller - You might use the Volumetric Controller or not depends on your scene.

    Under Visual Environment - Change Fog Type to Volumetric
    upload_2018-6-9_0-52-36.png

    Now change Mean Free Path under Volumetric Fog to something low - Lower the value = Denser the fog
    upload_2018-6-9_0-53-2.png

    Shot from the Fontainebleau Demo by Unity that I added Volumetric fog to and slightly edit the lighting.
    upload_2018-6-9_1-36-12.png
     
  16. manran

    manran

    Joined:
    Jan 30, 2014
    Posts:
    34
    It finally worked , thank you so much for this detailed step, you deserve a medal :) , you all deserve medals. Here is the image with the effect :) . Still missing many things. I'm learning the volume texture 3d stuff now tiger13.png
     
    Last edited: Jun 9, 2018
  17. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    320
    manran how did you make a tigra?
     
  18. Paddington_Bear

    Paddington_Bear

    Joined:
    Dec 9, 2012
    Posts:
    274
    I would definitely be interested in having a tinker with this when/if you decide to release it. I know a boffin who might very well be able to speed it up, depending on the method. Beautiful work none the less.
     
  19. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    Thanks. There are not many ways to speed it up significantly though, no getting away from the heaviness of the underlying simulation, very much including the amount of memory used for multiple 3D render textures. There are other limitations too that can severely impact on practicality, such as the fact it is trapped in a grid so does not lend itself to being used with large foggy scenes, especially since it cant be tiled seamlessly. I mostly only use this stuff myself because I have the luxury of doing arty stuff with it, rather than trying to make it practical for games. So just be warned that when I eventually share, it wont be as a system thats ready to go for people to use in a practical way with volumetric fog. I think this is worth harping on about because the entire point of modern volumetric fog solutions for games is that they dont add too many milliseconds to the GPU budget so are practical, and in this sense my sim is a very poor fit indeed!

    In the meantime, since me sharing it is nowhere close to imminent, you can get some sense of performance costs by looking that the sim that mine is heavily based on. Performance is not the same because I rewrote it to use 3D textures instead of buffers, which helped avoid the need to do certain operations, but you'll stil get a sense of how heavy it can be and how changing 3D grid sim resolution makes a big difference to visual quality and performance.

    https://github.com/Scrawk/GPU-GEMS-3D-Fluid-Simulation

    Honestly, when it comes to animating noise in volumetric fog systems, I have not really looked into all the possible methods for doing so in a performant manner, but there ought to be lots, and they will be so much more suitable than anything I have to offer. Just one example, the recent work documented by this person on twitter: https://twitter.com/teknic
     
    Paddington_Bear likes this.
  20. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,811
    Anyone got a spare fancy noise texture we can use for the Density Volume? :)
     
    GamdineProductions likes this.
  21. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    I probably should play with the standard volumetric texture stuff so I can provide some help on this. I know the versions of HDRP I've played with come with a very simple 2D->3D texture converter to help people with this, although from memory I think you need to make sure you feed in a 2D texture that is of Alpha8 format, or the resulting 3D texture wont be in the right format to work.

    Personally I probably favour having a quick look on github for any historical '3D noise generator' code people have shared over the years, which probably wont require all that much effort to use as source textures for this system. Although again from memory I think the system uses a rather low texture resolution (32x32x32) for the volume texture atlas, so a lot of options might be overkill, not entirely sure. I will report back once I've dwelt on this some more and have actually tried the latest package manager release.
     
    id0 and hippocoder like this.
  22. Ekincan

    Ekincan

    Joined:
    Sep 8, 2015
    Posts:
    16
    Does this volumetric lightning also work with baked light sources ?
     
  23. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    65
    I tried Volumetric Light in the Sample Scene... even static, it is flickering a lot to me... any setting i need to change in order to make it "stable"?
     
  24. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    320
    Just update new version from github, and volumetric is broken... again.

    Code (CSharp):
    1. ArgumentException: Kernel 'VolumetricLightingClustered' not found.
    2. UnityEngine.Experimental.Rendering.HDPipeline.VolumetricLightingSystem.VolumetricLightingPass (UnityEngine.Experimental.Rendering.HDPipeline.HDCamera hdCamera, UnityEngine.Rendering.CommandBuffer cmd, System.UInt32 frameIndex) (at C:/2018/ScriptableRenderPipeline/com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/VolumetricLighting.cs:636)
    3. UnityEngine.Experimental.Rendering.HDPipeline.HDRenderPipeline.Render (UnityEngine.Experimental.Rendering.ScriptableRenderContext renderContext, UnityEngine.Camera[] cameras) (at C:/2018/ScriptableRenderPipeline/com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs:1060)
    4. UnityEngine.Experimental.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Experimental.Rendering.IRenderPipelineAsset pipe, UnityEngine.Camera[] cameras, System.IntPtr loopPtr) (at C:/buildslave/unity/build/Runtime/Export/RenderPipeline/RenderPipelineManager.cs:32)
    5. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  25. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,811
    There's no guarantee github versions will work (they said this often). Adding staging to manifest is the safest way to get latest that should work (via drop down list).

    These usually mirror the releases section so that's 2.0.3 for me.
     
  26. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    By the way, todays Unite optimising Book of the Dead for high-end consoles talk mentioned the reason why a custom atmospheric scattering feature was used in that demo. It was because the standard HD pipeline one wasnt available at the time. So they took the work they had from the blacksmith demos atmospheric scattering and adapted it for HD pipeline. This is specifically mentioned as a good example of customising the pipeline for your own specific project.
     
    TerraUnity likes this.
  27. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    57
    Yeah. I had a problem with updating the github HDRP: all the render made artifacts. I've cured it by deleting the Library folder :)
     
  28. Alimohammadlo

    Alimohammadlo

    Joined:
    Jun 20, 2017
    Posts:
    14
    hello every body i am on working hd render pipline and make volumetric lights looks like this is image please help me tanks every body
     

    Attached Files:

    • 26.jpg
      26.jpg
      File size:
      124.4 KB
      Views:
      756
  29. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    799
    In Book of the dead demo it was said volumetric scattering was used. Is volumetric scattering the same as this volumetric fog or is it from Blacksmith demo 2015?
     
  30. Alimohammadlo

    Alimohammadlo

    Joined:
    Jun 20, 2017
    Posts:
    14
    ohh ok you can show how to use this is ? and whay find this is scripts ?
     
  31. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    It's the Atmospheric Scattering from the Blacksmith Demo converted to work with HDRP in Book of the Dead. Seems using it you will have to use the version of HDRP it was released with for Book of the Dead Environment or if you know what you're doing you can add it to another version. There should be a version of Atmospheric Scattering coming officially in HDRP so we just have to wait for that.

    Linear and Exponential fog is already in HDRP just not a full Atmospheric Scattering model yet.
     
    TerraUnity likes this.
  32. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    I havent tried the latest github version for some weeks now, but I note there have been some improvements made to the system, including quite a few things today. Changes include:

    Tooltips that properly explain what quite a few of the volumetric parameters do
    A global volumetric dimmer
    Ability to enable high quality volumetric mode via pipeline option, rather than having to edit a couple of pipeline files.
     
    Reanimate_L and hippocoder like this.
  33. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,811
    Nice, I shall take a peek at the HDRP team's eye candy goodness.

    Regarding the volumetric thing I'm struggling with it. The 32x32x32 texture I can use is barely useful. What is your opinion on that? Is it a mistake my end?

    I am able to generate a 3D noise texture of course, but when there's only 32 pixels to play with along a given axis it seems regulated to just falloff style patterns or blobs.

    It's my dream to have wispy and intriguing rolling and tumbling fluid like fog, perhaps by sampling and adding together two scrolling 3D textures, or some other thing I haven't worked out. That wonderful yet mysterious look you certainly do know what I am talking about as a fellow enthusiast from what I saw earlier!

    Would like to know how stupid I'm being :)
     
  34. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    525
    Hi guys is there any way to raise resolution of the fog?
    Im getting these jagged results (spotlight on the left) with any settings

    upload_2018-7-2_17-52-56.png
     
  35. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    I doubt you have done anything wrong. There really hasnt been much communication from the team about volumetric fog in HDRP, so I'm not really sure. Emphasis seems to have been placed on performance, and having a density texture atlas so that multiple different density volumes can be used in a scene in an efficient manner. But I dont know what their use case scenario was that gave acceptable results at such a low resolution.

    The reason my customised/hacked experiment didnt suffer from the 32x32x32 resolution is that I pretty much bypassed the entire texture atlas system and just had it read from the higher resolution 3D rendertexture that my system was already outputting.

    I am a bit out of date though, and they reworked the system quite a bit since I did my hack. For example it seems they since added support for using different mipmap levels of the texture, but I am pretty ignorant about mipmapping in general so I dont really understand the implications of this.

    I dont know if they have another plan for this stuff in the future, I kind of expect that if HDRP eventually settles down with things still in this sort of state, someone else will offer alternatives for this part of the system. It would also be nice if, for example, when the VFX particle system for HDRP is out, there was a way to use particles to influence volumetric density.
     
    hippocoder likes this.
  36. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    This stuff is largely a consequence of the volumetric system doing its work at a lower resolution in order not to kill performance. There are currently 2 different resolution options available, but the way to activate the higher resolution mode varies depending on what version you are using. eg as I mentioned earlier today, the current github master now has a simple way to enable the higher resolution mode via HDRP pipeline asset settings. I havent tried that yet, but I will. If you are using a version that does not include todays latest changes (eg a package manager version), then you have to edit two files to enable the higher res mode:

    com.unity.render-pipelines.high-definition/HDRP/ShaderConfig.cs
    Change it so that VolumetricLightingPreset = 2
    (1 is the default)

    com.unity.render-pipelines.high-definition/HDRP/ShaderConfig.cs.hlsl
    Change it so that #define SHADEROPTIONS_VOLUMETRIC_LIGHTING_PRESET (2)
    (again, 1 is the default)

    I was making these changes back when I had my own copy of the pipeline code, whereas with package manager version you wil probably need to change these files in the central package manager cache, and so you may also have to deal with issues relating to whether these files are read-only on your system.

    Both these files have to be set to the same value, and shaders will then recompile, otherwise the system will break. And as mentioned above, they have made this much easier to do in very latest master version, you just have to tick an option called 'increaseResolutionOfVolumetrics'.

    There may be other ways in which they can deal with artefacts around the source position of lights when used with volumetric system. I know I have seen similar artefacts with spotlights etc when used in engines other than Unity, and I think they maybe implemented a few tricks to improve things. And as I've been saying lately, I am a bit out of date so for all I know Unity might have done some work on this themselves recently. There are limits to these systems though, various tradeoffs between quality and performance, so I dont really know what the best results possible might be.
     
    thelebaron, cfree and pointcache like this.
  37. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    I just got done giving the latest github version a try. The convenient setting to use higher quality volumetric mode does indeed seem to work as expected :) Also as expected, it makes a notable different to the spotlight artefacts you mentioned.

    NewVolumetricSetting.PNG
     
  38. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    Just for the benefit of anyone reading this thread in future, who may not be keeping up to date with the HDRP changelog, the above setting was included in package manager HDRP version 2.0.5-preview.
     
  39. Arhowk

    Arhowk

    Joined:
    Apr 29, 2017
    Posts:
    9
    TerraUnity and elbows like this.
  40. poa123

    poa123

    Joined:
    Jul 13, 2018
    Posts:
    22
    Hi all!

    How can i setup the volumetric fog in order to make it avoid indoor spaces?

    Volumes inside volumes does not overwite the "parent" fog, so i can not place a new volume with no fog in the indoor space...

    Thanks a lot!
     
  41. ramos123

    ramos123

    Joined:
    May 29, 2013
    Posts:
    7
    Hey guys! I've been working with volumetric fog for a while, and I' start having this problem, there's a square in play view that does not render the fog when game it's running, does anyone know how to solve it ?

    1.PNG
     
  42. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    289
    Note that all the volumetric system is still quite new and not finalized :)

    For the moment the density volumes are additive only. Your use case of having a global fog with a "hole" inside for indoor space is a good example to implement subtractive volumes.

    Could you explain more how you did this setup ? Or maybe even better, share your scene ?
     
  43. unity_rxMfYuEm2kRXRw

    unity_rxMfYuEm2kRXRw

    Joined:
    Jul 2, 2018
    Posts:
    2
    Hi all,
    could someone provide a scene file with a local volumic light setup? For some reason it's not working in build 2018.0.0f2 with HDRP. Also tryed AURA ... but it's not working with HDRP. How do you get a normal Spotlight with local volumic control?
    Thanks a lot!
     
  44. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    A lot of info on how to set Volumetric lighting up at the top of this page.
     
  45. unity_rxMfYuEm2kRXRw

    unity_rxMfYuEm2kRXRw

    Joined:
    Jul 2, 2018
    Posts:
    2
    I know ... i tried to follow the infos up at the top, but for some reason I couldn't get it to work ... this is why I asked if someone could provide an easy setup exapmle. Thx
     
  46. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    729
    Simple question: How can we use both Volumetric & Exponential fog alongside each other in one scene?!

    The Atmospheric Scattering in Book of the Dead was exactly doing this where we had full volumetric lighting going on blended with controllable fog to simulate aerial perspective for further viewing distances at the same time.

    Also tried to blend 2 Scene Settings, one global and one local but I don't think that's possible! Also tried Density Maps to try to override the global Scene Settings and get Volumetric Fog from the second Scene Settings but that does not work either. So is it possible to have some sort of local Scene Settings blended with another one?

    I thought that you can have 2 Scene Settings sitting on a scene both global and both with the same priority and then blend them together using Weight parameter! The Weight parameter is being applied based on height of the whole scene, is that correct?
     
  47. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    I dont think its supported yet. There is a branch on github where some work to implement a mixed mode that supports both these fog types was done in June, but I havent seen any signs that this work was finished and merged into a main branch (though I might have missed something).

    https://github.com/Unity-Technologies/ScriptableRenderPipeline/commits/MWU/MixedFogModes

    This is not something I have investigated for myself, but I never presumed this sort of global blending would work at all, I suspect thats not been part of the plan at all at this stage but again this is just speculation on my part, sorry.
     
    TerraUnity likes this.
  48. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    This was official reply on the same question some else asked here

    upload_2018-7-30_10-38-32.png
     
    TerraUnity likes this.
  49. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    729
    @elbows @Grimreaper358 Thanks for the answers, good to know that we are not alone and that it will be there soon.

    But what's with the volumes for Scene Settings if they can't be local? Or if it can, how do we setup volumes for this?
     
  50. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,393
    I am really the wrong person to ask, because I've only used a single global volume so far.

    But certainly I expect local volume settings to do something, but thats not the same as expecting that a blend of 2 very different sets of settings can be achieved in the same location.