Search Unity

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

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

  1. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Sorry to see you have issues with your 2D project. Please contact us using the support email address listed on the publisher page.
     
  2. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Hi, please sign up on our support forum at kronnect.com and send me your username to download future beta versions. Cheers!
     
  3. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Latest beta adds "Sync With Profile" option.



    The default behaviour propagates any profile change to the script settings. Disabling "Sync With Profile" allows you to load manually a profile and then customize individual script settings keeping those changes until you click "Load" or call profile.Load(..) method manually.
     
  4. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,069
    It seems that there currently is an issue with Unity 2019.1.0b2 when running in VR: The distance to which the fog is rendered seems to be capped, and I'm also getting offsets so that objects that are occluding the fog appear is darker shadows in other locations ("darker shadow" looks like the fog effect isn't rendered there).

    Is that a known issue?

    I have updated to 9.6 using Unity 2018.2 recently, but didn't see this issue in Unity 2018.3, only in Unity 2019.1.0b2, so it might even be this is already fixed when using 9.6.1 / 2018.3. Unfortunately, updating Volumetric Fog is a bit tricky for us because we minimize build size by not using the Resources-folders; so I need to re-apply several code changes and object assignments on each update.
     
  5. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    It may very well be a bug in that Unity beta. Please report the bug to Unity. I’ll take a look as well.
     
    jashan likes this.
  6. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,069
    I'm about to file the bug report to Unity - just updating to Unity 2019.1.0b3 real quick to see if it still repros there (I was still on b2).

    I can now also give some more details about what's happening there:

    I'm using Unity PostProcessing v1, and Volumetric Fog, and HxVolumetricLighting. The funny thing is that in 2019.1, PostProcessing flips the image upside down. Volumetric Fog renders correctly (as far as I can tell). Now, HxVolumetricLighting fixes the issue that PostProcessing flips the image ... but there's some offset between Volumetric Fog and the rest of the scene that way.

    So it's really an issue of 2019.1 (and 2019.2) + Volumetric Fog + HxVolumetricLighting + PostProcessing v1. This kind of sucks because I had already started porting to PostProcessing v2, which may very well fix the issue - but they have changed how Color Grading works, and we use color grading a lot, with a different setup for each level. So that's a larger task.
     
  7. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,991
    Having a weird problem with Volumetric Fog -- when inside the fog, if I rotate the camera around, the fog disappears at some angles, then reappears as I keep rotating. This sounds vaguely familiar but I can't remember what to do about it....can you advise?

    thanks!
     
  8. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Don't remember an issue like that. Can you send me a simple repro scene?
     
  9. JDub19

    JDub19

    Joined:
    Dec 27, 2017
    Posts:
    2
    @Thrawn75 Hey, I was struggling to get Fog Of War cuts to stay permanent and I was following the documentation: "To make the cut permanent make sure Restore Delay is set to 0." I found the cuts became permanent not when I set Restore Delay to 0 but instead Restore Duration to 0. I don't know if this is a bug or just a typo in the documentation, but I'd assume the latter. I spent more time debugging this than I'd like to admit so I just thought I'd let you know to save someone else the headache.
     
    Thrawn75 likes this.
  10. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    I appreciate the heads up! Will check this and fix the docs accordingly. Thanks again for reporting this and apologize for any confusion.
     
  11. JDub19

    JDub19

    Joined:
    Dec 27, 2017
    Posts:
    2
    So I was wondering if someone could help me figure out how to do the Fog of War effect in the video from the first page of this post:
    . I want the ability to completely obscure what's below the fog while still letting it have the effect of moving and not just be a static black color. Any help would be greatly appreciated.
     
  12. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    The fog of war effect from that video is a custom effect integrated in World Map Strategy Kit and not really related to Volumetric Fog & Mist. Although you should be able to achieve a very similar effect using the wind, turbulence and different color options from Volumetric Fog & Mist plus the fog of war options and appropriate density, noise amount (the less noise the more opaque) and height values. If you wish to send me some sample/repro scene by email I'd gladly take an in-depth look.
    Cheers.
     
  13. DTek

    DTek

    Joined:
    May 29, 2013
    Posts:
    14
    Hello there, I'm considering purchasing your asset, it looks fantastic. I have a few questions before taking a decision :
    1) Does this work with other post processing effects ? I'm running a DoF effect with Unity's post processing packages, and would like to know if it works.
    2) Is this memory heavy ? I will need a fog that fills the bottom of the screen
    3) Does this react to light ? if my scene is at night, ambient is black, and I have a spotlight, will it show only parts of the fog ?
    4) Can I change the fog texture ? Let's say with something that looks like this :
    https://i.pinimg.com/564x/03/ae/1b/03ae1bde6f242bdc3bb3efdd37b4ec86.jpg
    will this work for 2d or 3d ?
    5) Does this support multiple fog elements on the scene at the same time ?
    6) Can the FoW edges be cleaned up / rounded ? they look quite rough as is.
    7) Can I have elements coming out on top of the FoW ? let's say an electricity pole that's a bit higher than the rest
    Thanks !
     
  14. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Yes. In the case of DoF, you need to enable the "Render Before Transparent" objects in Volumetric Fog & Mist inspector, so the fog is rendered before DoF effect applies. If you use Beautify's DoF, you don't need to tick that option since you can just place Beautify and Volumetric Fog & Mist in any order on the camera stack.

    No and it uses 0 allocations per frame after initialization.

    Volumetric Fog & Mist supports directional and point lights. Spot lights are not supported in current version.

    No.

    Yes. Volumetric Fog & Mist can work by adding the script to the camera (ie. for background fog or entire scene fog) or by placing any number of delimited "Fog Areas" in the scene or a mix.

    Yes. It's a matter of picking desired fog of war resolution so it allows smooth transition between clear and opaque areas.

    Yes.
     
  15. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    95
    Hi @Thrawn75 - quick question regarding VFM: do you have VR Single Pass Instanced support on your roadmap? It would be great to enable this for further performance benefits.

    Thanks!
     
  16. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Hi - yes, Single Pass Instanced support is included in latest beta.
     
    tntfoz likes this.
  17. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    95
    Haha, that's brilliant timing - many thanks for your help!
     
    Thrawn75 likes this.
  18. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    365
    Hi @Thrawn75 !
    Your volumetric fog is AWESOME!
    It's REALLY fast! I can easily use it for Android Vulkan on an Nvidia Shield TV at 56fps with everything else on scene!
    Makes me happy as a pig. :D

    I'm having an issue however: as soon as I activate the downsample, the regular render is all black and only the volumetric fog is visible.
    This is happening both in editor and in build when using HDR mode = R11G11B10 in ProjectSettings->Graphics
    Using HDR mode = fp16 fixes it.
    However it is slower.

    I have fixed it in your code forcing VolumetricFog.cs to use the standard HDR mode for it's job only (instead of forcing Unity as a whole to use fp16 for HDR)
    Line 3008:
    Code (CSharp):
    1.                 RenderTextureDescriptor rtReducedDestinationDesc = source.descriptor; rtReducedDestinationDesc.colorFormat = RenderTextureFormat.DefaultHDR;
    2.  
    Another thing:
    Is there a good reason to limit the max point lights to 6?
    Since it was making my lights pop, I modified the source to raise it to 12 and it's working fine for me.
    Anything I should know about that?
    Also, does dithering slow things down or is it free?

    Thanks!
     
    Thrawn75 likes this.
  19. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    haha! glad you like it :)

    Thanks for the fix for the NVidia Shield, will take a look at that.

    Regarding the point light count, you can indeed setup a larger number. Just go to Shader Options in Volumetric Fog inspector and set the max number you wish:



    The dithering is mostly free on modern devices.

    Cheers!
     
  20. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    365
    Oh... Ok.
    I did it the hardcore way though, modifying the source :p
    Sure this is easier. :D
     
    Thrawn75 likes this.
  21. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    365
    Ok, that seems silly but, I have read the docs and can't find how to do smooth holes in the general fog.
    I mean, the volumetric fog has a single "Fog Void" in it's options, which makes a single spherical smooth hole or void in the fog.
    What I want is to make several Fog Voids both spherical and boxed.
    I know it's possible since the shader options specify "Fog Void (Sphere Shape)" and "Fog Void (Box Shape)" along with "Fog Area".
    I know how to make Fog Areas in the hierarchy: GameObject -> Create other -> Volumetric Fog Area, but there is no option to create a "Volumetric Fog Void"

    I want a global fog and then several voids in it in the shape of spheres and boxes.
    It's possible, right??
     
  22. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Currently each fog area can have only one fog void (spherical of box shape). You can have multiple fog areas, but each one allows one single void. Some customers have modified the shader to use more than one fog void (using additional uniforms for location/size).
    Alternatively you can use the fog of war feature. This option works great for top-down games and allows you to customize the transparency of the fog at any position in world space (therefore you can create multiple holes with any shape).
     
  23. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    365
    Thanks for the quick answer!
    The fog of war seems the easier to use in my case.
    I'm concerned by performance though.
    How the fog of war compares to the regular volumetric fog?
    Also, what is more expensive: using several fog areas or just a single one with plenty of voids using the fog of war?
     
  24. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Quite cheap. You probably won't notice the difference.

    Having multiple fog areas visible in the frustum is more expensive than using the fog of war.
     
    atomicjoe likes this.
  25. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    365
    Ok, so I'm experimenting making voids with the fog of war but I can't make them last, it automatically restores the fog smoothly.
    I'm setting the Restore Delay to zero already but it keeps resetting the fog!

    Here is the code. I only apply it once, when the game starts, then the fog resets smoothly.
    What I'm doing wrong?
    Code (CSharp):
    1.     void ApplyFogOfWar()
    2.     {
    3.         VolumetricFogAndMist.VolumetricFog.instance.fogOfWarEnabled = true;
    4.         VolumetricFogAndMist.VolumetricFog.instance.fogOfWarRestoreDelay = 0f;
    5.         VolumetricFogAndMist.VolumetricFog.instance.SetFogOfWarAlpha(transform.position, radius, 0f, 0f);
    6.     }
    7.  
    EDIT:
    It seems the fog of war start duration has to be set to higher than zero to behave correctly.
    Setting it to 0.0001f fixed it.
    Also, if you try to set a higher radius in the same point you already set a specific alpha, it gets ignored.
    Using ResetFogOfWarAlpha(transform.position, lastRadius) before setting the fog of war point alpha makes it work.
     
    Last edited: Apr 3, 2019
  26. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Setting fog of war delay to 0 should make the clear area stay forever but it's checking fog of war duration instead in that API - you can set both to 0 for now. I'm prepping a new update with improvements related to fog of war, including a fix for these issues you have found.
     
    atomicjoe likes this.
  27. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    365
    Cool thanks!
    I made a script to cut holes into the global fog using the fog of war in the editor instead of code for level design.
    For anyone interested, just save this as "VolumetricFogVoid.cs" and assign it to an empty object.
    Place the object and set the radius of the hole. It's live in editor and in build.
    You can place as many of this holes as you want, just duplicate the gameobject and place it elsewhere.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [ExecuteAlways]
    6. public class VolumetricFogVoid : MonoBehaviour
    7. {
    8.    public bool resetFogOfWar = false;
    9.    public float radius = 5f;
    10.  
    11.    float offset = 0f;
    12.    float lastRadius = 0f;
    13.    Vector3 lastPos = Vector3.zero;
    14.  
    15.     void OnValidate()
    16.     {
    17.        VolumetricFogAndMist.VolumetricFog.instance.fogOfWarEnabled = true;
    18.        VolumetricFogAndMist.VolumetricFog.instance.fogOfWarRestoreDelay = 0f;
    19.        VolumetricFogAndMist.VolumetricFog.instance.fogOfWarRestoreDuration = 0f;
    20.        if (resetFogOfWar) {
    21.            VolumetricFogAndMist.VolumetricFog.instance.ResetFogOfWar();
    22.            resetFogOfWar = false;
    23.        }
    24.        VolumetricFogAndMist.VolumetricFog.instance.ResetFogOfWarAlpha(transform.position, lastRadius);
    25.        VolumetricFogAndMist.VolumetricFog.instance.SetFogOfWarAlpha(transform.position, radius, 0f, 0f);
    26.        lastRadius = radius;
    27.    }
    28.  
    29.    private void OnEnable() {
    30.        lastPos = transform.position;
    31.        VolumetricFogAndMist.VolumetricFog.instance.SetFogOfWarAlpha(transform.position, radius, 0f, 0f);
    32.    }
    33.  
    34.  
    35. #if UNITY_EDITOR
    36.    private void OnDisable() {
    37.        VolumetricFogAndMist.VolumetricFog.instance.ResetFogOfWar();
    38.    }
    39.  
    40.    private void LateUpdate() {
    41.        if (!Application.isPlaying) {
    42.            if (lastPos != transform.position) VolumetricFogAndMist.VolumetricFog.instance.ResetFogOfWarAlpha(lastPos, lastRadius);
    43.            VolumetricFogAndMist.VolumetricFog.instance.SetFogOfWarAlpha(transform.position, radius, 0f, 0f);
    44.            lastRadius = radius;
    45.            lastPos = transform.position;
    46.        }
    47.    }
    48.  
    49.    private void OnDrawGizmos() {
    50.        Gizmos.color = new Color(0.75f, 0.75f, 0.75f, 0.5f);
    51.        Gizmos.DrawWireSphere(transform.position, radius);
    52.    }
    53. #endif
    54.  
    55. }
    56.  
    EDIT:
    Just a precision: the script auto updates in the editor but freezes on play and in builds to avoid any performance hit.
     
    Last edited: Apr 3, 2019
    Thrawn75 and wetcircuit like this.
  28. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    365
    One thing that would be really useful would be to have some control over the alpha curve of the fog of war radius.
    I mean, right now if you make a big radius, it changes veeery smoothly from the edges to the center of the fog of war point you just placed.
    It would be cool to have some control on the smoothness or hardness of this transition.
     
  29. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Exactly. There're two new options in the upcoming update: smoothness and fuzzyness to control border appearance.
     
    atomicjoe likes this.
  30. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    julianr likes this.
  31. unity_c1ndWE1Nn46iPg

    unity_c1ndWE1Nn46iPg

    Joined:
    Jan 13, 2019
    Posts:
    53
    Hi, I got problem with VolumetricFog. When I intergrated with EnviroSky.. I got compile error. Now I cannot play my project anymore :-(
     

    Attached Files:

  32. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    It looks you have some compiler errors. Could you please show the console errors?
    Also make sure you use latest versions of the assets.
     
  33. unity_c1ndWE1Nn46iPg

    unity_c1ndWE1Nn46iPg

    Joined:
    Jan 13, 2019
    Posts:
    53
    Sorry, I'm mistaken. I thought Volumetric Fog & Mist works with EnviroSky, so I activated integration which is the main error. Now I have back up my project. Everything's fine
     
    Thrawn75 likes this.
  34. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    A glimpse of the upcoming Fog of War SceneView editor:

     
    ftejada and atomicjoe like this.
  35. unity_c1ndWE1Nn46iPg

    unity_c1ndWE1Nn46iPg

    Joined:
    Jan 13, 2019
    Posts:
    53
    Hello, Kronnect!

    Is there any way to make fog disappear at night starting at certain time from 5 PM to 6 AM in the morning because EnviroSky makes everything look too foggy at night with your asset
     
  36. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    You can hide the fog immediately using:
    Code (CSharp):
    1. VolumetricFogAndMist.VolumetricFog.instance.enabled = false;
    Or reduce density to 0 (which disables it):
    Code (CSharp):
    1. VolumetricFogAndMist.VolumetricFog.instance.density = 0;
     
    unity_c1ndWE1Nn46iPg likes this.
  37. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    146
    Hi Thrawn,

    How do I stop volumetric fog from auto creating \ attaching scrips to my various cameras? I remove it, but they get auto added back.

    Thanks
     

    Attached Files:

  38. Thrawn75

    Thrawn75

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

    When you create a Fog Area (at editor or runtime), it adds the VolumetricFog script to your main camera (the script attached to the cameras are responsible to render all fog areas).

    The Fog Area will look for a camera tagged with MainCamera, if not found will use any other camera. Either make sure your main camera is tagged as "MainCamera" or manually specify the target camera in the "Fog Renderer" field of your fog areas:

     
  39. unity_c1ndWE1Nn46iPg

    unity_c1ndWE1Nn46iPg

    Joined:
    Jan 13, 2019
    Posts:
    53
    Hello, Kronnect!

    Yesterday I tried your code, it worked but still did not fit my need. Now that I found a new way when I changed both fog color to soft blue it look beautiful at night but worse at day time. If possible, can you help me change fog color values from white fog color (at day time) to soft blue color (at night time) starting from 5 PM to 6 AM? I don't know how to code, it's really difficult for me
     
  40. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    The issue here is just how to know it's 5PM as this is a value managed by Enviro.
    I'll talk to Enviro author.
     
    unity_c1ndWE1Nn46iPg likes this.
  41. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    146
    Thanks for the tips on "mainCamera" tags. I set it now and hopefully it stops the bug. :)
     
    Thrawn75 likes this.
  42. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    50
    Hi! Is there anything I can do to make the asset work in 2019 HDRP or I'll have to wait for an official upgrade in the future?
     
  43. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Hi Hexer,
    Volumetric Fog & Mist is not compatible with HDRP and since HDRP is still under development there's no estimated date at this moment for a future compatible version. In fact final version of HDRP will require custom effects written for HDRP (PPSv2 effects won't work).
    Regards
     
  44. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    50
    ::sniff::

    I know it's not your fault! Thanks for the awesome asset BTW :D
     
  45. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Thank you. Believe me, when HDRP is out I'll evaluate what it involves.
    Cheers
     
  46. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Hi!

    Added Enviro time of day integration. Thanks to @Vondox for the quick response and support.

    A new script is available in the new beta which allows you to define color/density grandients that match the 24h day cycle. Note that these modifiers are temporary, do not change your fog settings so transitions work perfectly.



    To grab the latest beta please sign up on the support forum on kronnect.com and send me a pm with your invoice number.

    Cheers
     
    Last edited: May 9, 2019
    Dwight_Everhart likes this.
  47. timbo_molony

    timbo_molony

    Joined:
    Jun 5, 2017
    Posts:
    1
    Hi I've recently purchased the plugin and trying to figure out what's the best implementation setting for this on an Oculus Go or Quest. Documentation says to use dynamic fog and mist but beyond that not much more info. It's built successfully but makes the camera rotate in very excessive way. I'm also noticing a camera component is added to the OVR rig, which may be the culprit. Any ideas how to use this script without breaking VR cameras would be appreciated.
     
  48. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Hi,
    You can use both effects on your VR devices. Usually the procedure it's the same, just add the image effect script (either DynamicFog or VolumetricFog script) to your main camera. This camera may be called "eye camera" in some VR kits.
    Volumetric Fog & Mist is more complex thus can be slower and probably a no-go for many mid-range Android mobile devices but modern mobile devices or VR kits can even run it. It also depends on the view distance, options, etc.
    If you have issues other than performance, please send me a pm with your Unity version, platform and a screenshot of your fog settings. Thanks.
     
  49. rostik1975

    rostik1975

    Joined:
    May 14, 2015
    Posts:
    17
    Does this system support 2 directional lights at once? Thank you.
     
  50. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,174
    Hi,
    No, it supports 1 directional light and any number of point lights.
    Regards