Search Unity

Volumetric Clouds

Discussion in 'Assets and Asset Store' started by Eideren, Oct 20, 2014.

  1. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    It looks like you get the black halos if you try to use the Cloud/ShadowCaster shader on the ShadowCasterMat with either Standard cloud shader in Deferred. However, the custom editor you have isn't compatible with the ShaderForge version of the ShadowCaster shader so you get red errors, something must be breaking in a way to make it work(everything seems to look okay with the errors).

     
  2. Chaerephon

    Chaerephon

    Joined:
    Jan 3, 2013
    Posts:
    8
    Thanks! There's still a lot of work to do, the map is made from real world DEM data with some tweaks (its set in Ancient Greece and the rivers/shorelines have moved a bit since then).

    Will post some pics showing off your clouds when its progressed more.
     
  3. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Those errors comes from the "CopyPropertiesFromMaterial" function the script is using when "Reflect cloud settings to shadow caster" is enabled. It just means that he can't copy those variables to the shadow caster, it should only happen if you don't use the corresponding "shadow casting" shader with your basic cloud shader.
    I sent you another shadow caster, could you try it out ?
     
  4. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Hey Eideren, I'm really enjoying your cloud solution; it's very effective.

    I'm using your cloud system to generate very specific, individual clouds. I noticed that if I move the cloud object, the cloud bounds scroll across the tiled cloud texture. Is there any way to lock this so individual clouds can be moved about freely in the X and Z axes? If not, is it possible for you to expose the tiling offset parameters? With those, I can write a script that keeps the shader 'locked' onto a specific cloud within the tiled texture. That would be immensely helpful!

    Also, I noticed that the clouds are not affected by the scene ambient light, nor any point lights added to the scene. Directional light is the only light source that affects the clouds. Is this expected behavior? Is there any way I can enable Unity 5's physically based lighting to work on the clouds?

    Thanks again for an awesome asset.
     
    Last edited: May 30, 2015
  5. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Good news everyone, Dithered/Transparent shadow is coming in the next update !
    If you follow this link, you 'll see 3 different way it could look in the coming update, which one do you think would fit better ?

    Sadly, we can't do without the banding, I don't know if it comes to the fact that this method wont work with more dimensions in the Mask or if it is simply because they prefer keeping the dimensions lower for performance reasons ...

    The base transparency will be editable on the material either way.

    So if anyone is passing by and wants to know how to implement it, look into builtin_Shaders/CGIncludes/UnityStandardShadow.cginc
    and
    builtin_Shaders/DefaultResourcesExtra/Standard.shader

    Hi, thank you for your kind words !

    I actually didn't think that someone would use them like that, so yeah, as you can see the texture is mapped to the x/z plane in world space, after I am done with the shadow thingy, I'll add the option to map it in object space.

    The skybox/indirect light gain might indeed be usefull, adding support for other types of light might crush performances though, I'll look into it.
     
    led_bet likes this.
  6. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    It would be great if you could just drop a light object on the VCloud object to give it the light normal instead of filling it in manually. That was another thing I've been wanting to look into(it's been real busy for me lately) because it would let me hook it up to the Time of Day asset, which goes nicely with this one.

    As far as the new dithered/transparent shadows for clouds, I like both the sharp gradient and full gradient render. If it's possible though, I'd include all the options you showed pictures of, just so people looking for different styles have some choices to pick from.
     
  7. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    I am not sure that I understand your light normal, what do you mean by that ? A vector which shows where the light comes from ?

    Well, I kinda decided to ask since the number of multi_compile I am creating keeps pilling up and there's a certain limit that a project can have, now that I think about it, I could just do a bit of math and let a float handle that.




    P.S.: Other types of lights are now implemented and costs far less than what I thought.
     
    led_bet likes this.
  8. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Right now, you have this, you call it "Normal Direction" and it seems to be the normal(or inverse normal) that the light is coming from to shadow the clouds:



    If this were an object slot that you could drag a light object into instead, the cloud lighting would support the light object moving instead of having to write a script and wire it up to update every frame.
     
  9. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    That's actually multiplying the normals of the surface, you don't have to change it if you are using the normal maps included with the plugin, you might have to if you are using custom ones since some time maps have inversed channel.

    Directional lights work out of the box ...
     
  10. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Oh, hmm. Is there any way to make them lighter, like adjust the density, then? They're too dark in bright sunlight. They always look like dense storm clouds instead of light, fluffy ones, even with the sun in front of them. Tonemapping kind of exacerbates the problem(which is one reason why I thought the lighting was wrong).
     
  11. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    There should be a toggle box "Show Help" on the cloud material, it has a whole range of tips.
    The shading intensity is on the alpha channel of the shading color and the light color contribution is on the alpha channel of the base color.
    You might want to read the rest of them like depth color for instance since it might also be influencing the final result.
     
  12. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Here's what has already been done for the upcoming v1.4 :
    New stuff :
    Soft/dithered/transparent shadows.
    Option to map the texture in Object space or world space.
    Dynamic indirect lighting(Unity GI).
    Support for Point lights and spotlights added.​
    Changes :
    Reduced shader keyword from the old 8 to only 3.
    Fixed rendering of the disabled complex lighting.
    Reworded some bad variable names and descriptions.
    Changed normalization method to reduce the multi_compile number and add more customization.​


    I'll probably redo the set of textures included since I found a way to avoid the errors I had with this one(there's two very noticeable flat surface on both rough textures).
    I would like to reduce the package size as well so I might include the most used texture with the package and then put the rest on Google Drive or another host so that you guys dont have to download half a giga for stuff you wont use.

    So, what are the textures you use/like the most ?

    Also, before I upload the package off to unity, does anyone have any request ?
     
    led_bet likes this.
  13. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    I'm getting a shader error and broken/pink material...Thanks
    Unity 5.0.1f1
    latest version of volumetric clouds

    Shader error in 'Cloud/Standard': undeclared identifier 'cloudMorph' at line 168 (on d3d11)

    Compiling Vertex program with DIRECTIONAL SHADOWS_OFF LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF LIGHTING_ON NORMALIZED_ON
     
  14. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    That should be fixed, I sent you my version in PM just to be sure, could you test it out and report the results ?
     
  15. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    You are awesome! Looking forward to the Object Space addition.

    Quick question- Are you supposed to be able to see the clouds from above? When I fly a camera above the clouds, I see nothing. It's not that big a deal; my project doesn't need it, but it would be cool to have the clouds rendered on both sides.
     
  16. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    that did it! thanks :) looks great
     
  17. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Making them double sided in this case means that you have to create an additional render pass. In most case you can just put "Cull Off" in your shader pass to render both sides but then normals will only be correct for the front faces, which in this case breaks the rendering.
    Doing an additional pass will cost a lot more than sticking with front face rendering.

    But, if you still want that, you could just create non-curved clouds since they have their scale reversed once your camera goes above them (which makes them face towards the sky).
     
    led_bet likes this.
  18. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Oh, awesome. That explains why I thought I could see them from above at one point. I forgot to try the flat clouds. Thanks the heads up.
     
  19. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Version 1.4 finally live, here's the change log :
    Version 1.4 :
    New Features
    • Soft/dithered/transparent shadows.
    • Option to map the texture in Object space or world space.
    • Dynamic indirect lighting(Unity GI).
    • Support for Point lights and spotlights added.
    Changes :
    • Reduced shader keyword from the old 8 to only 3.
    • Fixed rendering of the disabled complex lighting.
    • Reworded some bad variable names and descriptions.
    • Changed normalization method to reduce the multi_compile number and add more customization.
     
  20. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Thanks for the update Eideren... Ugg just updated and broken again... Unity 5.02f1 OS X - running Deferred with Time of Day and Alloy... Tried deleting Volumetric clouds after getting this and bringing back in... Same weirdness...


    Complex lighting is turned on... When turning it off... Doesn't get funky

    Gary
     

    Attached Files:

  21. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    @garyhaus Could you try it in an empty project to see if there are any compatibility errors ? If you turn lighting off and turn on either DepthBlend or border fading, does it freak out ? Is shadow casting working ?
    Thanks a lot for that screenshot btw !
     
  22. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Any chance I could get 1.3 back? That was working perfectly in this project.
     
  23. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Well, I sent you a PM with it but I am pretty sure it wont work.
    If the error manifested before and then vanished with the same version and if I can't reproduce it on two different PC, it is most likely linked to something else, it might even be Mac specific.
     
  24. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Fresh Project Unity 5.02f1. Only the Volumetric Cloud 1.4 asset. First one is with Complex Lighting enabled. Second is without.

    Same forward or Deferred and using Linear color space.
     

    Attached Files:

  25. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Thanks for the old version BTW. Would like to get the issue completely fixed... Thanks for the asset and your time.
     
  26. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    BTW here is what the shadows look like from 1.4
     

    Attached Files:

  27. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    I sent you another one, could you try it out ?
     
  28. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    New Cloud shader fixed it in fresh project and my 'real' work in progress scene. However I have disabled the shadow caster as it still shows the weird artifacts as above(probably needs a shader adjustment?). Both in fresh project and my WIP scene.
     

    Attached Files:

  29. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    I was just trying to fix the clouds before the shadows, I sent you a bunch of new ones, could you try them out ?
    Thanks a lot for helping me out !
     
  30. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Last clouds shader broke it again. Shadow caster seems to be working now. Reverted to the previous cloud shader from a little while ago.

    Not sure if they are still supposed to be harsh edged...
     

    Attached Files:

  31. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Hey Eideren, really liking the now object-space feature for the clouds. I have one more suggestion to make it easier to use.

    Since tiling is locked in as a singular value for both X and Z coordinates, I'm having a hard time centering on one specific instance of the cloud shape. I'm having to fiddle with the tiling number and the Boarder Fading option to get the cloud shape almost centered in the middle of the slice boundry.

    I've looked into the shader and it appears to be a fairly straight-forward fix, but I know zero about HLSL and every API for HLSL is horribly formatted (or maybe I just need more sleep).

    Anyway, would you mind pointing me in the right direction on how to change the scaling to be independent per axis? Thanks!
     
  32. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    But which one broke ? I gave you three different cloud shader, did they all break ?

    Well, they are sharp at the moment to see if the error was caused by the dithering.
    Could you put a standard transparent material with an albedo-alpha inferior to 1 onto a basic mesh and compare the shadows of the semi-transparent to an opaque one ? If both have the same intensity then the error comes from the fact that unity doesn't support dithering on macs.

    Well, I did it for you since it's a bit more complicated with the custom inspector and the UV animation, check your MP.
    Yep, unity's mono is by far the best for shader programming but even it isn't that great compared to other types of programming.
     
    led_bet likes this.
  33. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    You are the greatest. Thanks so much. I wasn't trying to undervalue how complicated that edit would be (I didn't even think about the custom inspector part), and I appreciate your time adding that feature.
     
  34. Jonn Doo

    Jonn Doo

    Joined:
    Dec 2, 2012
    Posts:
    7
    Hello Eideren!
    Your clouds are great ... but I have a problem. The shader has problems with transparent objects / shader. Look at the screenshot. the mountain using a transparent shader (standard fade). The cloud now casts ugly faces by edge. Can you do something there?

    thanks

    clouds.jpg
     
  35. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Open cloud shader in the scripts folder and change the line 43~ from "ZWrite On" to "ZWrite Off" or the other way around, it should fix that issue.
     
  36. Jonn Doo

    Jonn Doo

    Joined:
    Dec 2, 2012
    Posts:
    7
    Now the clouds are in the background :(

    clouds2.jpg
     
  37. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Well, yeah, this is a standard sorting error for semi-transparent objects, you can't really fix it without cheating.

    If your camera has a fixed point of view we could change the draw order to always have the clouds rendered last (over your mountains) or you could just make your mountains opaque or cutout, do you really need a semi-transparent mountain ?
     
  38. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there Eideren,

    Error on compiling:

    Shader error in 'Cloud/ShadowCaster': invalid input semantic 'POSITION': Legal indices are in [1,15] invalid ps_3_0 input semantic 'POSITION' at line 61 (on d3d9)

    Compiling Fragment program with SHADOWS_DEPTH

    (using unity 5.1.0f3)
     
  39. Jonn Doo

    Jonn Doo

    Joined:
    Dec 2, 2012
    Posts:
    7
    Ok thanks Eideren. Going to try a few other things.
     
  40. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Hi !
    Sent you a fix in mp, tell me if that worked.
     
  41. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Thanks for the fast response,

    I tested the 2 shaders, now the compilation its working, but the compiled game shows the cloud shader as error (but shadow caster is working):
    upload_2015-6-21_14-28-19.png

    In editor, clouds are working, but shadow caster only works in Play mode:
    upload_2015-6-21_14-30-51.png
     
  42. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Okay, that's strange.
    Do a build with "Development build" and "Script Debugging" toggled on, launch it and after the loading close it down.
    Check in the Data folder of your build the "output_log.txt" and paste the last couple of lines here, that should give us a hint about that error.
     
  43. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Here it is:
    Code (CSharp):
    1. WARNING: Shader Unsupported: 'Cloud/Standard' - All passes removed
    2. WARNING: Shader Unsupported: 'Cloud/Standard' - Setting to default shader.
    3. Setting up 3 worker threads for Enlighten.
    4.   Thread -> id: db4 -> priority: 1
    5.   Thread -> id: 858 -> priority: 1
    6.   Thread -> id: 734 -> priority: 1
    Im building the project with deferred, dx11, Linear color space. Platform Windows, 64bit.
     
  44. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Well, that ain't really helpful, I just did a build with the same settings and everything works.
    Do you have an on-board and a standard graphics card in your PC ? The on-board might be trying to run your build and the standard is running the editor ? The editor is running dx11 and doesn't show error/pink right ?
     
  45. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    The editor is running with DX11 and its working fine. Im using a nvidia GTX 580, there is no on-board card.
    Maybe is something (like conflict with other shaders) related with my project. I will try to do a Test project only with your cloud shader and test if it works correctly (with the same quality settings ).
     
  46. Neolightl

    Neolightl

    Joined:
    Nov 26, 2014
    Posts:
    36
    Hey Eideren, I'm getting a NullReferenceException: Obejct reference not set to an instance of an object SlicedVOlume.integrityCheck () (at assets/volumetricCLouds/Scripts/SlicedVolume.cs:132)

    The clouds dont generate
     
  47. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Sorry about that, an error easily avoidable that I didn't notice.
    I sent you a download link in PMs, just overwrite it with that file.

    I'm uploading the fix to Unity right now but it'll take a while for it to be online.
    Thanks !
     
  48. MitchL

    MitchL

    Joined:
    Aug 22, 2013
    Posts:
    5
    Hey there Eideren, I'm running into the same problem as Project Mysh - any time I build my game the clouds end up bright pink. After some fiddling about, it seems to have something to do with the following two errors:

    These errors only seemed to appear when I imported other packages. That said, there was some weird business with them.

    When I import your package into an empty project, all works well. Upon importing certain other packages (eg: Horiz0n), the clouds would turn pink in the editor with those two errors showing up. When building the game, the clouds would look fine though. With other packages however (eg: UFPS), the pink clouds persist into builds. I have no clue why, or what could be happening. I'm still fiddling a bit to see if I can figure anything else out.

    Anyways, hopefully that helps with your debugging, this is definitely a frustrating bug for me. ;)

    Also, I'm seeing the same error as Neolightl, any chance I could get you to send that fix my way as well?

    Thanks! :)
     
  49. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    Ffs, this error was so frustrating ...
    Both of those seems to come from the compiler f*cking around, in my case it happens randomly when I compile the shadow caster or when a build is created.
    For the "variable 'o'" error, right click on the shader file and reimport.
    The other one, rebuild a second/third time.

    Could you try those workaround and report back ? I'll send you the current shader and the fixed script in PM since i can't ship them in this state ...
     
  50. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Hey Eideren,

    I see that other folks have experienced this before, and I tried rebuilding to resolve the problem as you suggested, but I'm getting pink clouds in my builds as well.

    When I execute a build, I get the following shader compilation error:

    Shader error in 'Cloud/ShadowCaster': invalid input semantic 'POSITION': Legal indices are in [1,15] invalid ps_3_0 input semantic 'POSITION' at line 61 (on d3d9)

    Compiling Fragment program with SHADOWS_DEPTH


    Build: BuildAndPlay.png

    In Editor: InEditor.png