Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    352
    I tried the beta version and it did not fix my problem at all - the clouds layer somehow removed the ability to draw into the FOW texture. I don't know exactly what happens.

    Moreover, with the beta I constantly get the error "UnassignedReferenceException: The variable _fogOfWarTexture of VolumetricFog has not been assigned.", and I have to create a FOW texture in my project to remove this error, which is not wanted by me, because actually testing the game writes into that texture, which then persists.

    "Use Main Settings" also doesn't seem to work for me - at least not always. Either I get a NullReferenceException (VolumetricFogFoW.cs, line 339), or the FOW simply does not get cleared.
     
  2. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Thanks. Please let's continue discussing these issues in the beta board to which you have access.
     
    ratking likes this.
  3. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    352
    I set a prepared FOW texture (because the start area shouldn't be as foggy as the rest), but as it gets changed when playing the game through FOW clearing characters, I do the following in Start():

    Code (CSharp):
    1.  
    2. fog.fogOfWarTexture = Instantiate(fog.fogOfWarTexture);
    Is this the correct way? Or is there something I missed. By the way, if I put that piece of code in Awake(), I get a NullReferenceError.

    nullref_fow.jpg
     
  4. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Yes, you can do that - regarding the error, it's an initialization order issue, I'll take a look.
     
    ratking likes this.
  5. Larsson24

    Larsson24

    Joined:
    Nov 2, 2020
    Posts:
    7
    Do I need to buy both Volumetric Fog & Mist 2 and Volumetric Lights to have volumetric fog and light? Do they work together? Or do Fog & Mist include everything? Any package deals for buying both if needed? :)
     
  6. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    It’s not included. Volumetric Lights offers an optimised workflow for Unity local lights. Select a light and add VolumetricLight component and that’s it, customise it. Volumetric Fog has a different workflow, it starts by creating one or more fog volumes in the scene which can be influenced by Unity lights (limited in number in URP). The array of options they offer is different as well.
    Usual cases: in open scenes/outdoors where you want directional lighting with shadows showing through trees, or fog of war, or just a cool fog effect over a landscape, use Volumetric Fog & Mist. For local lights like lamps, torches, flashlights, lighting effects throw windows in interiors, etc, use Volumetric Lights.

    There’s a 20% discount when purchasing the other one.
     
  7. Larsson24

    Larsson24

    Joined:
    Nov 2, 2020
    Posts:
    7
    Okay, thanks for the clarification. :)
     
  8. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    352
    As an experiment I switched my project from BIRP to URP and also switched to Volumetric Fog & Mist 2 URP for that. Somehow the above code doesn't work with the URP version, it overwrites my texture asset and I have to reset it via source control every time. Am I doing something wrong?
     
  9. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    It's a bug in the URP version which will be fixed in next update. Just call UpdateMaterialProperties() after setting your instantiated texture:

    Code (CSharp):
    1.         fog.fogOfWarTexture = Instantiate(fog.fogOfWarTexture);
    2.         fog.UpdateMaterialProperties();
    You can also enable the Blur option in the fog of war section.
     
    ratking likes this.
  10. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Spotlights are only supported in the URP version of Volumetric Fog & Mist (or use Volumetric Lights asset for your spotlights).
     
  11. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    540
    Yes my bad, I forgot to import Volumetric Lights package. Its working now. Thanks
     
    Kronnect likes this.
  12. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Hi everyone!

    Don't miss latest production announcement from Unity: Gigaya.


    We are so excited to announce that our asset Volumetric Fog & Mist 2 is used in this URP project.

    Learn more about Gigaya in this post.
     
    PutridEx and ratking like this.
  13. BoJustBo

    BoJustBo

    Joined:
    Aug 29, 2020
    Posts:
    4
    Hi, I have a question, and sorry if it's been addressed earlier but this thread is infinitely huge.
    So my question is, can this do vertical falling/rising fog? Like fog falling off a cliff like a waterfall for example. And if yes, can it transition horizontal fog into vertical.
     
  14. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    By using the Terrain Fit option, the fog will adapt to the surface in the volume. The final result will depend also on other parameters like turbulence, wind direction, noise 3d values, etc.
     
  15. BoJustBo

    BoJustBo

    Joined:
    Aug 29, 2020
    Posts:
    4
    Thanks for the reply, I looked up some videos of it on youtube and it looks really good.
    One more question: Since it is based on height from terrain, would that mean it wont work on 100% vertical stuff and I'd have to have a slight angle to the geometry to have it roll down?
     
  16. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    That's correct.
     
  17. BoJustBo

    BoJustBo

    Joined:
    Aug 29, 2020
    Posts:
    4
    Thanks :)
     
    Kronnect likes this.
  18. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Hi Kronec!

    I bought Volumetric Fog and Mist years ago and now also version 2, using the build-in version.

    I liked to have a fog in the distance to hide my terrain edge. For this I have a fog that is between 880 m and 910 m. My problem now is that the fog affects my performance a lot. In total I lose between 4 and 5 ms.

    I have already implemented the tips contained in the tutorial. But for example I can't set downsampling higher than 1, otherwise I immediately get strong artefacts around all my plants and trees.

    Here are my settings:

    S1.jpg S2.jpg

    Do you have any idea how I can improve the performance of the fog?

    Thank you very much!
     
  19. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Have you tried using Dynamic Fog & Mist to cover the terrain edge? It's included, try adding DynamicFog script ot the camera and customize. It doesn't provide all the options of Volumetric Fog but it might be a better solution in this case if you just want to cover the horizon.
     
  20. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    83
    Hi, I am looking for a volumetric lighting solution to be used in a first-person game running on the Nintendo Switch. How does this compare to other solutions on the Asset Store in terms of performance?
     
  21. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Hi!

    I bought Volumetric Fog and Mist 2 a while ago and am missing a very important component from the first Volumetric Fog and Mist.

    Here I could attach a fog to the camera that was rendered from a certain distance.

    So it was always around the camera.

    This function seems to be missing now or have I overlooked something?
     
  22. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Hello! Do you refer to the URP version? This version is designed around the concept of volumes. Just create a volume that encloses the camera and use the Distance setting.
     
    Last edited: Apr 13, 2022
  23. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    109
    Hi,
    using Unity 2021 LTS Volumetric Fog 8.0.
    When I save the scene, the fog volumes are not correct anymore. Somehow stretched. Is this something I should worry about? Certainly not very comfortable when designing a scene.

    Thanks for any ideas!
    upload_2022-4-14_23-24-3.png
     
    PutridEx likes this.
  24. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    This seems a bug in the recently released Unity 2021 LTS which doesn't happen in 2020 LTS. Material properties and keywords are being reseted when saving the scene. Moving the fog area or simply entering into playmode or reloading the scene will refresh the material properties. We've reported the bug and are also investigating a temporary workaround.

    EDIT: an update is now available on the Asset Store that should fix this issue. In Unity 2021.3 LTS, the new material.enabledKeyword can mess with other APIs resulting in incorrect keywords being applied.
     
    Last edited: Apr 15, 2022
    Doomchecker likes this.
  25. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Can you tell me how?

    I have no success with it and unfortunately there are no tutorials.

    I have all the assets from you. My goal is a sandstorm that starts after 300 m and gets stronger in the distance to hide what is further away.

    EDIT:

    I have now found a possibility. By chance I found the Fog Void Script in a video. It could work with this.

    But the other problem is. The size of the Vog. I have a 6 x 6 km landscape. The Fog would be just too big to cover the whole area. The loss of performance
     
    Last edited: Apr 19, 2022
  26. benington

    benington

    Joined:
    Jan 14, 2014
    Posts:
    7
    Hi @Kojote I am attaching a video where we try to explain how we would suggest to do the settings based on the description of what you'd like to achieve. We would also suggest tweaking noise scale value and distance fall off to merge the fog effect in the distance and not make the cut so sharp as in the video. We hope this helps:
     
    Kojote and Kronnect like this.
  27. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Hi @benington !

    Thank you very much, that's exactly what I was looking for.

    Can I also hang the fog on the camera in the URP version? Or are there problems there?
     
    Kronnect likes this.
  28. benington

    benington

    Joined:
    Jan 14, 2014
    Posts:
    7
    We're so glad it helped! For URP the fog works with volumes, only for builtin works rendered with the camera, but the results are exactly the same.
     
  29. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Is there a way to prevent the mist from being in the water?

    Water Fog.jpg
     
  30. benington

    benington

    Joined:
    Jan 14, 2014
    Posts:
    7
    Try increasing the vertical offset in the Geometry category from the inspector panel of the fog volume, that should work well.

    upload_2022-4-19_17-27-51.png
     
  31. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    You could use a script and a collider that encloses the water mass so it detects when player is underwater and reduce the transparency of the fog volume or disable it completely.
     
  32. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Unfortunately, attaching the fog to the camera does not work. The fog cannot be moved.

    Is there any other way to create a nebula for a large terraion?

    The terrain is 6x6 km. Even if I set the quality to 1, I lose 6 ms.
     
    Last edited: Apr 19, 2022
  33. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    In Volumetric Fog Manager, under Shader Options, there's an option to align noise to world space.
    Increase Raymarch Min Step value in Fog Volume inspector to speed up rendering.
     
    Kojote likes this.
  34. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    That helps me a lot! It has saved a lot of ms. Are there any other ways to save?
     
    Kronnect likes this.
  35. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Sure. Check out page 20 of the documentation (PDF). It lists a few suggestions/options to improve performance.
     
  36. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    I am trying downscaling.

    However, I get a message that I need to add a 'Volumetric Fog Render Feature' in the forward renderer. Unfortunately, I can't find anything in the documentation.

    What should I do here?
     
  37. benington

    benington

    Joined:
    Jan 14, 2014
    Posts:
    7
    Hi @Kojote here is a demo video of how to setup the Volumetric Fog Render Feature (most of our assets for URP would go the same steps to set it up in case you need it, as you said you have many of our assets)

     
    Kojote likes this.
  38. MaculaInteractive

    MaculaInteractive

    Joined:
    Oct 26, 2021
    Posts:
    2
    Hi, I want to try the fog of war brushmode but I can't seem to find it. Already checked the box for fog of war and fog of war editor and also created the Mask Texture. I'm using 2021.3.0f1
     
  39. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    in URP?
     
  40. Vaeer

    Vaeer

    Joined:
    Feb 22, 2022
    Posts:
    8
    Hello,
    I'm looking for an asset that could provide such effect and I wonder which of your assets (if any) could achieve this (at 2:26 minute, sorry, these forums remove timestamps from links).


    (Especially while looking at the slot machines from distance, there's clearly a for or volumetric light. But once camera gets there, there's no fog effect visible over slot machines once you're next to them)

    What I mean is that while there seem to be volumetric lights in this city (correct me if I'm wrong), it seems to me that many of these effects are quite wide and seem to disappear once you get inside the light/fog effect. Again, I'm not sure whether it's a fog being utilized, or only volumetric lights in this city.
    Is it volumetric fog volume? Or is it volumetric point light? Or volumetric spotlights?
    So, I don't know what exactly to seek. I've seen this effect in HDRP, but I must use built-in render for now or (if I'll be lucky) URP. My main focus here is on interiors, adding the feeling of depth and space through the shown effect.
    I'd also prefer if it was quite seamless, soft effect, like in the video. An while being inside it, sometimes I guess the effect gets fully transparent - or maybe it's just my impression? Anyway, I'd like to be able to do all that through some asset.
    Could you point to what I would need, @Kronnect?

    Another question, if possible, how would you see it perform on high-end mobile ios hardware like fast android tablets and ipads?
     
    Last edited: Apr 24, 2022
  41. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    That can be achieved with volumetric fog & mist. Place a fog volume in that room, customise height and use a low density. It should be visible from distance and due to low density, it will more transparent as you enter it. Also by using a collider and a script on that fog volume, you have full
    control of its appearance by modifying its visual properties.
    It should run very fast on modern devices as that local volume is pretty small.
     
    Vaeer likes this.
  42. MaculaInteractive

    MaculaInteractive

    Joined:
    Oct 26, 2021
    Posts:
    2
    so sorry, the brush appeared after I restarted unity. Thank you for answering so quickly :)
     
    Kronnect likes this.
  43. Deleted User

    Deleted User

    Guest

    This asset is cool. Is there a way to set the fog to be blocked by physics colliders? Say, you want to not have the fog when you're inside, but you see it each time you look out the window or leave the building.
     
  44. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Do you mean removing the fog inside buildings?
    You have some choices here:
    - Distance fog option is the most immediate which basically pushes the fog away from the camera position.
    - Next, are the fog voids which can be placed dynamically around the player or at given position.
    - Finally, if you need to clear fog from many specific locations, you can use the fog of war feature which let you control the opacity of the fog at any number of world positions.
    Check the documentation for more details or feel free to ask in our Discord for some examples.
     
  45. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Hi!

    I have installed 2 Fog Volumes in my Scene. However, either no fog at all or only one of them works.

    Can someone tell me what is wrong?
     
  46. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Hi,

    Could you provide more context? Are you creating them manually from the editor or using scripting?

    The built-in pipeline version has a demo scene that allows you to fly around the scene and create fog areas in front of you by pressing some keys. You could try that demo and check the script included in the folder for a working example.
    The URP has also this capability, using scripting.. the documentation of both versions (PDF) includes the code you need to use to create fog areas or volumes at runtime.

    Regards
     
  47. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    No, I do not want to create a fog at runtime. I have set up two fogs in my scene, as you can see here.

    Fog 1:

    Nebel 1.jpg

    Fog 2:

    Nebel 2.jpg

    Fog 1 is displayed in the game. Fog 2 is not displayed in the game.
    (The fog in the second picture is, by the way, from Wind and Glitter by MicroSplat).

    The question is: Why is only the first fog displayed, but not the second?

    EDIT:

    And one more question. I have 'Enable Fade' active. This fades out the fog. Does the fog still consume performance when it is hidden or should I deactivate it completely if I don't need it?
     
    Last edited: May 2, 2022
  48. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Update 8.1.1 is now live on the Asset Store which fixes the issue reported by @Kojote
     
    Kojote and BoJustBo like this.
  49. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    208
    Hi!

    I have another question about the Volumetric Fog. This should actually fade out after 300 m. However, I am now already over 500 m away and he still does not fade.

    Can you tell me what I'm doing wrong?

    Fade.jpg

    EDIT: Oh! I just see that the update is out, I'll test it right now! :)

    EDIT 2: Problem remains even with the latest version. The fog does not fade out at a distance.
     
    Last edited: May 18, 2022
  50. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Update coming later today, it's fixed
     
    Kojote and Kronnect like this.