Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

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,139
    As stated, profiles have been used configure style aspects (colors, densities, animations, etc.). All legacy presets like windy mist, frost ground, sand storm, etc. are now available as profiles. And you can create volumes which will lerp all settings smoothly as you enter/exit them.

    Fog void settings may require additional treatment from code though. For instance, if you set a fog void to follow a certain character, it must be set from code at some point and then, depending on the character or situation you may need to change the void radius - so because these settings seem more dependant on game logic they have not been included in the profiles ... for now. Some users have even tweaked the asset to add a second void..

    Yes - get a reference to the camera or fog area Volumetric Fog script and set the properties accordingly. You can get the reference to the main script with the convenient VolumetricFog.instance static method, for instance:

    Code (CSharp):
    1. VolumetricFog.instance.density = 0.5f;
    Next beta will include them (available anytime next week on our support forum).
     
  2. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    Hi there! I'm really enjoying using your asset and I think the results are quite nice.

    I just have one issue: I've been able to get it working with another TOD plugin, AzureSky Dynamic Skybox. However, while the sun directional light is assigned in Volumetric Fog script, and it's getting the sun's colour changes, the fog's colour is not updating/transitioning smoothly. For example, when the sun rises, it looks like Volumetric Fog is only updating the sun colour every .25ms (estimated) instead of every frame.

    Where might I start with smoothing out this transition? Is this an issue you've encountered with Time of Day plugin users at all?

    EDIT: So in an empty test scene the transition is much smoother... still not seamless but much better automatically. I will update if I solve this!
     
    Last edited: May 14, 2018
    Akshara likes this.
  3. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    When directional light rotates, Volumetric Fog & Mist needs to update an internal texture where some optimizations are baked - that can be expensive so there's an angle threshold which may cause the jump.

    Edit VolumetricFog.cs script and look for this line:

    Code (CSharp):
    1. const float TIME_BETWEEN_TEXTURE_UPDATES = 0.2f;
    replace it with

    Code (CSharp):
    1. const float TIME_BETWEEN_TEXTURE_UPDATES = 0f;
    And see how it goes.

    It will be exposed in the inspector in next version.
     
    Akshara likes this.
  4. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19

    Thank you very much for your swift reply! I'll try it today.
     
  5. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    Hi Thrawn, thank you for your support yesterday, it solved my problem!

    If you don't mind, I have another question :) I'm using Fog Areas to obscure certain rooms of a level until they are discovered (essentially volumetric fog of war). This works beautifully on square rooms, but I'm looking for a solution to non-square rooms.

    I figure I can achieve this through the use of fog voids subtracting from an area to achieve an angled corner (Edit: Actually, not sure if I can do this?)

    Is it possible to assign a different mesh, or a texure to create different shaped for areas? For example, a triangular fog volume? I know that Box and Sphere areas are supported out of the box. In my initial test, assigning a different shapes mesh to the fog area didn't work. Just wondering if you can give me any more info.
     
    Last edited: May 15, 2018
    Thrawn75 likes this.
  6. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Box and spherical shapes are analytical and deeply integrated in the shader and same render pass (that's why they're so fast). To cast fog on irregular areas, you could indeed try the fog of war feature instead which basically reads from a mask texture to pick the transparency at any given x/z position. Check out the fog of war demo script for sample usage.
     
  7. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    Thank you again for your quick reply! You're very helpful. I will work on this new approach today.
     
  8. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    Hi again,

    I looked into your solution. I'm not sure this method can encompass my needs, but perhaps I am just offtrack:

    I was able to use a texture mask to determine a fog cutting area in the demo scene, but since the Fog of War script is applied to the camera instead of being a fog area, it seems to fog an entire area and then cut only one part out of it. I would need to be able to cut fog of war on a per-room basis, rather than all on or all off. Is that possible?

    Ideally it would be amazing to be able to use this texture mask approach on a Volumetric Fog Box Area area to determine parts of the Fog Box Area to be transparent. Is this possible/if not, could it conceivably be extended?
     
  9. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    That's interesting, thanks for the suggestion. I'll check this and send you an update so you can try it :)
    You could also sign up on our support forum to get latest beta releases.
     
  10. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    I didn't realize there is a support forum, I will go check it out now! Is it better to just post there instead?

    Since you are going out of your way to do a check, I'll make sure to outline my use case and add an example photo:

    I hope to scale a Volumetric fog box area to fit interior rooms. When a player enters the room, the Fog Area's Density
    value will tween to 1, revealing the room. For non-square rooms, I would love to use an alpha map to remove areas of the Fog Area which stretch beyond the room's walls.

    In this screenshot you can see my problem with needing to mask out the fog which reaches beyond walls.

     
  11. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Well, the support forum has a private board for registered customers where you can download latest beta versions. It's here. For general / quick questions you can use Unity forum, no problem but lengthy discussions about a single topic are better handled on the support forum. It's your choice :)

    Thanks for the screenshot!
     
  12. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    Amazing!! I registered for the support forum and sent a PM with my invoice number to Kronnect. Depending on how our experiment progresses, I will make a thread there to share my experience with this approach to Fog of War :D
     
  13. Unityaware

    Unityaware

    Joined:
    Feb 14, 2014
    Posts:
    86
    I just just added your "Volumetric Fog and Mist" to the "VR Panorama 360 PRO Renderer", but the fog does not render. Could you please explain how I can get it to show up in the rendered VR video stills please?
     
  14. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Hi!
    Ensure you have the “Enable Multi-Camera” in Volumetric Fog inspector option checked (VR Panorama spawns several cameras hence the need to enable this option).
    Regards.
     
  15. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Just released a new beta on the support forum with the new mask feature. Looking forward to your impressions / tests.
     
  16. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    Hi Thrawn, I'm using it now and it looks great!! Thank you for your hard work. I think it will fit my needs superbly :) The only problem seems to be that the fog mask meshes are rendering on top of everything else (but I left this comment on the Kronnect forums as well, we can discuss there as you prefer)
     
  17. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Cool, thanks for trying out! I just read your message over there. I’ll take a look at your test package when you’ve it. This feature opens indeed lot of possibilities..
     
  18. deuxieme

    deuxieme

    Joined:
    Jul 15, 2015
    Posts:
    19
    Sure thing! There's a link to my test package over on the forum whenever you've got time. Again, really appreciate your work on this. Will definitely be recommending this asset to anyone who asks.
     
    Thrawn75 likes this.
  19. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Hi all,

    The new update 9.3 is now available - this is the changelog:

    - Added mesh volume mask feature for Unity 2017.1+ (enable it in Shader Options)
    - Added downsampling, fog void and light scattering options to profile scriptable object
    - Added texture update interval parameter to inspector (reduce to make directional light influence update faster)
    - Added WebGL compatibility
    - [Fix] Fixed inspector UI refresh issue when using profiles
    - [Fix] Fixed issue with a render texture not being correctly released when transparency blend is enabled (only Unity 5.5-5.6 versions)

    Also a new Discord server is now available! Sign in for quick answers and a nice chat on our assets :) https://discord.gg/7HQgT3v
     
    Akshara likes this.
  20. WILEz1975

    WILEz1975

    Joined:
    Mar 23, 2013
    Posts:
    288
    Hi ... I have this problem:

    I would like to use the Volumetric Fog Area Box but the fog can also be seen through the walls:(
    Is it not possible to avoid it? Otherwise the asset is useless for me :confused:
     
    Last edited: Jun 15, 2018
  21. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    To contain the fog inside certain rooms you can enable the Fog Mask feature. It’s the last section in the inspector. It allows you to define certain objects that act as containers for the fog and it will clip outside them.
    The objects will be invisible at runtime - their only purpose is to provide a mesh that limits the fog area.

    Also make sure your walls shader writes to depth camera buffer. If you’re unsure, please send me the shader and I’ll check or modify it properly.
     
    Last edited: Jun 15, 2018
  22. WILEz1975

    WILEz1975

    Joined:
    Mar 23, 2013
    Posts:
    288
    Using Layers is not really the best solution for me. All the walls are on the "Delfault" Layer and I can not manage my layers based on fog.
    If I use the "Default" layer as a mask (in the Volumetric Fog script on my camera), the walls are no longer visible.
    If I use the "Default" layer as a mask (in the Volumetric Fog script on my Volumetric Fog Area Box), the fog are no longer visible.:(
    My shaders are simple "Standard Shaders".
     
  23. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    The way Fog Mask works is intended to be used differently. Do not use your walls but place a custom cube on your room (covering the area) and assign that cube to a different layer - then use that layer that only contains the cube for the fog mask. When you run the scene, that cube will become invisible.
    If that does not work for you, can you send me a scene so I can advise alternative options?
     
  24. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    53
    Hello buddy, i have a little issue with Blend Mode and Depth Blur.
    Random black spots appear in screen when this two modes are enabled
    upload_2018-6-18_16-51-8.png

    No more errors without blend:
    upload_2018-6-18_16-52-30.png

    how can i fix this problem without disable blur/blend mode (blend mode gives a better visual quality to the project)
     
  25. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Hi @Deceiver !

    Thanks for the screenshots - the black spots could be due to NaN values in the framebuffer. Will add some protection to the pixel shader and send you an update to test.
     
  26. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    53
    Fixed adding this line before return of fragBlur in shader Blur

    pixel0 = clamp(pixel0, 0.0.xxxx, 1.05.xxxx);
    return pixel0;


    thanks for the quick repply @Thrawn75
     
    Thrawn75 likes this.
  27. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    678
    Hi,

    what happen to transparency objects, like car glass at distance or windows?
    There is no depth information and the objects stay at its color.

    Eg to my Water Towers support.
    nfs_run_scatt.jpg


    What happen to your fog in this case?
     
  28. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Volumetric Fog & Mist provides the following options to handle transparency:
    a) Render before or after transparent queue
    b) Do a custom depth pass with transparent objects thus completing the depth buffer
    c) Render fog over opaque geometry and then blend transparent objects on top of fog but with user-defined transparency level.

    Regards.
     
  29. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
  30. eric_delappe

    eric_delappe

    Joined:
    Dec 10, 2015
    Posts:
    17
    I see that Dynamic Fog and Mist has been updated to 6.5, but the version included with this asset is still 6.0. Will it be updated to 6.5, with the support for SRP and post processing profiles?
     
  31. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Sure! Latest version of Dynamic Fog & Mist (6.5 currently) will be included in next update of Volumetric Fog & Mist. In the meanwhile, you can send me a pm with your invoice number and I'll send you a download link.

    fyi, all registered users on our support forum have access to latest releases.
     
  32. matteumayo

    matteumayo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Hello,

    Amazing asset, however I've run into an issue, especially important in VR, which is I can't seem to eliminate aliasing around edges of objects in front of the fog:



    (This image is taken beneath terrain, but the same is evident for any object that stands in front of the fog.)

    The fog has a distance of 1000, but I also tested with a distance of 350. There's no downsampling. It's very close to one of the default profiles, just heightened and scaled up.

    I tried with lots of settings, as well as searching this thread, but the only thing I can think to make this at least workable is to us temporal anti-aliasing, of which the current solutions available are lacking.

    Do you have any solutions to this problem? Is there a configuration that works for VR (no aliasing/edge artifacts?)

    Thanks.
     
  33. Thrawn75

    Thrawn75

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

    The issue is related to how MSAA works in forward rendering path and _CameraDepthBuffer storing the resolved depth for each pixel. As a result, the fog image effect can only use one single depth value per pixel even if the multiple samples taken by MSAA have different depths.

    Averaging depth inside the GetDepth() method of VolumetricFog.cginc file can reduce the problem in some cases but this is not a good solution either since the average is still one single depth value considered for all sub-samples.

    You can try to enable downsampling x2 (in Volumetric Fog inspector) which in practice forces pixels to average colors and depth reducing the issue.

    If you prefer not using downsampling, you can make a change in code so Volumetric Fog still applies the final edge filter pass at the end:

    In VolumetricFog.cs script, around line 2847 change:

    Code (CSharp):
    1. if (_downsampling > 1f) {
    2. ...
    To:
    Code (CSharp):
    1. if (_downsampling > 0f) {
    2. ...
    Similarly, in VolumetricFogInspector.cs change line 966:

    Code (CSharp):
    1. if (_downsampling.intValue > 1) {
    To:

    Code (CSharp):
    1. if (_downsampling.intValue > 0) {
    Now you can leave downsampling to 1 (which will preserve resolution) while allowing the end pass with edge filter.


    Some testing pictures for the above changes:

    No changes:


    With the above change and "Edge Improve" option disabled:


    With above change and "Edge Improve" enabled:
     
    matteumayo likes this.
  34. matteumayo

    matteumayo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Thanks for the in-depth and quick reply!

    The downsampling 1 improve edges mode does alleviate things slightly. With downsampling 2 and up, there's a larger 'outline' (see the blue lines along the top edges - though this is with downsampling 1 with improve edges on.)

    Unfortunately even with this, there is still heavy aliasing, as seen in this image with the top edges (close to camera) as well as aliasing, although with no 'clear outline' as is the case when the only thing past the fog is the skybox.

    The 'outline' can be alleviated pretty solidly by matching the fog's color to that of the skybox/clear color. But, the alaising of distant objects standing in front of the fog is still present.



    Is it fair to say that it's not possible to eliminate this aliasing further without a third-party final AA effect? I've tried a variety of tricks for disguising the aliasing that's left, just experimenting with the different combinations of settings in the inspector, but I haven't found anything as of yet.

    Since the aliasing is only extreme with distant objects that stand before the fog, it could be fixed by making the distance cutoff for the fog very close, however, the view distance would be very low of course. My use case is to disguise view distance cutoff immersively for VR, and at the moment the far clipping distance is 1000.
     
  35. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Yes, try adding FXAA at the end of the stack.

    On the other hand, Fog materials do not present this issue since the material shader embeds the fog effect and in that case MSAA will do the correct thing: blend pixels with different fog accumulations. Fog materials are included with Dynamic Fog & Mist (also present in the Volumetric Fog Package) - the downside is that you need to replace your materials to use this solution and also the integrated fog effect is more limited although for a depth based fog effect should be more than enough (and it will be faster).

     
    Last edited: Jul 29, 2018
    matteumayo likes this.
  36. Alexey1B

    Alexey1B

    Joined:
    May 15, 2017
    Posts:
    19
    Hello, i have an issue with fog & Vegetation Studio & VR, (oculus cv1, U:2018.1.0f2, any pass mode) .At begining all ok, but after move head - fog become like another layer(moved a bit) and moving like billboard. I have suspicious what it is due to dynamic trees rendering of VS, when rotate head some trees dissapear, some appear in visible area and this produce this issue, is any idea how to solve it?
    issue1.png
     
  37. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    It looks like a discrepancy in the depth buffer. I’ll contact Lennart on this issue and see if he can shed some light.
     
  38. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,220
    Hi. What tree shader are you using?

    Lennart
     
  39. Alexey1B

    Alexey1B

    Joined:
    May 15, 2017
    Posts:
    19
    Hi, VS shaders from mountine trees package, so VS_tree_bark_... & VS_tree_leaves... .Also i check with those prefabs without VS, just put many prefabs of trees manually and in this case all ok
     
    Thrawn75 likes this.
  40. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,220
    trying to replicate it with the mountain trees now
     
  41. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,220
    Hi.

    I did a test setup now. Vegetation Studio, the mountain trees and the latest volumetric fog.
    tested with multi and single pass VR on an Oculus Rift. I am having trouble replicating the setup.
    Fog behaviour seems ok for me.

    Could you create a small demo project and send me a link in a private message?

    Lennart

    Image 415.png
     
  42. Alexey1B

    Alexey1B

    Joined:
    May 15, 2017
    Posts:
    19
    Hi, i also a long time could not reproduce on clean project, but finally i found, it is happens when OVRCameraRig (from oculus utils) - component OVRManager has checked Enable adaptive resolution, and min max render scale 0.7 - 1.2 . After return to default: ucheck & 0.7-1 this issue not appears, for me it is ok, but maybe this will help for somebody. When try to reproduce with this settings - some time issue appears in seconds, some time need almost 1 min
     
    Thrawn75 likes this.
  43. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    4
    Hi.

    Is it possible to rotate the clouds towards a point or use the rotation of parent object instead of being locked on planes? Or is there a way to fill an area with clouds with no orientation? I'm having problems as I try to get this working on a spherical planet. I might have been a little bit too optimistic (or desperate) as I'v been searching for tutorials for volumetric clouds for a long time without success and then decided to buy this.
     
  44. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Hello, unfortunately Volumetric Fog & Mist is optimized for "normal" (non curved) worlds. How big is your spherical world in units?
     
  45. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    4
    I'm currently using Planetary Terrain asset for my world and it has a radius of 6371000 units.
     
  46. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Well, you could create localized fog / cloud effects with Volumetric Fog & Mist but not cover the entire world of such dimensions.
     
  47. Alexey1B

    Alexey1B

    Joined:
    May 15, 2017
    Posts:
    19
    Hi, i found what RenderTexture not work in Single pass but work in Multi & Single pass instanced (RenderTexture from demo scenes)
     
  48. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    95
    Hello, I'm using your Volumetric Fog asset to render very thick fog in a scene but I'm having trouble with it rendering a transparent glass material (on cars).

    Although I can get the desired look with the glass by disabling "Render Before Transparency" and then setting Transparency Mode to None, this unfortunately affects other transparent objects in the scene (I have volumetric light beams as well).

    If I set the Render Before Transparency back to enabled then my volumetric beams look good, but the glass material is not affected by the fog (obviously).

    I'm not sure how to resolve this. :(

    Is it possible to set the blending pass to a layer mask so as to only affect specific transparent objects in the scene? Or can you recommend a glass material/shader that works with your fog correctly without the need to for the Blending Pass?

    The Volumetric Light Beam asset I'm using is here: https://www.assetstore.unity3d.com/en/#!/content/99888

    Thanks.
     
  49. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Hi! Sorry, do you refer to demo scene #3?
     
  50. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Hello,
    What's the problem when disabling "Render Before Transparency" and the Volumetric Light beam? Is it getting wipped by the fog? Yes, we can try a custom glass shader that renders before transparent queue and still be transparent. Can you send me an email with more details and a screenshot please?