1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Are you an artist or level designer going to Unite Europe? Join our roundtables there to discuss artist features.
    Dismiss Notice
  6. Unity 5.6 is now released.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

[RELEASED] Fog Volume 3

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

  1. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    313
    bmccall1 do the demo scenes work for you ? If they do then it is probably an issue with scene scale I am guessing. I noticed that if you zoom out from the demo scenes then the effect turns off so that might be it. Either that or are you aren't scaling the cube in 3 dimensions or something. It looks like a rectangle not a cube there. For some reason the assets doesn't appear to play nice with some other shader packages though. I am guessing it is something to do with the unity shader compiler if I import some other assets the demo scenes stop working in fog volume. It might be some other packages that are stopping it working.

    If it isn't that though and you are in a hurry you could purchase v-light from brian su as he has added volumetric areas to it which produce a similar effect
     
  2. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    3,573
    I don't own any of his products, but I think they're interesting.

    Having each of them as separate effects seems likely to be inefficient, though. I'd prefer to see them combined.
     
  3. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    119
    I created a brand new unity 5 project and pulled in the demos and they don't work. :(

    I appreciate the help though, thank you for trying! And I wouldn't mind buying something, but I had actually written several game objects to interact specifically with this fog volume script. Things like when you walked into a sphere, the farther you got from the edge of the sphere the fog would get more intense, thus it was off when you were outside, and at full fog volume at a certain level inside the sphere. So its not just that I can't get it to render right any more, (which blows) but I actually wrote code in other parts of my game to work with it.
     
  4. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    313
    bmccall1 try importing the image effects standard unity package after importing fog volume my guess is that your project doesn't include the necessary image effects compiled already. The demo scenes do work with the latest version as long as you compile it for a pc or mac standalone platform. Also make sure you have your unity editor set to display the scene with a high enough quality setting to show the effect in the editor. Or simply compile the project and then set the quality to fantastic when you play it to check that it isn't just unity trying to disable it for performance.
     
  5. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    bmccall1, let's divide this into little parts first.
    1º Fog Volume 2 is more complex than previous versions, so when you update it from 1.x to 2 your previous config won't be valid at all. You will have to learn the new documentation and adjust parameters again. I know that's annoying but what can I do? :) I'm so sorry for that.
    2º Can you bullet out the console errors you are getting? I never upload a version to the asset store with console errors, obviously.
     
  6. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    313
    David_MG it does error for me when I import it into a blank project. It complains about not having the tonemapping image effect namespace. To fix it I have to import the image effects package.

    Also I would remove the exclusions for it trying to compile for mobile if I were you. Unity are updating their shader compiler at the moment so that everything uses the same shader compiler rather than separate ones for each platform. It pretty much means that eventually any opengles 3.1 compatible phone will be able to run any shaders up to the current directx11 level soon.

    Unitys shader compiler is still pretty flaky at the moment but in theory as long as you make a shader that works under directx11 it should work for all other shader model 5 platforms without you having to change anything.

    If you want to test it I would suggest just getting a cheap android phone or tablet that is running android 5.1 and has a mali t720 gpu in it.

    I would just simply make sure your shader works in directx11 which it does and just remove mention of mobile support until unity have finished their new compiler.
     
  7. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    119
    Understood. and I had actually entirely removed fog volume from the project as having it as part of the project was really bad.

    This is all in Unity 5.1.2f fyi.

    So here's the first picture: This is a brand new project with absolutely nothing in it, and I import fog volume:
    2015-07-28 10_24_53-Unity (64bit) - Untitled - FogTest - PC, Mac & Linux Standalone _DX11_.jpg

    This one is what happens when I import it into my existing project. Before and after.
    NOTE: There is NO fog objects in the scene at all, it just 'does this' when I import.

    BEFORE 2015batch17 - PC, Mac & Linux Standalone_ _DX1.jpg

    AFTER batch17 - PC, Mac & Linux Standalone_ _DX1.jpg


    and the console
    console2015-07-28 10_31_06-.jpg
     
  8. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Ok, the thing is that I used Tonemap in the demo scenes, so when I upload the package, it's linked and included automatically but not correctly, since all the needed scripts are not included. To avoid that, import like this:
    2015-07-28_16-21-30.jpg


    About the second error. That's so weird, I have never seen such error. There isn't any variable named _MainTex in my shader. That's a GUI error btw.
    Thanks for the tips.
     
  9. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    119
    Ok, yeah I am less worried about the console errors. MainTex errors usually have to do with shader forge. So I am wondering if somethign with shader forge is causing this.

    By the way, the white boxes are any meshes that have "Cube" mesh. If I create a brand new cube, its broken looking as well.
     
  10. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Humm, that's something new. Nobody have reported an error like that here.
     
  11. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,593
    @David_MG

    Hi,
    Every thing is alright in the Editor, but no fog in the build. (Windows, Unity 4.6.7, DX9). Any idea?
     
  12. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    730
    Hi David
    Fog Volume works great for me except for creating 'patchy' or 'cloud-like' fog. Can't seem to get anything even close, the fog is always consistent. Any tips or suggestions? Noise is not working for me as well, does it require DX11?
     
  13. SheldonLevine

    SheldonLevine

    Joined:
    May 6, 2015
    Posts:
    3
    Is Unity Free now supported? It don't see this specified in the Asset store or in the 2.0 documentation. Thanks!
     
  14. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Humm... I have been updating the asset only for the latest versions of Unity. PM me in case you really need some extra support.


    Yes, DX11 needed for volumetric noise. Check the included demos in the package!

    Yes, it is at last!
     
  15. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,593
    Thanks..
     
  16. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    484
    I get this error quite often when I undo something:

    UnassignedReferenceException: The variable FogMaterial of FogVolume has not been assigned.
    You probably need to assign the FogMaterial variable of the FogVolume script in the inspector.
    UnityEngine.Material.SetFloat (System.String propertyName, Single value) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:304)
    FogVolume.OnWillRenderObject () (at Assets/FogVolume/FogVolume.cs:196)

    I don't know if anyone else gets it. Reloading the scene (like going into play mode) makes it go away. Its extremely annoying.
     
  17. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    705
  18. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    247
    Testing Fog Volume in Unity 5.3.0b3

    The Asset does not work at all on Mac OS X El Capitan, the FogVolume shader just appears pink, with the following errors logged:

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

    I have submitted bug case 737480

    EDIT: Looking at the shader, the error on Mac is "undeclared identifier 'ShadowSamples'
    Testing on Windows 10 works OK.

    EDIT 2: Managed to fix FogVolume.shader on Mac. The problem is OpenGL 4.1 uses SHADER_API_GLCORE

    The fix is to change FogVolume.shader lines 7 and 111 to:

    #ifSHADER_API_D3D9 || SHADER_API_D3D11 || SHADER_API_OPENGL || SHADER_API_GLCORE

    Some of the scenes don't work using OpenGL 4.1, however starting Unity in 2.1 mode seems to work OK

    To do this on a Mac you need to start Unity with:

    open /Applications/Unity/Unity.app --args -force-opengl
     
    Last edited: Oct 19, 2015
  19. trx

    trx

    Joined:
    Aug 4, 2013
    Posts:
    7
    Hi David!

    Is it normal that it is not possible to change the origin of cloud?
    As soon as i changethe origin (worldspace) about 300-400 units the scene collision doesn't work properly. (funny is that it works when i translate another axis the same amount in the negative direction)
     
  20. vfxjex

    vfxjex

    Joined:
    Jun 3, 2013
    Posts:
    73
    Hi David,

    I tried to buy your fog using my school account and when I build it in android its just pink.
    any solution?

    Shader error in 'Hidden/FogVolume': 'ShadowSamples' : undeclared identifier at line 136 (on gles)
     
    Last edited: Nov 26, 2015
  21. bakteria

    bakteria

    Joined:
    Dec 23, 2015
    Posts:
    1
    Hi,
    Is it necessary to be inside of volume to render properly?
    I will need thick fog to be seen outside of building, through windows, and not having fog inside building.
    I haven't seen that kind of example.
    I was thinking about placing volume outside close to windows but Im not sure it will work properly.
     
  22. qkymber

    qkymber

    Joined:
    Apr 23, 2013
    Posts:
    4
    Hi David,
    I'm trying to implement indoor smoke with your fog system, but can't set proper setting for noise (without noise everything works) for small fog volume 20x20x20. Can you make this kind of example, please?
    Also, met the same problem as trx.
    I will be grateful for any help you can provide.
     
  23. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Yes, it will work. It can be seen from outside.
     
  24. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Well, simulating smoke was not my plan, but we should be able to to simulate something. Have you ever payed L4D2? There is a map with a big hotel kitchen in flames and full of smoke, when you get out of the elevator.
    Test these settings. Inside the rar you will find the scene and the gradient used.

    Just checked the issue trx reported. Never noticed it before :/ Ill take a look at it.
     

    Attached Files:

  25. qkymber

    qkymber

    Joined:
    Apr 23, 2013
    Posts:
    4
    Yes, i want to use your system in the same context as you describe L4D2 map.
    My project is firefighting game with indoor and outdoor areas with flames and smoke emitters. So player can walk inside and outside smoked areas.
    Your example looks very beautiful, but i met two problems with it.
    First: scene collision. Then i turn it on fog volume becomes weird with your example settings, without scene collision smoke draws over all geometry.
    Second: huge fps drop when i'm change fog scale to target 20x7x20.
    Also, i should be able to change visibility inside smoked area at runtime.
    Right now i'm using fog volume without noise (scene collision works well) and unity3d particle system with shape particle emitter, but it looks not so good like your clouds or smoke exmaple.
    Any ideas?
     

    Attached Files:

  26. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Yeah, I see. I used some expensive features such as noise shade or double layer. You have to balance visuals and performance. Noise size affects performance. If you tile it big, it will be much cheaper. Another option is to tweak the shader.
    Find this in the shader:
    Code (CSharp):
    1. //tweak quality here
    2. #define STEP_COUNT  50
    And try different values.
    Size: Having big volumes is not a problem if you don't make noise too small.
    Intersection (collision): you have to find the magic value. I know it's not easy to adjust. In the documentation you will find some recommendations for that.
    Check my settings and performance here.

    2015-12-25_18-35-35.jpg

    And here, after editing the shader:

    2015-12-25_18-38-14.jpg

    Modifications at runtime: most of the parameters are public, so you should be able to edit them at runtime.

    Good luck!
     
  27. qkymber

    qkymber

    Joined:
    Apr 23, 2013
    Posts:
    4
    Thank you for your attention to my questions. I will check it as soon as possible and write about results.
     
  28. qkymber

    qkymber

    Joined:
    Apr 23, 2013
    Posts:
    4
    Hi again.
    After few experiments, i'm figured out, what all problems appears when i move fogvolume object out of its original position (0,0,0). There is a short video with demonstration. Two identical fogvolume objects, first in (0,0,0) position, second in (50,0,0) position. I hope it will help.
     
  29. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Thanks for the info. Here is the fix:
    replace distance2Exterior = distance(_WorldSpaceCameraPos, rayStart);
    with this:
    distance2Exterior = distance(i.LocalEyePos, rayStart);
     
  30. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    1,154
    I have to say I remain very impressed by how much additional versatility you added to the system in version 2. I suspect it didn't get as much attention as it deserved.

    I'm particularly keen on the potential for use as a cloud system with other sky/day cycle assets that lack beefy volumetric clouds of their own.

    Do you happen to have any thoughts on the possibility to make the cloud mode of the system able to 'bend down into the horizon' or otherwise deals with issues of the system ending in too obvious and abrupt a way when camera is well below the clouds in a nice open environmental scene, not giving the impression of following the curvature of the planet etc?
     
  31. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Hi, thanks for your comment.
    That's a good idea. I have done some experiments and seems to be possible. But before doing that, I had to add a distance fading for noise (many requested it). I don't want to call it clouds, otherwise people will assume this is a cloud system, and that was not the original idea, hehe. So, yes, distance fade:

    [​IMG]

    This will fade noise from the volume center to a given distance following a spherical shape.

    2016-01-10_15-00-59.jpg
     
    elbows likes this.
  32. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    82
    Hi !

    I've been using your asset in a project for about a month now, everything worked like a charm until I tried to implement VR.
    The fog seems to ignore the camera depthmap.
    Any idea what I'm doing wrong ?
    I have joined screenshots of the same scene, without and with VR. FogVolumeVRBug.png
     
  33. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Hi,
    Did you put the VR camera in the camera slot in the Fog Volume script?
     
  34. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    82
    I did, but it is not called MainCamera, don't know if this is a problem.
     
  35. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    The name is not a problem. You should see this little info message:

    2016-01-12_21-53-33.jpg

    Does your camera say that?
     
  36. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    82
    It does...
    I am using Unity 5.3.1p2, and an Oculus DK2.
    As everything works fine without VR, my scene should be correctly set up for the most part.
     
  37. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    82
    Hi !
    Found the problem, I was using a really big farclip for my camera (about 10^9 which is no problem if you have a nearclip at 1)
    But for some reason, a farclip superior to 10^6 messes up everything in VR, even the lighting itself.
    Sorry for the unrelated post then ^^ !
     
    DavidMiranda likes this.
  38. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Crazyness of the day :)
     
  39. p92363

    p92363

    Joined:
    Oct 22, 2012
    Posts:
    2
    Hi David, I wrote to you an email asking for an issue. We bought your fog and when playing it a HTC One7, fog appears as a purple by deffect unity texture. What are we doing wrong?, please we are in a hurry. This is in a simple scene with a cube and skybox but when playing it with oculus mobile nothing appears, not even the purple texture....
     
  40. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    890
    David,

    Have you done much testing on Unity 5.3.0f4 ?
    I'm running OSX with that Unity version and anytime I try to change a setting on Fog Volume or open your demo scenes Unity crashes...

    Please advise
     
  41. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    890
    Also, when I load a fog volume into an existing demo scene like the viking village here: I get strange behavior where the volume is only visible from certain viewing angles Screen Shot 2016-02-01 at 2.17.01 PM.png Screen Shot 2016-02-01 at 2.17.07 PM.png Screen Shot 2016-02-01 at 2.17.13 PM.png Screen Shot 2016-02-01 at 2.17.19 PM.png
     
  42. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    I have not tested that version yet. What a nightmare to fix stuff over and over with every single version of the engine...
     
    JohnRossitter and hopeful like this.
  43. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    890
    As a fellow publisher, I agree completely :)
     
  44. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    112
    @David_MG I seem to have found a strange bug. I'm trying to turn 3D noise on and off at run time so I made a simple script that toggles the setting on my fog instance. While this works perfectly in the editor (running the script toggles between noise and no noise) it doesn't work in a build. I checked and the script is running and functioning correctly so it seems that there is something about fog volume that prevents noise being turned on and off at runtime in a build (but works fine in the editor). Any thoughts on what might cause this and any ways around it?
     
  45. alex_hajdu

    alex_hajdu

    Joined:
    Nov 10, 2013
    Posts:
    32
    5.3.2f1 - When I click enable noise in Editor unity freeze. The same happens when I try to load scenes coming withinn the package. ( Honestly I think there is something with unity editor beacause vuforia is crashing aswell )...
     
  46. alex_hajdu

    alex_hajdu

    Joined:
    Nov 10, 2013
    Posts:
    32
    5.3.2f1 - Also I've problems, I've clear scene with box and Fog Volume and it looks like this. What I'm supposed to do?

    Screen Shot 2016-02-06 at 21.34.20.png
     

    Attached Files:

  47. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Already replied Alex by email. Hope he brings us good news. Btw, hes on a Mac. All I have to test mac is a virtual machine (lots of pain)

    I had to code a custom Fog shader for him since I don't have an HTC.

    Have you tried to switch on and off other options such as gradients or inscattering? Have you tried to activate-deactivate shader keywords in other shaders? I think I never tried that, so I don't know if you can compile shaders at runtime.
     
  48. zarex7

    zarex7

    Joined:
    Jan 25, 2016
    Posts:
    2
    Fog Volume very great asset but... dont work on Android. In editor fog ok, but on android device black sky without fog
     
  49. _ben

    _ben

    Joined:
    Apr 21, 2013
    Posts:
    4
    Hi David, Since I updated Unity a month or two ago, i believe around 5.2, i've been unable to build my project to Mac and Fog Volume seems to be the problem. When building, the build dialog sticks at : Building Assets - resources.assets. There are instances of Unity Shader Compiler eating up all my CPU but the build never finishes.

    This is with a blank project, and nothing but the latest (as of today) version of Fog Volume and Unity Standard Assets, building to Mac Universal.

    Thanks!
     
  50. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    438
    Hi,
    Did you update the asset? Its because a problem with the compiler. If you decrease the number of samplers to something like 15-20, it will compile fine, although it will take some time.
    Find #define STEP_COUNT 50 in the shader and lower it to 15 or so.