Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASE] Calm Water

Discussion in 'Assets and Asset Store' started by Phantom_X, Jan 22, 2016.

  1. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    87
    Hi,
    So using Calm water, and Unity terrain tree, when they are using the Billboard shader, the calm water appears on top of them. People have said using Tags { "Queue"="Transparent-200" can make it work, however, it still does it on mine. Any suggestions?

    Thanks alot.
     
  2. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    Yeah there is a bug in unity at the moment and setting render queue in the shader doesn't work. You will need to use a script that changes the render queue of the material with Material.renderQueue. Alternatively you can change the render queue on the material by editing it in debug mode.
     
  3. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    87
    ok i think i can do that.. can you give an example of the actual line of code with Material.renderQueue please?
     
  4. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    let's say you want to change the render queue of the water it would be something like that.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SetRenderQueue : MonoBehaviour {
    5.  
    6.     public int Queue = 2900;
    7.     void Start ()
    8.     {
    9.         GetComponent<MeshRenderer> ().sharedMaterial.renderQueue = Queue;
    10.     }
    11.  
    12. }
    13.  
    transparent starts at 3000 so you'll want something below that.
     
    Last edited: May 16, 2016
    philc_uk likes this.
  5. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    87
    Thats great thanks alot Yan.
    Seems like this is a useful fix which could go in the demo of next exciting update of Calm Water ;-)
     
  6. Aerryx

    Aerryx

    Joined:
    Sep 24, 2013
    Posts:
    3
    Would anyone know why I'm having an issue creating the same wave effects as in the demo and images above? The scale of the object is 1, 1, 1 and I created a Plane with the dimensions of 1000x1000 to surround my 500x500 terrain, which i think is the cause but I've been unable to figure out how to account for it in the settings.

    upload_2016-5-19_17-24-9.png
    upload_2016-5-19_17-26-42.png
     
  7. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Here's the settings I have for a 1000x1000 plane.



    Now if that's the kind of waves you were talking about you will need to use the DX11 version of the shader. Gerstner wave needs more vertex to get the best result.

    If you use the non DX11 version of the shader you won't be able to achieve this result with such a large plane. Unity cannot handle mesh with more than 65k vertex and because of that it's not possible to create enough subdivision in a plane this big to get this effect. That's were tessellation comes in and save the day. You could also have multiple smaller meshes with more subdivisions tiled together but it would probably be hard to hide the seams between meshes.
     
  8. Aerryx

    Aerryx

    Joined:
    Sep 24, 2013
    Posts:
    3
    Thanks a ton Yan! This solved my issue, I forgot to use the DX11 version.
     
  9. Aerryx

    Aerryx

    Joined:
    Sep 24, 2013
    Posts:
    3
    I noticed a weird issue, and I'm not sure if it has anything to do with my settings or not, but the edge of the depth color isn't reaching all the way to the terrain so if you catch it at the right angle you can see deep down into the water.

    upload_2016-5-19_18-44-26.png
     
  10. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Do you see this happening in the demo scene as well? If you don't there is probably something wrong with your setup, but if you do I will need more details on how to reproduce this like unity version, target platform, rendering path etc... Even better if you can send me a package with the problem I will have a look at it.

    Thanks
     
  11. Leoo

    Leoo

    Joined:
    May 13, 2013
    Posts:
    96
    Hey @YanVerde ,

    Am taking a serious look into your asset before getting it into my project,
    Am using the TimeOfDay asset, to handle my sky and Fog scattering, do you have any user that has successfully integrated CalmWater into a TOD setup?

    Thanks!
     
  12. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    Not that I know of, but I'm pretty sure that TOD just controls stuff like light direction and intensity and maybe skybox. In that case calm water would work, I only have one small thing to fix to make it perfect and it's the depth fog feature that doesn't react great to dark lighting yet, but I plan to fix this pretty soon (like maybe today or over the weekend).

    Thanks!
     
    Leoo likes this.
  13. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,138
    Any chance this would work on 4.7?
     
  14. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    At the moment it won't work below 5.2 because I use some unity's macro that where introduced in that version, and since support for unity 4 is dropped I don't think I will support it either.
     
  15. Cross22

    Cross22

    Joined:
    Sep 26, 2014
    Posts:
    21
    Nice looking shader!
    Before purchasing it, can you confirm that it works with single-pass VR in 5.4?

    (My refraction shader needed some fixing for this because the rendertexture size is different in VR mode and because the rendering eyeIndex needs to be queried).
     
  16. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    I will try that later on today and get back to you on this.
     
  17. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    After testing this I can say that it's not working with single pass mode. The problem is caused by a bug in unity and may be fixed in an upcoming release of 5.4. It's still in beta after all. I could make a work around but I prefer to let unity fix this.
     
  18. DigiScot

    DigiScot

    Joined:
    Aug 23, 2013
    Posts:
    27
    Hi, just purchased this and I'm really liking it, much nicer than the old water features I was using.

    Is it at all possible to find out the height of the wave at any particular point? doesn't need to be super accurate, writing some simple buoyancy physics so would go far to helping it look more realistic.
     
  19. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    If you want to do something like that you will need to have your buoyancy script to also control the displacement of the mesh rather than doing it in the shader.
     
  20. WagDan

    WagDan

    Joined:
    Nov 7, 2014
    Posts:
    36
    Hi,

    We are looking for a water asset, with SSR that allow water in different areas at different heights in the same scene. Does your asset allow multiple custom meshes to be used as the water base?

    We have a river with some surrounding lakes that are higher up. Our existing asset just puts an infinite plane through the whole scene at one level.

    If the answer is yes, 100% will buy!
     
  21. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    The asset allows for multiple custom meshes no problem, but just so you know it's not SSR. The realtime reflection script is almost the same with unity's water. It will re-render the scene from a different angle to create the reflection. So this is probably not suitable if you are going to have multiple water meshes performance-wise. You could always use Cubemap reflection mode which is very cheap but won't be real reflection.

    Once unity will release it's final version of Cinematic Image Effects I will be sure to modify the reflection script to add SSR support though.

    Thanks!
     
  22. WagDan

    WagDan

    Joined:
    Nov 7, 2014
    Posts:
    36
    Hi @YanVerde any idea if/when the SSR will be implemented?
     
  23. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    I need to write the deferred pass for that. I'm looking into it, but I don't know how long it's going to take.
     
  24. Alessandro-Miralles

    Alessandro-Miralles

    Joined:
    Jul 15, 2015
    Posts:
    2
    Hello,
    Would there be a reason why my solution builds as an exe with no issues, works on my machine, but the moment I take the exe to another machine with better specs, the calm water plugin does not render?

    Am I missing anything in the build process?
    Thanks in advanced!
    Al
     
  25. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    thanks for contacting me, can you give me the specs of both machines, what version of unity are you using and what render path are you targeting?

    Thanks!
     
  26. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Ok for future reference, the problem was that the user was targeting Forward rendering Path and did not put the CameraDepthTexture script on the Camera. In Forward rendering path you need to have that script on the camera otherwise you don't have a depth texture and the water won't display.

    I thought I had mentioned it in the documentation, but it looks like I don't. I will update the documentation with that information.
     
  27. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,663
    You can now create rivers with Calm Water and Landscape Builder. Thanks Yan, for helping to get this working.

    In LB, you can create a Map Path in the scene, to define the river bed topography, the custom river surface mesh, and restrict placement of trees, grass, textures etc.

    LandscapeBuilder_CalmWaterRiver1.png


    What you'll need:

    Calm Water 1.5.9 or newer
    Landscape Builder 1.3.6 Beta 2b or newer

    As well as configuring LB Lighting (for animated clouds and Weather cycle), I've added some 3rd party assets to this scene:

    HQ Photographic Texture Grasses
    3DForge Exterior Kit (House)
    Nature Package (Rocks)

    CW/LB Integration also lets you add oceans, lakes and ponds.
     
  28. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    Hello Yan,

    I need to switch On/Off the " _DEPTHFOG_ON" because I need to have it off when the player is above the surface and on when the player is under. How can I do that? I tried through the "Material.SetFloat( "EnableDepthFog", 1.0f); and "Material.SetFloat( "EnableDepthFog", 0.0f); but it doesn't update in the game.

    Please help me to achieve this.

    Regards,
    Carlos
     
  29. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    Right now it's not possible to change it in game because I use shader feature instead of multi compile, but it's easy to change.

    Open the shader file you are using and change lines
    Code (CSharp):
    1. #pragma shader_feature _  _DEPTHFOG_ON
    To this

    Code (CSharp):
    1. #pragma multi_compile _  _DEPTHFOG_ON
    You will have multiple lines like that to chage, be sure to change them all.

    Then to toggle it on and off just use
    Code (CSharp):
    1. Shader.enableKeyword ("_DEPTHFOG_ON") ;
    2.  
    3. //and
    4.  
    5. Shader.disableKeyword ("_DEPTHFOG_ON") ;
    6.  
    7.  
    8.  
     
  30. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    Hello Yan,

    I downloaded your latest version of the water, and I see not distortion on the refraction in the water. Is there something I am missing? Could you help me to sort this problem?

    Regards,
    Carlos
     
  31. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hey,
    There seems to be a problem in Unity 5.5, I will look into it ASAP.

    Thanks
     
  32. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282

    Ok, Here is the fix, in the file CalmWater_Helper.cginc, replace the function OffsetUV() with this one:

    Code (CSharp):
    1. inline float4 OffsetUV(float4 uv, float2 offset){  
    2.     #ifdef UNITY_Z_0_FAR_FROM_CLIPSPACE
    3.         uv.xy = offset * UNITY_Z_0_FAR_FROM_CLIPSPACE(uv.z) + uv.xy;
    4.     #else
    5.         uv.xy = offset * uv.z + uv.xy;
    6.     #endif
    7.  
    8.     return uv;
    9. }
    10.  
     
    Last edited: Mar 30, 2017
  33. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    Yan,

    This fixed the refraction but now the reflection is not distorted!?

    Regards,
    Carlos
     
  34. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Yeah right,
    For the reflection part, make this change in CalmWater.cginc:

    Code (CSharp):
    1. // Change:
    2. fixed3 rtReflections = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(DepthUV)) * _Reflection;
    3.  
    4. // TO:
    5. fixed3 rtReflections = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(GrabUV)) * _Reflection;

    I will push update version 1.6.0 to address these issues.
    Thanks!
     
    Last edited: Mar 30, 2017
  35. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    Yan,

    Thank you so much. Now everything is fixed. You are great!

    Regards,
    Carlos
     
  36. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    Hello Yan,

    I just realized that the fix you gave me for the reflections problem:

    fixed3 rtReflections = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(GrabUV)) * _Reflection;

    Now is showing the reflections without inverting the image! What is it missing? This problem disappears if I add the Unity Cinematic/Bloom effect to the main camera(Weird isn't it?) I just can't use that effect in the camera because it is too expensive.

    Also, Is there a way to make the reflections with the fog on it? I see that when I am far out in the water looking toward the shore, the environment above is cover with the fog but the reflection is not so it looks very off.

    I am using forward render, linear color space, Unity 5.5.2p2.

    Regards,
    Carlos
     
    Last edited: Apr 2, 2017
  37. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Right, I did not have this problem in deferred, did not test it in forward.
    Ok here is what you are going to do.

    first, add this function to CalmWater_Helper.cginc
    Code (CSharp):
    1. inline float4 OffsetDepth(float4 uv, float2 offset){  
    2.     uv.xy = offset * uv.z + uv.xy;
    3.     return uv;
    4. }
    then in CalmWater.cginc
    make this change:
    Code (CSharp):
    1. float4 DepthUV     = OffsetUV(i.DepthUV,offset);
    2. // Change to:  
    3. float4 DepthUV     = OffsetDepth(i.DepthUV,offset);
    and leave
    fixed3 rtReflections = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(GrabUV)) * _Reflection;
    as it first was
    fixed3 rtReflections = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(DepthUV)) * _Reflection;

    as for the fog problem, what kind of fog are you using exactly? I have no problem with linear fog on my side.



    Regards
     
    Last edited: Apr 2, 2017
  38. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    Hello Yan,

    Thanks for the fix, it worked like a charm. About the fog, I am using Forward render, Linear color space, Realtime reflection, and Exponential Squared fog in my project.

    I also just did a test with the linear fog and still have the problem where the fog doesn't appear in the reflection.

    I can send you a screen grab if you let me send you a pm.

    Regards,
    Carlos
     
    Last edited: Apr 2, 2017
  39. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Sure,
    Contact me in PM so we can discuss this more in detail
     
  40. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    ProblemWithFogWithLinearFogAsWell.jpg I just tried with the linear fog, and I have the same problem. Here you can see it. I realized that I don't need to pm you to upload pictures. Please help me with this.

    Regards,
    Carlos
     
  41. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    ho ok now I understand, you mean in the reflection texture it self, not on the water.
    Unfortunately this is not really something that is possible to fix within the asset.
    Basically the way unity does his fog doesn't work with the oblique projection matrix needed to create the reflections. So when it renders the reflection the fog computation is wrong and will not show up the the renderTexture.

    I can think of a few options you could use to hack this.

    1 - Use an image effect on the reflection camera to create fog. like global fog or something similar, unfortunately since you are in forward rendering this would mean creating a depth texture for that camera that will result in doubling drawcalls.

    2- rewrite your all of your shaders with fog computation in world space. This might result in slower performance but not as much as the previous option.

    3- Use 3D objects that simulates fog and that are visible only by the reflection camera.

    I know you would prefer a better solution, but that's all I can think of for now.
     
  42. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    Hello Yan,

    Please see the attached image taken from the Xbox One kit. In the editor in play mode the water looks awesome as usual, but when I run the application in XBO kit, this is what I am getting. Any idea? I am using your latest release. it seems to me that it has something to do with refraction/reflection.

    Regards,
    Carlos ProblemWithWater.jpg
     
  43. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    I can confirm now after another test, that one more it has to do with adding the bloom effect from Unity to the camera:

    If I don't add the bloom effect the water looks like the picture,
    If I do add the bloom effect the water looks fine.

    I need to avoid this, since the bloom effect is too expensive for my project. Could you help me please?

    Regards,
    Carlos
     
  44. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    This is really weird, only think I can think of is that sometimes the rendertexture can get flipped on some platform and adding a second image effect flips it twice so the render looks fine at the end. Can you try turing on/off Antialiasing (MSAA) and other image effects and tell me if it makes any difference?

    Regards
     
  45. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    I never use MSAA, or other effects. The only effect that I use is bloom and without it is the only time that this problem happens.

    Regards,
    Carlos
     
  46. Ar7ific1al

    Ar7ific1al

    Joined:
    Jan 21, 2014
    Posts:
    52
    Hey there,
    Is there any news to share regarding SSR support? The Post Processing Stack has been available for some time now (better than "cinematic image effects" package), and I would love to have SSR with this water. Very happy with my purchase thus far. :)
     
  47. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Hi,
    I have made some progress on that, I have the reflections showing on the water, but I still cannot get it to look very good yet. The reflection is very very subtle no matter the settings I put on the SSR image effects. I have more work to do on that.

    Regards,
    Yan
     
    Ar7ific1al likes this.
  48. Ar7ific1al

    Ar7ific1al

    Joined:
    Jan 21, 2014
    Posts:
    52
    Very good to hear you are making some progress, even if it is giving you trouble. Even without SSR, I'm very happy with my purchase. What made me buy was the tessellated water shader. Physical waves!? Yes please! For the price, I don't think there is a better water shader.

    Someone mentioned buoyancy support in the thread but it wasn't discussed much; would you happen to have any plans to add support for buoyancy and the tessellated waves? I'm not familiar enough (or at all, really) with shader programming to port the displacement to a C# script as you mentioned in a post above. Buoyancy with the tessellated waves would be awesome.
     
  49. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    822
    PrefabsTest.jpg Here is the image with the prefabs.
     
  50. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    282
    Looks like we found a bug in unity on xbox one. I will submit a bug report for this, but it looks like the grabPass is causing issue on this platform. I will send you more prefabs to see if we can find a work around.

    Thanks!
     
unityunity