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

Physics Water 2D Tool - GPU based ripple water, realistic buoyancy, water flow & animation

Discussion in 'Tools In Progress' started by Nicrom, Feb 23, 2015.

  1. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    No problem, I can get both set up.
     
  2. PaulAfello

    PaulAfello

    Joined:
    Sep 19, 2015
    Posts:
    16
    First of all, great tool! Love the richness it can bring to a scene.

    I am running into a curious issue though for which I could not find any solution (but I probably missed it).
    In my scene I have fog enabled in the environment setting (see image for settings).



    In game view some layers that are not affected by the fog above water are rendered as if heavily obscured by fog in the reflection. Notice the black stone wall missing in the reflection:



    As soon as I turn fog off in the Lightning/Environment settings the wall reappears:



    I am so confused as to what might be causing this! For reference I also post a view from the scene where you can see the black stone wall is but 1 unit away from the other stone walls that do reflect in the water surface.



    If I move the rock aside you can see a bit of the background that is actually affected by the fog because it is 220 units away... but those objects are actually NOT affected by the fog in the reflection.



    I am on the latest version of Water2D and working in Unity 2020.2.7
    What am I doing wrong here?
     
  3. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. Thank you for for your kind words :)

    Select the water object with the script Water2D_PlanarReflection and make sure the rock layer is not disabled in the Reflection Mask
     
    SamRock likes this.
  4. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    I've seen this on the store - looks like it would work great for 3D as well. I'm curious why it's advertised for 2D/2.5D only? I also read that you include a Shader Graph for the water. Does it work in the latest URP (12)? Thanks! :)
     
  5. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. Its advertised for 2D/2.5D only because Water 2D Tool was created with the intention to be used mainly in side scrolling games.
    It works in URP 12, but the Shader Graph shader is just a template shader with only the water ripple feature. It doesnt have other features like color depth, refraction, reflection etc.
    Here is a screenshot of SG shader.
    upload_2021-5-18_9-2-33.png
     
    adamgolden likes this.
  6. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    I'm using the Planar Reflections component (v1.12) from this asset currently, which is working great for me in 2021.2.0a20 with URP 12 - but in the script for it, I had to change the end of line 236 to
    = max;
    and the end of 237 to
    = bias;
    ..and based on code earlier in the function it appears this was what they were originally meant to be (..please correct me if I'm wrong).

    Anyway - this asset had just what I was looking for, thanks, I also appreciated the reflection quality being super easy to adjust at runtime procedurally (just by setting whatever properties then disposing the current reflection texture). I also plan to learn your ripple system eventually as I'm sure it'll be a good fit for something and I think it looks great :)
     
  7. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    I'm glad Water 2D Tool can be of use to you :).

    I have not tested Water 2D Tool in 2021.2.0, so I'm not sure about the code changes. Thank you for this info, I'll look into this.
     
    adamgolden likes this.
  8. NautilusCat

    NautilusCat

    Joined:
    Nov 29, 2020
    Posts:
    3
    I just downloaded this and was pretty excited to mess around with it, but none of the shaders are working. Everything, including the demo scenes just have the default pink texture on everything and I'm getting hundreds of error messages per second saying "Shader properties can't be added to this global property sheet. Trying to add <nameoftexture> (type1 count1)".

    Also if I play the scene, I get hundreds of these errors messages per second on the console:

    NullReferenceException: Object reference not set to an instance of an object
    Water2DTool.Water2D_PolygonClipping.GetIntersectedPolygon (System.Collections.Generic.List`1[T] subjectPoly, UnityEngine.Vector2[] linePoints, System.Boolean& intersecting) (at Assets/Water2D_Tool/Assets/Scripts/Utils/Water2D_PolygonClipping.cs:50)
    Water2DTool.Water2D_Simulation.ApplyForcesToObject (System.Collections.Generic.List`1[T] subjPoly, UnityEngine.Vector2[] clipPoly, System.Int32 oIndex) (at Assets/Water2D_Tool/Assets/Scripts/Water2D_Simulation.cs:2054)

    Any idea what's going on here? I'm using 2020.3.14. and the Universal Render Pipeline.
     
    Last edited: Jul 15, 2021
  9. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hello.

    The Water 2D Tool shaders and materials need to be upgraded to work with URP. To upgrade them, go to Water2D_Tool/Assets/SRP folder and import Water2DTool_URP package.

    You mean the Water 2D Tool demo scenes generate errors?
    I tested Water 2D Tool in Unity 2020.3.14 URP and no errors are generated in my project.
     
    Last edited: Jul 15, 2021
    NautilusCat likes this.
  10. NautilusCat

    NautilusCat

    Joined:
    Nov 29, 2020
    Posts:
    3
    Oops, my bad. Thanks for your help.
     
  11. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    You are welcome. Let me know if you encounter any other issues. I'll help with what I can.
     
  12. NautilusCat

    NautilusCat

    Joined:
    Nov 29, 2020
    Posts:
    3
    One other quick question, is there a way to change the sorting layer?
     
  13. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    The sorting layer and order in layer for the front and top mesh of the water can be set from the Water2D_Tool script, Mesh Properties group of options.
    upload_2021-7-15_22-38-19.png
     
    NautilusCat likes this.
  14. ullbjorn

    ullbjorn

    Joined:
    Jan 2, 2018
    Posts:
    2
    Hi

    Is there a tutorial for this asset? Im lost cant make it work...:(

    Thanks!
     
  15. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. There is a PDF Guide as well as a Tutorial Series that showcases the most common features of Water 2D Tool
     
  16. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    Hi, love this plugin!
    When is support coming for Unity 2021.2 URP? I haven’t tested, but read in your notes it wasn’t supported.
     
  17. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. I'm glad you like it :).

    I'm not sure when I'll add support for Unity 2021.2+ URP. Currently I'm busy with another project and do not have the time to work on Water 2D Tool.
     
  18. zeldalore86

    zeldalore86

    Joined:
    May 22, 2020
    Posts:
    5
    Hi Nicrom, whenever I go into the water 2D asset page, I get a "!!! Failed to render view !!! Internal Server Error". It seems the server is down. I was planning on purchasing it. This seems to be a unity server issue? not sure if you can do anything to circumvent this. Thanks
     
  19. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi zeldalore86. I would recommend you try contacting the Asset Store support.
     
  20. zeldalore86

    zeldalore86

    Joined:
    May 22, 2020
    Posts:
    5
    Hey there! I bought the asset and I must say it works remarkably well! I do have a slight issue in regards to its rendering order.

    I am attempting on setting up a simple 2.5D test scene using sprites, which are placed in different positions on the Z axis to achieve a parallax effect. Each sprite's order in layer is set up accordingly to not overlap with the ones in front.

    When I apply a regular plane mesh horizontally, the layering works fine, as seen here: upload_2022-6-26_17-42-25.png

    The issue comes with the water, which I believe might be due to it working with Order in Layer like sprite renderers do, which I believe is an issue as it does not render the same way as a mesh would. Changing the ordering layer of the top layer of the water merely places the water over or under the whole sprite, and ideally it would be best if this top layer rendered like a plane would. You can see what I mean here:

    upload_2022-6-26_17-48-11.png

    Is there a way to fix this issue? Is there something in the water's settings I might not be seeing, or would I need to edit something in the code?

    My goal is to essentially achieve the same effect seen in Ori or the Rayman games with their parallax and depth.

    upload_2022-6-26_17-49-12.png

    Thanks!
     

    Attached Files:

  21. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi zeldalore86.

    What Unity version and pipeline do you use?
    Also, what shader do the sprites use?
     
  22. zeldalore86

    zeldalore86

    Joined:
    May 22, 2020
    Posts:
    5
    I'm using Unity version 2020.3.30f1
    The water shader is the Default_WaterRippleAdvanced_TM. The same applies if I apply the shadergraph shader provided (SG_UnlitWaterRipple_Template_TM). If I apply the default Lit shader of the default plane, the layering works as intended, but without the ripple and such.

    As for the sprites themselves, they use a Sprite default shader in this case.
     
  23. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    The default sprite shader is not suited for objects that enter the water. This is true for water in general and is not limited to Water 2D Tool shaders. You'll need to use a shader that has a cutout feature. For example, for the sprites that enter the water, use the Unity Standard shader with the Rendering Mode set to Cutout.
     
  24. zeldalore86

    zeldalore86

    Joined:
    May 22, 2020
    Posts:
    5
    I forgot to add I am using URP, but I seem to have solved the issue, partially.

    I tried once again the Shadergraph material "SG_UnlitWaterRipple_Template_TM" and FM, and the big grey box using the "Universal Render Pipeline/Lit" shader now seems to be working fine in both water planes.

    As for the mushrooms, which is a custom Shadergraph (quite a simple one), I originally had the surface set to transparent, but setting it to opaque with Alpha Clip set to true seems to fix this issue as well.

    upload_2022-6-26_19-23-44.png

    However, lets say I instead want the world to be affected by Unity's 2D Lights, if I set the shadergraph to "Sprite Lit" or "Sprite Unlit", the issue persists as it no longer has an option for Alpha Clipping (I want to make sure all options are available in case I decide to use the Forward Renderer or the 2D Renderer).

    As a sidenote, changing the Water to Sprite Lit (in this case the front mesh) works well, illuminated with a Freeform Light 2D (and an extra one for testing highlights/brighter areas in water):

    upload_2022-6-26_19-29-43.png

    Also, the "Default_WaterRippleAdvanced_FM" material has this strange issue with the water when applied to the plane and mushroom, not sure why that's happening:

    upload_2022-6-26_19-36-32.png

    Both Ori games and Rayman Legends use 2D lights to illuminate their environments (even the water), which Unity replicated creating their own 2D lights.

    The ideal thing would be for this asset to be able to be used using 2D or 3D lights depending on which renderer (Forward or 2D) you decide to use in URP. But It seems to be primarily a shader issue.
     
  25. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    I want to point out, that if you want to use the Water 2D Tool shaders that have real time reflections, they will not work with the 2D Renderer
    upload_2022-6-26_21-0-14.png

    What shader does the material "Default_WaterRippleAdvanced_FM" use?
     
  26. zeldalore86

    zeldalore86

    Joined:
    May 22, 2020
    Posts:
    5
    The shaders might be able to be edited to incorporate reflections in the 2D renderer, although I would have to experiment on that. something like this comes to mind:


    Default_WaterRippleAdvanced_FM uses the shader "Water2D/LWRP/UnlitWaterRippleAnvanced_FM"
     
  27. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Do you have the Opaque/Depth Texture toggles enabled in the scriptable asset?

    upload_2022-6-26_21-12-51.png

    If you use Discord, you can join my Discord server. It will be easer for me to help you with your issues.
     
  28. EnvisionGames

    EnvisionGames

    Joined:
    Sep 24, 2019
    Posts:
    12
    Hey, i am using Unity 2020.3.35f1 and the latest URP Version 10.9.0 - April 12, 2022.
    The Problem is that in the Demo Scene the Camera looks different than the Scene View. I tried it in built-in and it looks normal so it must be a problem with URP. How can i solve this? In the MainCamera Perspective the water is not transparent and you can not see the sharks through the water. There is also no water outline on the rim of the environment. Screenshot (123).png Screenshot (124).png
     
  29. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. Can you check if the Depth/Opaque Texture toggles are enabled in the scriptable asset settings?
     
  30. EnvisionGames

    EnvisionGames

    Joined:
    Sep 24, 2019
    Posts:
    12
    Yes that fixed it!! Thank you :)
     
    Nicrom likes this.
  31. EnvisionGames

    EnvisionGames

    Joined:
    Sep 24, 2019
    Posts:
    12
    I should have seen this earlier ^^
     
  32. Exclusif

    Exclusif

    Joined:
    Apr 21, 2022
    Posts:
    1
    Hi,
    How do I change the color and transparency of the water? Can't find anything about that in the docs.
     
  33. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    Which water shader do you use?
     
  34. kjorrt

    kjorrt

    Joined:
    Nov 26, 2014
    Posts:
    34
    Hi, is it possible to make a 3D water cube with this? I need cubes of water in my game with depth, opacity and interactions.
     
  35. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. Its not posible to make it cube. The water can have only the front and top mesh.
     
  36. Cidonix

    Cidonix

    Joined:
    Apr 21, 2015
    Posts:
    2
    Hi! What about support URP in Unity 2022.3?
     
  37. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. W2DT custom shaders support URP only up to Unity 2021.1. I plan to add support for newer versions of Unity, but I'm not sure when that will happen as I'm currently busy with other projects.
     
  38. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    183
    I would really love an update (or even some instructions on how to make it work myself) with Unity 2022. Great asset!
     
    adamgolden likes this.
  39. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi starfoxy.

    I'm sorry, but at the moment I am busy with another project and do not have the time to work feature updates for W2DT.
    I assume you use URP, if so, W2DT comes with a basic shader template created in SG than you can use as a starting point if you want to try to port the water shader to URP.