Search Unity

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,905
    Thanks, will check this.
     
  2. Jbaker08

    Jbaker08

    Joined:
    Oct 8, 2012
    Posts:
    52
    Is there a way to cut holes in fog?
    You have 'fog void' setting but it only cuts out around the player (I couldn't even get that to work properly).
    I need global fog on my camera, and then I wanted to place 'fog void zones' in buildings etc to stop the global fog rendering inside them buildings.

    I have multiple buildings, some very large. Fog doesn't tend to go inside buildings.

    I hope you can help.

    Thanks
     
  3. Kronnect

    Kronnect

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

    If you have many areas where you want to exclude the fog, the best (performance-wise) choice is to use the fog of war feature. Check the pdf for API you can use to set the fog transparency in world space positions (basically you call
    SetFogOfWarAlpha passing a world space position, radius and alpha).

    In the version for the built-in pipeline, you also have a feature called "Geometry Mask" which lets you specify geometry that acts as a cutout mask for the fog (check page 17 of the pdf). This mostly works for top-down games.

    Regards
     
  4. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
  5. Knbmedia

    Knbmedia

    Joined:
    Dec 8, 2014
    Posts:
    18
    Hello,
    I have a problem with Fog&Mist 2 and camera Far Clipping Planes.
    Using Unity 2019.3.0f6, URP 7.2.1 and Fog & Myst 2 (v2.2).
    When reducing camera Far Clipping, Fog partially disappears.
    See the attached screenshot. I've set the Far clippling plane to 500 and fog disappears in the center of the camera.
    Fog_clipping.png
    I have attached another example below. Far clip plane set to 100: objects are correctly occuled (behind mountain) but an horizontal strip appear in the fog.
    Fog_clipping_2.png

    It seems that the fog beyond the far clip limit is not rendered.

    Regards
     
  6. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Sent the fix by pm.
     
  7. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    In order to apply post processing to the fog, you must select "render before transparency." However, with that selected, things like streams and windows now render on top of the fog. Surely there is a solution to get post processing on the fog while still obscuring transparent objects behind the fog as well? I tried Beautify instead of PPv2 without any luck.
     
  8. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    You can use Volumetric Fog & Mist and Beautify in that order on the camera. Then fog will render before Beautify and both effects will render after transparent queue.
     
  9. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    For some reason that isn't working for me either. As you can see in this image, Beautify is placed after Volumetirc Fog & Mist, but the tint is not being applied to the fog.

     
  10. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    There must be a second Volumetric For script which is automatically managed by the fog script. Make sure both scripts are moved up before the Beautify script.
     
  11. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    Thank you, that does indeed fix it! However, this leads to another issue. If the fog is rendered after transparency, then our sun vanishes from the sky and doesn't exactly look great:



    So, I tried assigning the sun to the fog and now I get this:



    The directional light intensity is around 4.5. Lowering the intensity fixes the issue with the fog being blown out, but then the scene doesn't have the nice lighting that I want. Changing the fog colors values for intensity doesn't seem to have any impact.
     
  12. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Try reducing Light Intensity in Volumetric Fog inspector or making the fog Albedo darker to compensate the brightness of the Sun. Also try Beautify’s Sun flares option.
     
  13. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    That fixes part of it, but it doesn't impact the sun disk. Is there some other setting that I'm missing?

     
  14. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Tweak the Light Scattering options. Looks like they are burning the rays.
     
  15. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    Ah, that does the trick! Thanks so much.
     
    Kronnect likes this.
  16. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    One other question, this time about the scripting API. I've been digging around in the code, but nothing I've tried has worked so far. I've got a custom inspector that I set the time of day to move the sun in the sky. The problem is that as the sun moves through the sky, the fog doesn't update the light/color to match the new position/intensity/color. Is there a way I can force this update through the API?

    Here is a video to make it more clear:

     
    Last edited: Jun 7, 2020
  17. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Usually the Sun disc depicted in a procedural skybox is aligned with the direction of the scene main directional light which you should assign to the Sun property of Volumetric Fog & Mist. By assigning such directional light to Volumetric Fog inspector, the fog color, luminance and other properties will adapt to match the sun height and light properties.

    If you can't assign a "Sun" light or directional light to Volumetric Fog & Mist, or if you want to manually control the light direction, you can do so by setting the lightDirection property either in the inspector or using scripting:
    Code (CSharp):
    1. VolumetricFogAndMist.VolumetricFog.instance.lightDirection = <vector3>;
    This only works if the Sun property has not been assigned because in that case the sync is automatic.
     
  18. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    I do have the sun assigned to Volumetric Fog & Mist (the directional light in the scene is named "Sun/Moon"). I'm also using the built-in procedural skybox, and the sun is correctly aligned with the directional light. However, the fog doesn't update until I move the scene in the editor, and if I have the sun move through the sky in play mode, the fog doesn't update at all.

     
  19. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    It's strange. Are you sure the Sun/Moon gameobject reflect the rotation of the lighting? Perhaps it's a child object instead? You can check the feature creating an empty scene and adding the fog to the camera as well as the default directional light to the Sun property. Then, rotate the Sun and you'll see the fog colors and brightness react to Sun position in the sky.
     
    Last edited: Jun 7, 2020
  20. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    Yes, "Sun/Moon" is being directly rotated and has the direcitonal light component directly on it with no children. I get the same result in a default scene:

     
  21. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Maybe the Sun scattering option is burning the fog colors? Try deactivating it or reducing its intensity.
    It should look as in this video:
     
  22. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    It is less noticeable, but disabling the sun scattering doesn't fix it. It is really odd, because changing the rotation value directly in the inspector doesn't cause the issue, but if the value is changed in a script then it won't update the fog.
     
  23. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Can anyone tell me the differences between Kronnect's Volumetric Lights and Aura 2 ?
    Is it faster or anything?
    I already have Aura 2, but I don't know if Volumetrics Lights offers anything more or is better suited for specific cases.
     
  24. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    I've used both and find Volumetric Fog & Mist to be much more flexible. I wasn't able to achieve the look I was shooting for with Aura 2. The big one for me being the fog void option. I didn't do performance testing, so I can't say which is faster, but the performance cost in our current project has been minimal.
     
  25. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Thanks, I was talking about Kronnect's Volumetric Lights though, not Volumetric Fog (which I already have and love btw).
    I can't find a forum thread about this particular plugin and that's why I ask here, since it's by the same developer.
     
  26. benington

    benington

    Joined:
    Jan 14, 2014
    Posts:
    7
    Hey guys! I am the Content Manager of Kronnect, we are working on a new intro for Volumetric Fog & Mist V2, and we'd love to include footage from your own games that use this asset. If you want your take to appear on the video, share it here and we will be more than glad to take a look at it and eventually add it. If is not much to ask try to make it 1080p and in game view mode fly cam. Thank you so much!
     
    Last edited: Jun 22, 2020
    Kronnect likes this.
  27. mutp

    mutp

    Joined:
    Oct 1, 2018
    Posts:
    79
    Hi, I'm considering buying this asset (already have the first version) but I need for URP + VR. I was wondering if this works for it, and if the issue @DaleEidd mentioned was solved?
     
  28. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Yes, it's fixed.
     
    mutp likes this.
  29. SeanC88

    SeanC88

    Joined:
    Apr 21, 2012
    Posts:
    19
    Hello! I just purchases VF&M2 and I'm already loving what it is doing for my scenes! One issue I am hitting though - in the demo scene, I placed a Fog Void but I don't see any results. Is there something else I need to do for those to work?
     
    Kronnect likes this.
  30. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Did you enable Fog Void option in the Fog Volume component?
     
  31. SeanC88

    SeanC88

    Joined:
    Apr 21, 2012
    Posts:
    19
    Thaaaat would do it! Fixed! Thank you very much!
     
    Kronnect likes this.
  32. mutp

    mutp

    Joined:
    Oct 1, 2018
    Posts:
    79
    Does the URP version of this asset have support for volumetric spotlights and directional lights?
     
  33. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    The URP version of Volumetric Fog & Mist 2 supports directional and point lights.
    You can use Volumetric Lights to add scattering effect to spot, point and area lights.
    Note that both assets produce different effects - while Volumetric Fog & Mist is intended for fog atmospheric and localized effects (which can receive lighting from directional and point lights), Volumetric Lights is designed to add scattering/luminance to the area of influence of the lights.
     
    mutp likes this.
  34. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    H, I just bought your asset and after importing the URP package I get 2 errors:

    Code (CSharp):
    1. Assets\VolumetricFog2\Scripts\RenderFeatures\DepthRenderPrePassFeature.cs(43,34): error CS0115: 'DepthRenderPrePassFeature.DepthRenderPass.Configure(CommandBuffer, RenderTextureDescriptor)': no suitable method found to override
    Code (CSharp):
    1. Assets\VolumetricFog2\Scripts\RenderFeatures\DepthRenderPrePassFeature.cs(80,34): error CS0115: 'DepthRenderPrePassFeature.DepthRenderPass.FrameCleanup(CommandBuffer)': no suitable method found to override
    I'm on Unity 2019.4.1 with URP 7.4.1 at the moment. Is this a known bug?
     
  35. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Nope. It just works on those versions. Looks like your URP package is not correctly installed? Can you double check that URP 7.4.1 is listed and installed in the Package Manager?
     
  36. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    Hi, it is, I work on this project since last year and any other URP-specific asset works too (e.g. LUX URP shaders).

    upload_2020-7-13_17-58-48.png

    I wonder if I missed something, but can't see anything odd with my project.
     
  37. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    You could try removing Volumetric Fog & Mist folder. Then check there're no more errors in the console. Reimport again the asset. If problem persists, try deleting the Library folder.
    I have just tested your Unity/URP versions in an empty project and it works fine, no errors.
     
  38. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    So, I have tried:
    - removing then reimporting the Volumetric Fog URP package: no success
    - deleting the whole Library and reimporting everything for my project: no success
    - removing URP package and reinstalling it: no success

    For me the question is, why does the package think that there are no methods to override under DepthRenderPrePassFeature.DepthRenderPass when clearly everything else works in my game when it comes to rendering and shaders.

    Edit: I also have a custom render pipeline set up where after the forward rendering pass I also have a render pass to show an outline for specific objects then render some opaque and transparent objects afterwards. Tried what happens if I enable Depth for those specific render passes but nothing changed.
     
  39. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    I guess there's a class naming conflict here, which shouldn't occur because all Volumetric Fog & Mist classes use proper namespaces. The offending code can be found in the class DepthRenderPass which is defined within the DepthRenderPrePassFeature class. This DepthRenderPass class inherits from URP's ScriptableRenderPass class which declares the two virtual functions that are giving you errors. This should work fine, unless there're other classes with same names that don't use namespaces.. could this be the reason?

    One thing you can try is to simply remove the file DepthRenderPrePassFeature.cs from Volumetric Fog & Mist 2 (basically this feature just let you inject a custom depth pre pass to allow renderers that doesn't write to depth buffer to look correct with the fog).
     
  40. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    Doing so results in a similar error, so there is some naming conflict that causes a worse problem than just being able to remove the script:

    Code (CSharp):
    1. Assets\VolumetricFog2\Scripts\Managers\VolumetricFogManager.cs(87,13): error CS0103: The name 'DepthRenderPrePassFeature' does not exist in the current context
    I will look through the code base to see if I find anything that causes such a conflict. Very strange.
     
  41. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    There are actually no name suggestions in VS when I start to type "DepthR" and also the using statement is greyed out (not in use):

    upload_2020-7-14_12-46-42.png

    I tohught "DepthRenderPrePassFeature" would be part of the URP package, but it seems it's not?
     
  42. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Well, yes, in addition to remove the file you will need to strip out all references to its class from the asset.

    No, DepthRenderPrePassFeature is the name of the class included in Volumetric Fog & Mist. It derives from ScriptableRendererFeature which is part of URP.
     
  43. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    Yep, my bad, went through the code again and see the bigger picture now (I need another coffee, that'd be my excuse). It works indeed if I remove all references, but it doesn't let my mind settle down on it. If I ever have time I want to find out why I have to remove this feature when it works for others in various projects and setups.

    Thank you for your assistance, I will now go and test the Fog of War on an Android device and see how it performs, in the editor it looks very nice.
     
  44. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    58
    If anyone interested, I'm sharing a single real use case about mid-range mobile performance here. May aim is to add Fog of War to my game and I tested the volumetric version of this asset only out of curiosity on Android, because as I suspected (and as also hinted at in descriptions) it is too much for a mobile game when it comes to rendering. But I tried it nevertheless, later I also describe what I ended up with as a solution.

    Device: Samsung A5 (from 2016, model: SM-A510F), Android 7.0, Open GLES 3
    Software: Unity 2019.4.3 (LTS) with URP 7.4.1 and a custom render pipeline setup where an additional render pass is drawing outlines units behind other objects

    So, when I added the Volumetric Fog of War, the game's stable 28-30 FPS dropped to 14-16 FPS, even with Raymarching set to only 1 and other optimizations. It definitely looked gorgeous, but performance suffers if you don't target only the latest high-end devices.

    The solution in my case was, targeting older and not so great devices, is to make good use of the Dynamic Fog and Mist asset which you get with this one for free. ;)

    I added the Fog of War prefab from the Dynamic variant, tweaked it to my liking and then tested on the device. Good news is that as advertised, it has the least impact on performance and I can keep my 30 FPS happily.

    upload_2020-7-15_19-10-29.png

    Note that I actually have a perspective camera for this game and setting the Fog of War layer to anything else than sea level would distort the visibility in my case too much, but having it high would also make everything be rendered beneath it, which is actually what I want.

    To minimize the visibility areas' shift due to my perspective cam setup, I have set the FoW layer to 0 height and reveal areas exactly where my entities appear. I ensure that no matter high the terrain, trees or anything else is laid out on the map, the FoW is always rendered above those by having an additional render pass only for the FoW layer of mine, drawing FoW after all opaque and transparent objects have been drawn already. The effect is seen in the screenshot at the tree quite well.

    Happy customer here. :)
     
    Kronnect likes this.
  45. draverik

    draverik

    Joined:
    Feb 17, 2019
    Posts:
    19
    Volumetric Fog & Mist 2 - does it work with Single Pass instanced for VR? We have all working but now it dosn't work with single pass.
     
  46. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    There's a confirmed bug in URP which prevents world reconstruction to work properly in VR. We're in talks with URP team for a fix and we have already exchanged some work with them looking for a solution ASAP.
    In the meanwhile, make sure you're using latest version and try the workaround by uncommenting this line in CommonsURP.hlsl:
    //#define USE_ALTERNATE_RECONSTRUCT_API

    Please submit a bug report to Unity to ensure this is the same issue.
     
  47. draverik

    draverik

    Joined:
    Feb 17, 2019
    Posts:
    19
    Updating package to the latest version solve the problem. Thanks
     
    Kronnect likes this.
  48. unity_dMztkup1zHAh6w

    unity_dMztkup1zHAh6w

    Joined:
    Aug 1, 2020
    Posts:
    3
    Hi, I'm having trouble getting Volumetric Fog & Mist 2 to work with Unity 2020.1.0b and URP 8.1.0. I have Bundle's URP Shader installed and Render Pipeline Setting set up. Here is an image from the demo scene. スクリーンショット 2020-08-02 4.21.05.png
     
  49. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Hi,
    Usually this happens when your URP pipeline asset doesn’t have the Depth Texture option enabled. Note that you can have multiple URP assets (per quality level).
    Select Volumetric Fog Manager in hierarchy. Does it show any warning in the inspector?
     
    Last edited: Aug 1, 2020
  50. unity_dMztkup1zHAh6w

    unity_dMztkup1zHAh6w

    Joined:
    Aug 1, 2020
    Posts:
    3
    URP is set in all Quality and Graphics, Depth Texture is turned on in Settings, and there is no warning in Fog manager. スクリーンショット 2020-08-02 16.39.19.png スクリーンショット 2020-08-02 16.39.19.png スクリーンショット 2020-08-02 16.39.59.png