Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Volumetric Fog & Mist - AAA realistic and animated fog, dust, low clouds and mist

Discussion in 'Assets and Asset Store' started by Kronnect, Dec 1, 2015.

  1. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Glad you sorted this out! I was a bit in the dark without a repro. Also the toggling of renderBeforeTransparent seems like a timing issue between some scripts. Anyways, enjoy that fog of war!
     
    Whatever560 likes this.
  2. LKH_Prime

    LKH_Prime

    Joined:
    Apr 18, 2019
    Posts:
    5
    Hi, does Volumetric Fog & Mist 2 support Unity2021.2(URP12)?
     
  3. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Yes.
     
  4. ZorbaTHut

    ZorbaTHut

    Joined:
    Mar 19, 2014
    Posts:
    21
    Hey, I just released a game with a *lot* of mist that used (a modified version of) this asset for our rendering! Thanks! Worked great!

    One of the modifications I did was a performance improvement; we had *a lot* of fog, and we released on the Nintendo Switch, and this is a bit heavyweight for the Nintendo Switch by default. We ended up adding a separate URP render pass which rendered fog at half-resolution then composited it back onto the image, which was still a massive net performance gain.

    Doing this in a way that works properly is a bit of a finicky pain; thankfully there's a GDC Vault talk on the subject at https://www.gdcvault.com/play/1023275/Mixed-Resolution-Rendering-in-Skylanders . You end up downsampling the depth buffer in a very specific way, rendering fog to a half-res backbuffer based on the downsampled depth buffer, then upsampling it again using both the half-res and full-res depth buffers to put all the bits in the necessary places. If I remember correctly, it brought our fog rendering in the worst areas down from 20ms to 7ms. In our case, a fixed camera angle and predictable geometry meant we only needed to worry about the min/max sampling and bilateral upsampling - that's the first ten minutes or so - but you may want a more general solution, and, well, there's the rest of the video :D

    This is not a request, our game is shipped, we're done, just thought you might appreciate a useful link!

    (I've already recommended this package to some friends, for the record, it really does work quite well. Thumbs-up.)
     
    Alic and Kronnect like this.
  5. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Very interesting! Thanks for sharing your tip and the article.. and of course for the shout-out :)
     
  6. Hukha

    Hukha

    Joined:
    Aug 12, 2013
    Posts:
    61
    Hello!
    Is it possible to achieve fluid/smoke interactive?
    Something like FluidNinja in UE

    Thanks!
     
  7. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    No. Volumetric Fog & Mist 2 has animated wind and turbulences that affect the entire fog volume, and although you can interact with the fog and change its color or opacity in world space at any position, it's not a particle/cell diffusion system that can drag interaction or flow from one position to another.
     
    Hukha likes this.
  8. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    295
    Hello,

    I am using Volumetric Fog & Mist 2 as a 'full screen' effect for a very foggy first-person environment, and it is working great.
    I am wanting a more stylized look though and I would like to adjust the color of some of the fog based on two things, distance from camera, and vertical distance from a point. As I understand it these are not currently supported, which is perfectly understandable, I'm not complaining.
    I was however hoping you could point me in the right direction for implementing these my self.

    Thank you for your time!
     
  9. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Hi! Nice suggestions. Currently there're a couple of ways to add color to the fog, like fog of war (in URP version) or using fake point lights. But send me a pm or email so we can discuss alternatives.
    Regards
     
    MechaWolf99 likes this.
  10. LogaNRV

    LogaNRV

    Joined:
    Jun 3, 2017
    Posts:
    35
    I was trying to add the volumetric fog to a scene with only point lights, but it didn't work (main color always looked black).
    I taught it was because I was using Unity 2021.2.6, but in the end it started working when I added a fake directional light (is in the scene but disabled) to the Fog Manager.
    I mention it because I didn't saw it in the documentation, so not really sure is a requirement..

    Also, do the fog always receive point light shadows?. So "receive shadows" and "shadow intensity" options are only for the directional light?.
     
    Last edited: Dec 14, 2021
  11. xinoHITO1

    xinoHITO1

    Joined:
    Jul 2, 2012
    Posts:
    33
    Hello, I'm loving this asset! The fog is quite easy to set up but I'm running into an issue. My character uses a cel-shaded with a black outline. The thing is the black outline fades out only when in front of the fog.

    The outline is made by a vertex offset in Amplify. I'm attaching the settings on how it's made.
    The character's render queue is assigned to Geometry (2000). I can fix it by changing it to Transparent but that may cause some other sorting issues in my project.

    Is there a way to fix this without changing the render queue?

    fog issue 2.png

    fog issue.png
     
  12. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    In latest beta, it's no longer necessary to have a Sun light assigned to the manager.

    The asset option "Point Lights" use a custom implementation based on the virtual point light concept which is super fast but it doesn't support shadows. The "Receive Shadows" option is for the directional light only.
    If you wish to have shadow support for point lights and spot lights, you need to enable the "Native Lights" option in the inspector.
     
    LogaNRV likes this.
  13. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Thanks. The built-in version of Volumetric Fog works as a full screen image effect which only allows two injection points: before or after transparent queue. It's not possible to specify a render queue (the URP version works in a different way and allows you to customize the render queue, although the fog should always run in the transparent queue range).

    The outline itself doesn't write to zbuffer right? The fog relies on this info to determine the distance to pixels and compute fog accumulation so it may overwrite those pixels. In order to preserve a smooth outline (with proper blending) you will need to move the render queue of the outline to transparent. Other options include using a cutout shader for the outline (will produce harsh outline) or use stencil in your outline shader (and modify the fog shader so it skips writing on the stencil).
     
  14. Radiangames2

    Radiangames2

    Joined:
    Aug 22, 2012
    Posts:
    45
    I'm not seeing any shadows from the sun, even in the demo scene. Tried a pretty much blank project as well, same result. This is using Unity 2019.4.31f1 with today's version of VF&M2, using Built-In Render Pipeline. Here's a screenshot:


    Any ideas what I might be missing? Thanks!
     
  15. Radiangames2

    Radiangames2

    Joined:
    Aug 22, 2012
    Posts:
    45
    In the almost-blank project, I had to change the shadow distance, and in both I had to change from Close Fit to Stable Fit (Quality Settings). Now I got them working. Except for one problem: The shadows only show up on objects in certain layers. Still trying to track down where that's coming from.

    The shadows for objects in other layers are working fine, except with the volumetric fog. (Changing the layer does fix the issue for specific objects, but I have them in those layers for other reasons, aka physics).

    UPDATE (#1): Found the ShadowMapCopy script on my light, and it's working, but still not sure what is happening. I forced the additional sun shadow settings to show, but it's using the shadowmap from the light, so those didn't do anything. Might end up doing my own custom depth texture for this, but I'd still like to figure out why the light's shadowmap isn't correct...
     
    Last edited: Dec 18, 2021
  16. xinoHITO1

    xinoHITO1

    Joined:
    Jul 2, 2012
    Posts:
    33
    I'll try using the Transparent Render Queue. Thanks for the quick answer!
     
  17. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    The default shadow distance in an empty project is 150 which is too low for this scene. Just increase it to 250 or even more, and shadows should show up as expected. I've added shadow distance check in the demo scene so in future updates, that setting will be updated automatically if it's too low.
     
    Last edited: Dec 19, 2021
  18. Ivalobon

    Ivalobon

    Joined:
    Feb 20, 2017
    Posts:
    17
    When I enable an area volume of fog, the fog looks perfect but gets this strange screen grain effect added also. Is there a way to remove this?
     

    Attached Files:

  19. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Just reduce dithering or jittering settings.
     
  20. Ivalobon

    Ivalobon

    Joined:
    Feb 20, 2017
    Posts:
    17
    Perfect, thanks for the tip.
     
  21. ademord

    ademord

    Joined:
    Mar 22, 2021
    Posts:
    49
    Hello

    The fog is coming infront of my UI could someone help me out? upload_2022-1-5_23-4-51.png
     
  22. ademord

    ademord

    Joined:
    Mar 22, 2021
    Posts:
    49
    I think i fixed it with this upload_2022-1-5_23-10-14.png
     
  23. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    You can also make your UI canvas render to Screen Space Overlay which should make it on top of anything else.
     
  24. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    341
    Hi,

    I am unable to post in Kronnect's forums for some reason. It says to enable Javascript...

    I'm on URP, and on the latest version on the asset store (6.5).

    First, I have a volumetric fog that follows the player and serves as a basic distance fog + renders some sort of volumetric light because of the shadows being enabled.
    In the editor, here's how it look. Very subtle, creating a big of fog in the distance:
    1.png

    This fog's setup looks like this:
    fog scene.png
    fog inspector.png

    Now I also have other volumes to render rain curtains. The closer you are, the darker they are. I was very pleased to see the addition of the Depth gradient and Height Gradient features.
    Here's how it looks in the editor:
    G6102zq.png

    And here's an example of the setup for that kind of rain curtain effect:
    rainzone inspector.png
    Now here's how my screen look like in the BUILD:


    If I deactivate the player-following fog in the build, here's how the rain curtains look like:


    Everything is white, and looks super dense.

    What am I missing? I have never encountered different results in builds vs editor with this asset before.

    Thanks for your help!
     
    Last edited: Jan 13, 2022
  25. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    @marcrem can you try to reproduce that issue with volumes in a repro and send it to me? Do you have other render features?
     
  26. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    111
    Hey, amazing asset! A few questions...
    1. Does Volumetric fog and misk work with your other assets? I am interested in combining your Shiny SSR with this fog assessment.
    2. Why do you have a separate asset for volumetric lights? Is the Volumetric effect in the separate asset better in any way and in that case, can both assets be combined?
    3. Is it possible turn objects into fog, e.g. carving the fog to a Teddy bear to make a Teddy bear shaped cloud?

    Thank you for you attention!
     
  27. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Thanks!

    Volumetric Fog & Mist 2 should work fine with any of the other assets. There can be subtle variations in built-in or URP depending on the rendering order of certain effects. For example, we suggest to have Beautify 2 running before Volumetric Fog & Mist 2 so the environment is kept crisp but the fog doesn't lose any blur (although it's quite subtle).

    Volumetric Lights is optimized for the use case of light scattering extending local lights and they have different options for each case. You can use both effects in the same scene.

    Volumetric Fog & Mist 2 for URP has support for Unity native lights as well, so you can have your point and spot lights shine throught the fog without the need of Volumetric Lights. However, with Volumetric Lights you can cast realistic cone-shaped lights for street lamps, torches, etc. more easily while adding additional fx effects like dust particles without covering the entire area with fog. Optimization-wise, there're specific options for both assets as well.

    Regarding the fog carving.. there's the fog of war effect in Volumetric Fog & Mist 2 which let you control the transparency at any x/z position. It won't help to create a custom shaped cloud though. The URP version uses a world-space volume which perhaps you could modify to use a custom mesh instead of a boxed volume although that's only in theory, it's not something supported out of the "box".

    Kind regards.
     
    look001 likes this.
  28. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    341
    My game isn't really something you can just export as a small repro build / project for you to test unfortunately, it's way too big. However here are some more details, hopefully you can spot something :(

    My player character's camera:
    upload_2022-1-16_20-35-15.png




    Now here's the player's renderer :
    upload_2022-1-16_20-37-27.png


    Since it's rendering the volumes, I doubt that it has something to do with any of the renderer features there, but I might be wrong. I am absolutely not able to reproduce it in the editor, but it always happens in builds since I updated.

    It's a major blocker right now for our play testing sessions and I hope we can find a solution :(

    Thanks so much

    EDIT: I'm trying to create a blank unity project and reproduce it, how do you want me to send a project?
     

    Attached Files:

    Last edited: Jan 17, 2022
  29. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Send the link by pm.
     
  30. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    341
    At the moment, I haven't been able to reproduce the bug in a fresh project, even by using the same settings. I'm very lost here.
     
  31. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    341
    Hi again. I've added a bunch of debug keys to disable things in my build. I disabled all other effects, all post processing, and everything still is all white.

    I have this idea : It does look like it's trying to do the distance gradient, but it could be calculating distance from the wrong position?

    Also, have you looked at my settings? I'm basically setting the albedo to white, and changing to a darker tone with distance + height gradients. is this the way to go?
     
    Last edited: Jan 18, 2022
  32. coreyjdixon4

    coreyjdixon4

    Joined:
    Jun 4, 2019
    Posts:
    5
    Hey @Kronnect , We're currently using Built In and have just purchased this asset, its great.

    However im trying to setup a simple "fog is outside, but not inside houses / trucks".

    I cant seem to do it without getting hard edges on geometry based fog, OR overlapping edges when using fog volumes. What do you suggest?
    Thanks!
     
    Last edited: Jan 28, 2022
  33. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    If the interiors are static, I'd recommend using the fog of war feature. You can paint the holes in the fog from the Scene View and keep the fog outside this way.
     
  34. coreyjdixon4

    coreyjdixon4

    Joined:
    Jun 4, 2019
    Posts:
    5
    Our game is first person, and painting away fog seems to remove everything in the Y axis, is there a work around for that?
     
  35. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Have you tried the Raymarched Fog of War option in Shader Options?
     
  36. coreyjdixon4

    coreyjdixon4

    Joined:
    Jun 4, 2019
    Posts:
    5
    No I'll give that a go now :) Thankyou!
     
  37. Reekdeb

    Reekdeb

    Joined:
    Nov 26, 2012
    Posts:
    9
    Hi @Kronnect amazing asset. However, console is logging lots of Warning messages when 'Terrain Fit' option is enabled.

    You can only call cameraColorTarget inside the scope of a ScriptableRenderPass. Otherwise the pipeline camera target texture might have not been created or might have already been disposed.
    UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)

    Unity: 2020.3.25f1
    URP: 10.7.0

    ScriptableRenderer.cs
    Code (CSharp):
    1.         /// <summary>
    2.         /// Returns the camera color target for this renderer.
    3.         /// It's only valid to call cameraColorTarget in the scope of <c>ScriptableRenderPass</c>.
    4.         /// <seealso cref="ScriptableRenderPass"/>.
    5.         /// </summary>
    6.         public RenderTargetIdentifier cameraColorTarget
    7.         {
    8.             get
    9.             {
    10.                 if (!(m_IsPipelineExecuting || isCameraColorTargetValid))
    11.                 {
    12.                     Debug.LogWarning("You can only call cameraColorTarget inside the scope of a ScriptableRenderPass. Otherwise the pipeline camera target texture might have not been created or might have already been disposed.");
    13.                     // TODO: Ideally we should return an error texture (BuiltinRenderTextureType.None?)
    14.                     // but this might break some existing content, so we return the pipeline texture in the hope it gives a "soft" upgrade to users.
    15.                 }
    16.  
    17.                 return m_CameraColorTarget;
    18.             }
    19.         }
    Can you please look into it? Thank you.
     
  38. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Well, terrain fit option was not changed in the URP version. Is this first time you're using it? Or does that msg show after updating to the new version released today? Also please specify which Unity version are you using. Thanks!

    Update: which render features are you using in the URP asset?
     
    Last edited: Feb 1, 2022
  39. Reekdeb

    Reekdeb

    Joined:
    Nov 26, 2012
    Posts:
    9
    It turns out the issue occurs when using Enviro - Sky and Weather's Fog or Sun-Shaft renderer features along with Volumetric Fog & Mist 2 URP Terrain Fit.

    Forward Renderer:
    upload_2022-2-2_1-24-40.png

    Enviro Settings:
    upload_2022-2-2_1-30-9.png

    Console Output:
    upload_2022-2-2_1-35-45.png

    Unity: 2020.3.25f1
    URP: 10.7.0
    Enviro: 2.3.3
    Volumetric Fog & Mist 2 URP: 7.0.1

    The issue was present in previous version as well.
     
  40. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Do the warnings disappear if you disable Enviro render features? It could be that those render features are not designed to work with custom or additional cameras and try to run on every camera. If this could be the reason, please contact Enviro developer and /cc me so we can suggest them a solution (similar to what we use in our render features).
     
  41. Reekdeb

    Reekdeb

    Joined:
    Nov 26, 2012
    Posts:
    9
    These warnings disappear if either I disable Terrain Fit option or I disable Enviro fog and Sun shafts renderer features. If I enable both those warnings appear again.
     
  42. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Now also available in built-in pipeline!

     
    wetcircuit, Monil and ratking like this.
  43. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    352
    Thanks for this, but is there a reason why it doesn't work with objects in the Default layer?

    EDIT: Also, there seems to be a problem with setting the general density of the Volume Fog that has Terrain Fitting enabled. Changing the density moves the fog up/down.
     
    Last edited: Feb 9, 2022
  44. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    That layer mask is used to include objects in the zenithal depth pre-pass. Using the default layer setting would probably include undesired elements and can affect performance - hinting to use a specific layer to capture terrain (or any other object you know) will prevent that. Said this, you can use the default layer as well.

    It's a side effect that might be changed in a future update. Just move the fog area or volume up/down as needed.
     
  45. limboking

    limboking

    Joined:
    Aug 16, 2017
    Posts:
    1
    Hi @Kronnect, thanks for providing amazing assets!
    I have a problem when using the fog in my project. When Render Before Transp. is selected, the UI layer which uses world space and the Particle system are always displayed at the top. When Render Before Transp. is not selected, they are all at the bottom. How could I make them normally affected by fog?
     
  46. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    Hi! And thanks for using Volumetric Fog & Mist!

    The issue with particles is inherent to the way post-processing fog effects work. There're workarounds though, for instance, you can:
    - If the transparent object is a cut-out style object or something that you can consider like opaque to the fog (ie. rivers, lakes, oceans), you can use the Compute Depth option so a custom depth-prepass is performed (check this video).
    - If the transparent object has alpha gradients (like smoke particles), it's trickier since a cutout option like above will add a hard cut of the fog effect around the particle. In this case, you could try to integrate the fog effect into the shader iself or use the blending option.
    Check the documentation (PDF) for some tips about transparency support.
     
  47. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    352
    (Built-In RP, Unity 2021.2.11) I have a Fog Area Box with FOW activated and it works very well. But when I add a Fog Cloud Layers object with one or two layers, the FOW does not work anymore and the fog of the box does not vanish. Is this a known problem?
     
  48. coreyjdixon4

    coreyjdixon4

    Joined:
    Jun 4, 2019
    Posts:
    5
    Thankyou for the help with the Fog of War, that worked perfectly.
    However I have a new issue.
    We're also using your Volumetric Lights asset, when using both together, the volumetric light seems to stencil out and not be visible on top of the fog when rendered over the skybox or far away objects? Is there anyway around this?


    Thanks again!
     
  49. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    We're looking into this.

    Could you please contact us by email or use our Discord (invite in the signature)? Images seem broken.
     
  50. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,912
    A new beta is available on our support forum which allows fog areas to reuse the same fog of war settings from the main fog script, including contents and layout;



    This option let you focus on customizing the fog of war from a single script (the main script attached to the camera which can also act as a fog area by itself).

    Previously each fog area would keep its own fog of war settings and layout. Now you choose to keep previous behaviour (default) or enable this option and use the same fog of war effect for all fog areas.