Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Fog Volume 3

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

  1. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Last edited: Jul 15, 2023
    nxrighthere, Lex4art, Alverik and 4 others like this.
  2. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    Hi I just purchased this as I assumed it worked on mobile as you mentioned in the description it works for ios. It appears to work for me on pc but when I change to any mobile platform ie android or ios the fog disappears. Am I doing anything wrong or is there a bug ? Also as a suggestion for extra features is there any reason you couldn't make any mesh shape volumetric not just cubes ?
     
    DigitalNerds80 likes this.
  3. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    As you can see here, its working on an iphone

    $61990111-b489-4f83-b650-cecc75882deb_scaled.jpg

    It may disappear in editor viewport, it also happens on PC sometimes. I still don't know why. But its always shown in game.

    About shapes, as described in the documentation, it only models box shapes, since the fog is not based on any geometry, but on an algorithm.

    It's time now for debug and improvement, so any comments are welcome. Another update with some more options is waiting for approval.
     
  4. Antigono

    Antigono

    Joined:
    Oct 20, 2013
    Posts:
    63
    Hi, I am interested.
    It is heavy in terms of performance?
    How would be the best way to implement over a large terrain area? I guess doing that follow the player and only having a small portion of fog around him.

    Sorry for my english, thanks
     
  5. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    It is a transparent shader, so it adds overdraw. Nothing different than any other effect such as fake light shafts, particles...
    As reference, I show you two comparison images.

    $30-01-2014 21-26-59.jpg $30-01-2014 21-23-57.jpg
     
  6. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    Hi I found out what the problem was. For some reason when switching from desktop to mobile platform on PC it changes the near clip plane for the camera to a very small value. I got this working on Android by simply increasing this value. You might want to look into this or perhaps at least ensure that the near clip plane camera in your example isn't too small so will show up on most mobile devices as default.
     
  7. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Humm, dunno. I have tested switching from one platform to another and works fine all the time.
     
  8. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    I have made my first android build ever, and yes, it works almost fine. I'll keep testing.

    $30-01-2014 23-22-28.jpg $30-01-2014 23-22-04.jpg
     
  9. Antigono

    Antigono

    Joined:
    Oct 20, 2013
    Posts:
    63
    I purchased the asset. So far everything works fine, and attaching the fog to player, it gives the effect of fog stretching away
    It would be very nice and usseful if the fog gradually begins or ends, and not ending in a wall of a rectangle.
    Is this possible?

    thanks!
     
  10. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Great asset, works well in editor/play. I'm getting a errors when building my win exe though... any ideas? thanks


    Assets/FogVolume/FogVolume.cs(47,17): error CS0103: The name `FogVolumeCreator' does not exist in the current context

    sometimes this one...

    Maximum number (64) of shader keywords exceeded, keyword FOG_VOLUME_INSCATTERING_OFF will be ignored
    UnityEngine.Shader:EnableKeyword(String)
    FogVolume:ToggleKeyword(Boolean, String, String) (at Assets/FogVolume/FogVolume.cs:78)
    FogVolume:Update() (at Assets/FogVolume/FogVolume.cs:46)
     
    Last edited: Jan 31, 2014
  11. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Yes, I noticed that error last night when I tried to build for android. And update is waiting for approval. If you don't want to wait, this is the correction:

    #if UNITY_EDITOR
    FogVolumeCreator.Wireframe (VolumeObj, HideWireframe);
    #endif

    About the other error. Sounds like unity has a keyword limit. I didn't know that. Could you ask support about that?
     
  12. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    I think we should use things according to its original purpose. This is an existing method and it works as expected. If you want to compare, UDK has this feature. The idea is to place it in the world, without moving it. Also, its a box/rectangle and it has an ending, what you call wall. That's how it works.

    $AutomaticConstDensityFogVolume.jpg
     
  13. TRIAX GAME STUDIOS

    TRIAX GAME STUDIOS

    Joined:
    Nov 27, 2013
    Posts:
    49
    ...
    Hi David !

    Im very glad to See "Finaly" some more works yours Published.
    Been Following you since Your very first Udk Works days ...

    ---

    Thank you also to make this Asset Affordable.

    ---

    I think this project yours is amazing / as we still don't have true volumetric Light scattering fog methods in unity ...

    ---

    Still i miss some very important features in this asset that are basically a Most important "Buy now" Game Changer .
    That is :

    1) Having Projected Textures Controlling the fog Density
    1.1) This could be done in 2 Ways
    1.1.1) Low Resources Method / opengl dx9 :
    1.1.1.1) Planar projected / Project in Either X,y,z a Texture that controls the density
    1.1.1.2) Triplanar Projected / Project in Both Xyz Planes at same time .
    1.1.2) High Resource Method / Dx11 :
    1.1.2.1) True Volume 3D textures That Control the Fog Volume .
    2) As well Allow animation of Projection / or Volume Textures
    3) The volumetric or projected Densities should also inherit colors from textures.

    This is quite like a Very Most important features Set Out of this project.
    Do you think you can make it for the next Major Revision on this ?

    You can Also Double or even make a new Asset version Whenever you are able to do that
    And Sell a New product like 5x Times more expensive : Like at 50$
    Right After you are able to implement All those "most needed" features i mention above.
    As its a Major Game-changer Feature Set ...

    ---

    ReCalling And Supporting for What User @Antigono is asking :

    - Having For Volumes to Work not just in cubes but also in Spheres / allowing Volume Fallof Booleans "as udk" but not just also on custom geometry / As well Having Planar or even triplanar Falloffs That we can Overlay and adjust for the fog effect not ending in a Rectangle as user mentions is also something very needed ...

    ---

    I know this things got Alot of time and involvement needed, and maybe you just want to release your oldest research Because many people Asked you and thats it, No more improvements ...

    But game Development is as much Demanding as you know more than ever is this days ...
    .. And you can actually win more money if you Top up / On those More Professional Needed Features.
    ----

    IM Especially looking forward the possible evolution in all those in this Unique like no other unity extension.

    ---

    As well we are all looking forward to have more of your Development Like The Skin Shaders / And Full Atmospheric Environmental Lightning Scattering plugins You got in the oven There : http://dmg3d.blogspot.pt/2013/11/atmospheric-rendering-for-dynamic-light.html

    -----

    Thanks for being here and making the Difference in Professional Quality Achievements out of unity, therefore pushing unity to another bounds. Your Research is always extremely welcome.

    ---

    With my Very Best Regards

    Trish Dian.
    TRIAX GAME STUDIOS / Technical Production Admin

     
    Last edited: Jan 31, 2014
  14. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Wow! Awesome feedback, thanks!

    Custom shapes:
    That requires a completely different method. Im using a ray/cube intersection algorithm for this. And that's what it does, it models a cube.

    Falloffs/noise:
    Well, I have never worked with 3D textures, so I'll have to learn about that. Really interesting indeed.

    Other tech:
    I can't release my Skin or atmospheric system, since it was done for 'The Forest' game and I got paid for that. We also used Sunshine volumetric shadows, so...
    But well, I'll listen the people's request to bring them what they need. Thanks to Robert Briscoe and others, I decided to do this plugin :)
    Im not even a programmer, but Im doing my best. Indeed, Im working as FX artist for the game Rime, so... hehe, nothing to do with unity or graphics programming :p

    Thank you!
     
  15. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    The latest version fixed it, thanks!
     
  16. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    awesome
     
  17. cl-apps

    cl-apps

    Joined:
    Mar 16, 2013
    Posts:
    128
    Really nice fog! I've been playing with this for a little while now and have begun testing on iPhone.

    I have noticed a drop of about 10FPS on my iPhone 5. So from about 30FPS to 20FPS on a dense jungle scene. I'm assuming this is solely down to overdraw.

    I was wondering if there is the possibility of any further shader optimisations as I really like the effect.
     
  18. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Hi,
    great Asset!
    But I had some problems with your shader when scaling the volume to very high dimensions. On the screenshot you can see the artifacts that are visible . The volume scale is 9000x9000x9000. Are you aware of this problem with high scales? Is there are a solution? (I played with a terrain from Worldcomposer that has very high dimensions and want to give the scene some fog atmosphere. With your shader it looks really cool, but I had problems with these artefacts. When I fly over my terrain I get weired flickering from the fog shader)
    $fogVolume.jpg
     
  19. cl-apps

    cl-apps

    Joined:
    Mar 16, 2013
    Posts:
    128
    I had those issues too. Switch your Camera Render Path to Deferred Rendering. Should do the trick

    Also make sure your Camera far clip is set to something big so the fog renders properly
     
  20. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Thanks for the info! Switching to Deferred Rendering didn't work but I realized that when I increase the Near Clipping Plane of my Camera the problem is almost gone.
     
  21. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    I'm looking for an alternative to the Unity Projector for creating dark shadow volumes, if that makes sense. In your examples you use quite light colors for the fog, so my first question is can the fog be changed to a very dark color to create shadow like dark areas. Please see below:

    $Shadow2.png

    When using a Unity Projector in the scene it doubles the drawcalls since projectors draw every mesh they touch twice. Does this asset also increase drawcalls in this way?
     
  22. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Yeah, the effect reads from _CameraDepthTexture, so Clipping planes have an important role here.
     
  23. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    The fog can be set to something dark, yes. I doesn't increase drawcalls, just it's own.
    $13-02-2014 20-27-06.jpg
     
  24. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Perfect! Just what I need
     
  25. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Just bought this and I'm getting RenderTexture warnings and nothing is showing in both the scene and game view :(
    I thought this was for Unity Free as well?
     
  26. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Yeah, I noticed it's not working with the free version. I updated the information 10 days ago, but something went wrong and its not shown yet. Im sorry for that.
     
  27. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    I sent you a PM
     
  28. maxfog

    maxfog

    Joined:
    Mar 19, 2013
    Posts:
    2
    Hi David,

    I am really liking the idea of your shader as it is exactly what I am looking for. However I saw in an earlier post about the volume not showing in the editor window, have you figured out a way around this issue yet? Any information would be amazing!

    Thanks
    Max
     
  29. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Well, that's something related with unity internal stuff when running in Forward mode. I'll keep working on the effect, I want to add some more options. Hopefully I find what's going on with that at some point.

    Thanks.
     
  30. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Does it only work on a cube or can I use some other shape like a sphere?

    How expensive is it on mobile? I see you tried, what's the performance drop?
     
  31. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Hi. It only works on a cube. I have not tested deeply how expensive it is on mobile. The shader itself is quite complex, and since it is a transparent shader, it wont be cheap.
     
  32. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Hi, David,

    Amazing Works!

    Because of I'd like to use in my mobile project, you plan to optimize for mobile devices?

    Thanks
     
  33. ironbelly

    ironbelly

    Joined:
    Dec 26, 2011
    Posts:
    597
    Hey David, we have run into a large issue with this shader and our current project. What we are trying to do here is to put fire or light sources in the fog and have it produce a nice halo glow as you would see in real life.. Unfortunately this seems impossible with the fog shader it's current state :( In the words of our environmental artsts 'This fog just eats them up and are barely noticeable'.

    Here is the effect we are trying to create( http://i.kinja-img.com/gawker-media/image/upload/t_ku-xlarge/19d6ud8t8pj4rjpg.jpg ):
    $19d6ud8t8pj4rjpg.jpg

    Do you have any suggestions?


    Do you have plans to allow us to use this on a sphere?
     
  34. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Hi. Im not sure if I fully understand what do you need. Are you trying to emulate light glow with a translucent material? In that case, you will have the same problem with every translcuent shader. I can't do anything with that, since that's a universal problem. Something about I can't do anything.

    There is another method that maybe will help you with that, but we are talking then about a new asset. Check this
     
  35. ironbelly

    ironbelly

    Joined:
    Dec 26, 2011
    Posts:
    597
    that same technique will work in Unity just like it does in UDK?
     
  36. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Sure. Unity is capable of EVERYTHING :)
     
  37. ironbelly

    ironbelly

    Joined:
    Dec 26, 2011
    Posts:
    597
    What about allowing multiple lightsources for the inscattering?
     
  38. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    In theory, infinite :) As much as your hardware could compute.
     
  39. ironbelly

    ironbelly

    Joined:
    Dec 26, 2011
    Posts:
    597
    I was under the impression that we could only have 1 directional lightsource for inscattering with your plugin(http://i.imgur.com/5rfZ4bq.jpg ) . How would we go about adding additional pointlight sources?
     
  40. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    I think we should talk about this outside the forum ;).
     
  41. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Hey david, i've seen your work on your blog, including character shading and work with udk and it's extremely impressive (If you've seen shaderforge in the assets section, its very close to the udk material editor now and your ocean and other work has inspired me to recreate a lot of udk stuff now, you might appreciate it for shader work) and your shift to Unity is interesting, looking forward to new things by you - in the case of this asset I might try recreate such an effect myself with raymarching using material I own as guidance, but if I give in, this could be great.
     
  42. robert-nally

    robert-nally

    Joined:
    Mar 5, 2014
    Posts:
    76
    Hi David,

    I really like your shader as it produces a great effect and your other work is really remarkable as well.

    I'm running into a bit of an issue with the fog volume and I was wondering if you could help me out with it. Basically, I am able to see the edges of the volume even though they are far away. I would just scale the volume up to where you can't see the edges, but there is playable space up top as well and I didn't want that to have as thick of a fog effect. I'm attaching a screenshot of the issue below.

    $fog_volume_box_problem.jpg

    I'm not sure if it is because I made the fog volume really long and large or if it might have something to do with the Draw Order, which I admit I don't fully understand at the moment, but I did play with it and change it to different numbers for my different volumes (1-3). I wanted to reach out to you to see if this might be an easy fix for something I may be misunderstanding. If not, I will try and work around it.

    Any help is greatly appreciated.

    Thanks,
    Rob
     
  43. robert-nally

    robert-nally

    Joined:
    Mar 5, 2014
    Posts:
    76
    Also wanted to mention, for those having difficulty not being able to see the fog volume in the editor or scene in Unity without running the game I found a workaround.

    If you switch your viewport view to RENDER PATHS from say TEXTURED you should be able to at least see the volume and where it is in 3D space. It doesn't show or give you the full effect, but it can at least help you to place the volume where you want it without having to keep running the game to see where it is at.

    Hope this helps,
    Rob
     
  44. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    humm... I don't think this is the correct way to use the volume, Im sorry. It's more suited for a more "global" situation.
     
  45. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    No plan to optimize for mobile?

    Thanks
     
  46. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    I have upgrading plans (more features), but optimization doesn't sound possible right now. Maybe at the cost of visual quality, who knows. I will review it as soon as Im done with some other stuff.
     
  47. ironbelly

    ironbelly

    Joined:
    Dec 26, 2011
    Posts:
    597
    We're actually running this on an ipad Mini with fairly decent results. Even without specific mobile optimizations David's done a great job at keeping this lean
     
  48. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Downsampling setup with some preset enum would be a good point to start :)
     
  49. Unityaware

    Unityaware

    Joined:
    Feb 14, 2014
    Posts:
    101
    Hi David,
    I just install your Fog plugin, however I have a problem. The purpose I am using it for is to create an underwater atmosphere, which looked ideal when I saw it. So I stretched your volume cube 2000 x 2000 to cover the whole area and just under the water plane and this is what I get. There are some blank slots which keep popping up and are dragged around in the player, as well as after images from the surface. How would I overcome that any ideas? Please have a look at the screen grabs:

    http://3d-art.co.uk/www.3d-art.co.uk/Fogvolume.html
     
    Last edited: Mar 27, 2014
  50. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    I have made a 6k volume and still works fine

    https://dl.dropboxusercontent.com/u/16565603/Unityforums/28-03-2014%209-16-25.jpg