Search Unity

Fog Volume 3

Discussion in 'Assets and Asset Store' started by DavidMiranda, Jan 30, 2014.

  1. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Good news. I've been digging into this problem and finally I found the solution for these warnings:
    They were causing slow compilation and huge shader files. It will compile smoothly now.

    Version v2.0a8 submitted for approval.
     
  2. mm_ASH

    mm_ASH

    Joined:
    Nov 15, 2013
    Posts:
    358
    Hi David!
    I want to create dark shadow volume.
    Previously it was possible, but in new version it seems like additive blending is applied.
    Can you help me with that?
     
  3. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    humm, nope
    2016-03-11_12-01-05.jpg
     
  4. mm_ASH

    mm_ASH

    Joined:
    Nov 15, 2013
    Posts:
    358
    I don`t need noise, disable it please to see the problem.
    I knew that it works with that option ;)
     
    Last edited: Mar 12, 2016
  5. mm_ASH

    mm_ASH

    Joined:
    Nov 15, 2013
    Posts:
    358
    Hi David!
    Any news about my problem? Still waiting for solution =(
     
  6. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Disabling noise won't change anything, the shader blend mode is
    Code (CSharp):
    1. Blend SrcAlpha OneMinusSrcAlpha  
    , so it can be black.

    http://docs.unity3d.com/Manual/SL-Blend.html
     
  7. mm_ASH

    mm_ASH

    Joined:
    Nov 15, 2013
    Posts:
    358
    I know that I can`t be because it is just can`t be :D
    Have you checked that in editor?
    I have Deferred Rendering Path + Linear Space, maybe that cause problem.
    But for me when you set solid black you just can`t see volume at all.
    ...and yes I`ve seen shader code, it`s alpha blending but because of some strange reason it behaves like additive.
     
    Last edited: Mar 15, 2016
  8. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    cansino el nota.jpg
     
  9. mm_ASH

    mm_ASH

    Joined:
    Nov 15, 2013
    Posts:
    358
    You were right, sorry
    in linear space black color with visibility=5 is absolutely invisible but white colors looks are pretty noticable. Lower visibility values helped.
     
    Last edited: Mar 15, 2016
    hopeful likes this.
  10. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    good good ;)
     
  11. Knil

    Knil

    Joined:
    Nov 13, 2013
    Posts:
    66
    Does this support all the standalone platforms (Windows, Mac, and Linux)?
     
  12. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Im on OSX and it works great for me. (Yosemite)
     
    DavidMiranda likes this.
  13. _ben

    _ben

    Joined:
    Apr 21, 2013
    Posts:
    7
    Just wanted to confirm this version fixed my previous build problem. Thanks David!
     
  14. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Marvelous!
     
  15. Juggernaut_Games

    Juggernaut_Games

    Joined:
    Jan 20, 2013
    Posts:
    1
    Hi David!

    I love this asset and use it extensively in our game! We updated to the latest version hoping to resolve an issue our OSX users are seeing with the fog volumes, but they're still encountering it and we're seeing a shader compilation error when building for OSX:

    Shader error in 'Hidden/FogVolume': 'mul' : cannot resolve function call unambiguously (check parameter types) at line 216 (on opengl)

    Compiling Vertex program with _FOG_GRADIENT
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTO

    and

    Shader error in 'Hidden/FogVolume': '_NoiseVolume' : undeclared identifier; 'tex3D' : cannot resolve function call unambiguously (check parameter types) at line 150 (on metal)

    Compiling Vertex program with _DOUBLE_LAYER
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP

     
  16. MorganSandb

    MorganSandb

    Joined:
    Jun 4, 2015
    Posts:
    19
    Hi We are experiencing some problems when using DX11 and Fog volumes. Our scenes get white square artifacts.
    They are View dependent, and will popp inn and out based on camera angle, but the artifact looks to ignore the geometry of the scene. squareArtifacts.JPG
     
  17. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Partially solved...

    Are you using dx11 dof or maybe a bloom effect?
     
  18. MorganSandb

    MorganSandb

    Joined:
    Jun 4, 2015
    Posts:
    19
    im using DX11 with bloom and dof, but the problem still happens if i turn those effects off :/
     
  19. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    I was having that same issue. I noticed unity's new cinematic effects make little black/white dots sometimes with fog volume. Dof exacerbates these if its hdr. Putting my dof after my tonemapper made the issue unnoticeable for me, at no cost to the look of my dof. Scion tonemapper made really awful white pixels as well, so I think fog volume has some issue with certain tonemappers.
     
  20. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Yes, I have experienced this before. I think this is caused by negative color values or even when a pixel has a very high value. So when we add postprocess effects these crazy pixels are revealed causing different behaviors. This is not really related with Fog Volume itself, the problem comes from the scene shaders. Probably from the specular term. I remember I had to modify the very early standard shader versions when I was working for Unity to avoid this problem. It was returning extreme values for roughness=0 and stuff like that.
     
  21. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    That's what I thought initially as well, but I isolated my particular issue to fog volume/scion. My white specs went away when I disabled the fog or scion tonemapper, and they move around when I change volume dimensions. I moved away from scion because I can't live without your light scattering. Now unity's new cinematic tonemapper gives black dots, and they aren't as noticeable. I can ship with them. I'm not sure if the black dots are from a similar fog volume incompatibility, I'll have to check when I'm at my workstation.
     
  22. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    I would start with a postprocess that makes this at the top of your post process chain: SceneColor = clamp(SceneColor, 0, 1000);
     
  23. ccburton

    ccburton

    Joined:
    Mar 17, 2013
    Posts:
    31
    Hi David, I'm currently getting purple fog when I attempt to run this in iOS on an iPad. Compiling it in OS X 10.11.2. Looks great in a desktop build, but the iOS is very purple and seems like an error. Unity version 5.3.5f1
    OpenGL v4.1

    WARNING: Shader Unsupported: 'Hidden/FogVolume' - Pass '' has no vertex shader

    WARNING: Shader Unsupported: 'Hidden/FogVolume' - Setting to default shader.

     
    Last edited: Jul 17, 2016
  24. Fockerian

    Fockerian

    Joined:
    Sep 9, 2014
    Posts:
    6
    Fog works with WEB GL?
     
  25. Fockerian

    Fockerian

    Joined:
    Sep 9, 2014
    Posts:
    6
  26. Deleted User

    Deleted User

    Guest

    Hello Good sir! I have an issue when my camera have 0 in X rotation. Then horizontal lines appear!
     
  27. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Sorry, I can't test on iOS :/
    Never tried. I will look into it.
    Woot? That has no sense :D

    Well, good news, I have found the ultimate intersection method:

    2016-09-18_19-21-17.png
     
  28. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Yes, working on WebGL. I have never tested this platform before. Gamma color space and LDR, right? So ugly :)
    Well, everything is fine except the volumetric noise okay? Don't enable it in the next update.

    2016-09-18_22-34-27.png
     
    Last edited: Sep 18, 2016
  29. Deleted User

    Deleted User

    Guest

    Yes, well After more research they apeared when the camera was perfectly alligned with the fog volume, when they had the same rotation, and was only visible when the camera was moving. Just added in the script that the rotation shall never be 0. Also! I added a hacky rotation thing in the noise UV, so we could create this "Vortex" look sorry for potato screenshot, but it was what i had at hand! Really loving how the "fog volume" good job PotatoScreenshot.JPG
     
  30. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Seriously?, that is awesome!
     
  31. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    Not sure if this is still a problem but just wanted to add that clamping the fog value used for the alpha fixed the issue for us.

    Code (csharp):
    1. fog = saturate(fog); // etc...
     
    Deleted User likes this.
  32. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    That's okay if you are not in hdr. If so, I would try max(0, fog) instead.
     
    Deleted User and spraycanmansam like this.
  33. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Hi users. I have very very good news. I have added a ton of new features for the next version. I will probably move this to a 3.0 version + upgrade fee, since its a major review with many many improvements and new capabilities.

    1. Improved intersection method (100% perfect)
    2. Improved noise shadows
    3. Added tonemapper (in case you can't use a tonemap postprocess) + gamma control
    4. Added pointlights. 100% dyamic, you don't have to do anything but adding a script to the lights
    5. Better usage of jitter. You can now use less iterations since the jitter is now much more effective
    6. Added spiral deformation and rotation
    7. Better color blending in gradients
    9. Optional 100% procedural noise. (Much more expensive than sampling the 3DNoise texture, but performance is not affected by noise size)

    TODO:
    New interface. It was okay when it was simple, but the current inspector is too large.

    Once I do the new inspector UI I will release v3.

    Some gifs I captured during the time I have been working on this:

    Here we see 3 things: new shadows, vortex effect and pointlights added dynamically to the raymarch loop when they get into the volume. If they are outside, it wont be computed. You don't have to do anything manually!
    https://i.gyazo.com/cc2d2c0e0048df7f53ad806622553c41.gif


    Pointlights positions are transformed to allow you to rotate and move the volume without any weird behavior:
    https://i.gyazo.com/08377d06c7d68df79a68f55e3610549c.gif


    Better color blending and intersections with scene:
    https://i.gyazo.com/48141d802658e5059f845ea49097f21a.gif


    Super cool shadowing:
    https://i.gyazo.com/afd783406e4e6092a8d01a30aa2283bb.gif


    Alien attack ;):
    https://i.gyazo.com/40c5c970fa38117b07ad6f807b75f10a.gif


    Thanks for buying!

    Regards.
     
    Last edited: Oct 19, 2016
  34. Deleted User

    Deleted User

    Guest

    Looks cool man!
     
  35. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    And thanks for the idea ;)
     
  36. Deleted User

    Deleted User

    Guest

    if you want to be crazy with the vortex, suport for the directional light/sun to have a "lightning" chance that flashes the vortex! :p :p
     
  37. 2freed0m

    2freed0m

    Joined:
    Jun 17, 2015
    Posts:
    10
    have issue with transparent shaders
    any fix? Screenshot_623.jpg
     
  38. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    As explained in the documentation, page 18, if scene shaders don't write depth information, then Fog can't be done correctly for those pixels.
     
  39. Deleted User

    Deleted User

    Guest

    Hello Good Sir, David! I do have some issues with the "Noise" In Unity 5.4, On PS4 and XBOX ONE, The fog volume will not show up at all. I I don't get any compile issues on the platforms, and I cant find any issues, but, do you have a fix for consoles?
     
    Recotech likes this.
  40. 2freed0m

    2freed0m

    Joined:
    Jun 17, 2015
    Posts:
    10
    I tried to do it myself but it didn't work out.
    Can you provide an example of transparent shader that will work properly with your Fog.
    ples :>
     
  41. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    Hikiko66 likes this.
  42. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Thanks for the idea! It's so cool. I did something similar some time ago:
    https://twitter.com/BetaVersionOfMe/status/783257996151382016

    And today I have something to show:
    https://twitter.com/BetaVersionOfMe/status/811903267223601152

    UI: the inspector hides and shows the options depending on what's activated
    https://dl.dropboxusercontent.com/u/16565603/Unityforums/2016-12-22_12-06-34.mp4


    Im sorry, but that's not possible. I already tried to do a special shader, but it's impossible because The Fog is generated using Fog Volume data, and I can't take that data to another shader :/
     
    JonDadley, elbows and punk like this.
  43. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Something to share :)
     
    Seith, JonDadley, punk and 1 other person like this.
  44. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    Awesome work David! Any ETA for 3.0?
     
  45. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Humm, Im not sure yet. Im currently working full time on this, adding more options, improving methods.... Its pretty complex. I hope to get it ready in February.

    Let's see some random screens:
    I have added detail cascades and tested distance field functions too. Just exploring possibilities :)
    2016-12-23_14-23-24.jpg 2016-12-23_14-21-48.jpg 2016-12-23_14-21-22.jpg 2016-12-23_4-50-40.jpg 2016-12-23_14-25-22.jpg
     
    elbows, JonDadley and punk like this.
  46. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
  47. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    That looks awesome ;)
     
  48. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Thanks!

    Aaaand, I have something new to show. I thought that it would be good to be able do model noise with a specific shape, useful for cloud modeling or interiors.... so I've been thinking how to make that possible. Here is the first result I got: https://twitter.com/BetaVersionOfMe/status/813383360085106692

    Additive

    2016-12-26_14-56-37.jpg


    Subtractive

    2016-12-26_14-53-05.jpg
     
    JonDadley, elbows and punk like this.
  49. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Well, 40 hours of work in 2 days.... maybe too much :)
    Added normal computation for direct lighting. Extremely expensive because noise is computed 6 times to do the job. To optimize, I added a distance slider, so we can compute that only when we are close.
    Some lovely screens:

    2016-12-27_23-33-01.jpg 2016-12-27_23-33-08.jpg 2016-12-27_23-32-50.jpg 2016-12-27_23-31-54.jpg 2016-12-27_23-31-44.jpg
     
  50. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Hello folks,
    Some progress. I have added color absorption and fog working together with clouds, so we can have a cloud sea with fog above or below it :) The inspector is also looking pretty good. Ah, and sorry for the banding, I broke something but couldn't find it yet ;)

    2016-12-29_19-10-26.jpg 2016-12-28_22-30-53.jpg 2016-12-29_19-04-51.jpg 2016-12-29_19-05-00.jpg 2016-12-29_19-05-12.jpg
     
    punk, OCASM and Hikiko66 like this.