Search Unity

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. flipfloplab

    flipfloplab

    Joined:
    Jun 16, 2017
    Posts:
    1
    Hello, I need to use a caustics effect. Do you have any example for this?
     
  2. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    I'm sorry, but Water 2D Tool doesn't have any demo scenes for caustics effect.
     
  3. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    HI,
    Could you please advise me on the right setting to keep my character from sinking into water when he is on top?
    Similar is there a way to stop my character from going towards the surface? I have set the Density to 0.5. Anythng higher makes him fly towards to surface
     
  4. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi, I'm sorry for the late reply.

    There are a few things you can do to achieve the effects you want. In the Water2D_Simulation script, Player options group, increase or decrease the value of the field Player BBox Size or Player Buoyant Force Scale..
     
  5. BioBurden

    BioBurden

    Joined:
    May 28, 2018
    Posts:
    115
    Hi, just curious to know if this asset can be used to create a lava pool/molten metal pool as opposed to water? I'm assuming it's mainly down to the textures used and that you'd probably want to disable buoyancy etc. Is this possible?
    Thanks in advance.
     
  6. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    It is possible, but just changing the texture will not give you the best result. You'l have to use a custom shader.
     
  7. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    Hi Nicrom,
    I am having some issues with decrease in performance when i use the Water Asset(GPU). As you can see in the Profiler image, when the Water is on, I get around 15 to 25 FPS. However when I turn it off, FPS immediately jumps up to a playable number. Could you advise an ideal setup to get max performance? My game is completely underwater with rare visit to the surface.
    Profiler.PNG
    You can see the stats in the below WaterON and WaterOFF images too
    WaterOff.png
    WaterOn.png
     
  8. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hello, I'm sorry for the late reply.

    What device are developing for, PC, mobile?
     
  9. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    PC
     
  10. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    That is weird. You should not experience this kind of frame drops on a PC. Do you get the same frame drops in the demo scenes too? You can contact me directly on my email johnq002@gmail.com
     
  11. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    Thank you! I have emailed you details with screenshot.
     
  12. DNA666777

    DNA666777

    Joined:
    Jan 22, 2017
    Posts:
    1
  13. raphaelsanguinete

    raphaelsanguinete

    Joined:
    Feb 3, 2018
    Posts:
    6
    Hello, Nicrom.

    I'm developing a game in wich the character will float on the water and then jump up from the water many times. But, in that jumps, the character have to go up the same height, always. In the tests on my project, I'm not getting this result and I think that's because the water physics and deformations, that makes sometimes the character jumps lower or higher than the place that he has to get. I saw that the same happen in the demos, so I think its a normal behavior of the water, with its physics dragging or boosting the character, and with so, affecting the height of the character jump.

    It's a 2D game, my character is Raycast based and I'm using the default water (the game will be for mobile).

    I've tried many different parameters and didn't got a good result yet.

    So, I ask you, whats the best approach to tackle this challenge??

    Thank you!
     
    SamRock likes this.
  14. GrooGadgets

    GrooGadgets

    Joined:
    Apr 2, 2009
    Posts:
    71
    Hello,

    Not sure if this question has been asked before but I would like to know if it's possible to make water where there are caves that you can swim to under the water like in Ori and the Blind Forest?

    If you're not sure what I mean check out the video here:



    Cheers,

    Simon
     
  15. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    Hi, what recommendations can you make for running this on WebGL? I played with your WebGL demo from the asset store link, and...at least it works!
    I made some animation
    (skip to about minute 4) with your GPU water in a couple scenes. The video was captured with the Windows build. My WebGL builds run OK until they get to the scenes with the water, which crash. If I even try to build WebGL on my local box, it breaks the compiled shaders or something, and then the water is pink and black in the edit view. When I looked at the material for the water, the little preview was pink. I just created a new GPU water from the menu. What do I need to change to get at least what I see in your demo? Thanks!!
     
    Last edited: Sep 15, 2018
    SamRock likes this.
  16. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    Hi @Nicrom

    Hope you recovered from your injuries and are back home. Eager to see some updates on the issues reported to you (via mail) :)
     
  17. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Water 2D Tool is part of Unity Cyber Week Mega Sale with a 50% discount.
     
  18. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    Hey hope you are back from Hospital. Would we see any updates to the previously mentioned issues?
     
  19. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. Thank you, I'm a little better now. I'm sorry for getting back to your issues so late. Could you email me and describe the issues you have at the moment.
     
  20. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. I'm sorry for this late reply.

    What version of Unity are you using and what are the specs of the PC you are building on?
     
  21. HD43

    HD43

    Joined:
    Jul 10, 2018
    Posts:
    8
    hi,i try to change water size on runtime,but it not work
    Here's my code
    Code (CSharp):
    1.  waterTool.waterWidth = levelBound.size.x;
    2. waterTool.waterHeight = levelBound.size.y; waterTool.RecreateWaterMesh();
     
  22. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    Is the water object CPU or GPU based?
     
  23. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Water 2D Tool v1.7 is now published on the Asset Store.

    This update is mainly focused on bug fixes and compatibility with newer versions of Unity.
    Water 2D Tool is no longer supported on Unity versions older than 5.6.6.
    I also updated the documentation and made it available online. The documentation now contains a section with tips about which settings should be changed to get a better performance on mobile devices.
     
  24. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,525
    Thanks for the update!
     
    Nicrom likes this.
  25. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    Thank you for the updates!! Could you please elaborate on this update "Removed the option to disable the 2.5D water when a GPU based water object is created." ? What does this mean? 2.5D will always be enabled?
     
  26. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    In short yes, the 2.5D will always be enabled for GPU based water objects. The GPU based water needs both the top and front mesh to be present. Before when you created a GPU based water object you could disable the top mesh by disabling the 2.5D toggle, but doing this would generate errors when in Play mode.
     
  27. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,525
    Is there a way to change the axis of the water?

    I want to rotate the water 90 degrees.
    and the gravity axis too
     
  28. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    I'm sorry, but currently you can't rotate the water object. This applies to the CPU based as well as the GPU based water objects. Rotating the water object will make the handles not work correctly and at run time you may experience some weird water behaviours.
     
  29. JohnnyRey

    JohnnyRey

    Joined:
    Jan 26, 2013
    Posts:
    16
    I just discovered this asset...it's incredible! I did have a question - how do I make an object "float" and "bounce" along with ambient waves? (while still staying put) I have it so it floats, but it does not move once it's settled in the water.

    Additionally, any tips on using this with an orthographic camera? When I try, the water almost looks like I'm looking at it from directly above, and any transparency under the surface is gone.

    Thanks!
     
    Last edited: Mar 20, 2019
  30. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    I'm sorry, but currently you can't make an object move up and down with the ambient waves. The buoyancy is simulated on the CPU while the ambient waves on the GPU. In order to make the object react to the ambient waves the CPU needs to know what changes the GPU made to the vertex positions, but this is not easy to implement.

    The GPU based water is not really suited for the orthographic camera. I would recommend you to use the CPU based water with the orthographic camera.
     
  31. JohnnyRey

    JohnnyRey

    Joined:
    Jan 26, 2013
    Posts:
    16
    No problem and understood. Thank you for the information!
     
  32. dvdarias

    dvdarias

    Joined:
    Sep 24, 2014
    Posts:
    12
    Hi Nicrom, amazing asset. Just a question:
    I have a 2D game made of spreite renderers only.
    I am not being able to make the Distortion work on the water 2d object using a perspective camera. It starts working as soon as I change the camera to orthogonal. I am using the UnlitRefraction_FM shader.

    How can I make it work?
     
  33. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    I'm sorry for the late reply. There is a time difference between us.

    In the material properties of the water object increase the values of the field Bump waves or Distortion.
     
  34. dvdarias

    dvdarias

    Joined:
    Sep 24, 2014
    Posts:
    12
    Problem solved!!!, Thanks for the quick reply.
     
  35. uniwarden

    uniwarden

    Joined:
    Nov 30, 2017
    Posts:
    2
    Hi Nicrom. Great tool. My question is, is there a way to get this working with the lightweight render pipeline? if so let me know as soon as possible. Thanks in advance.
     
  36. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    I'm sorry, but currently Water 2D Tool only partially works with the LWRP or HDRP.
    The GPU based water as well as other Water 2D Tool shaders are not compatible with the LWRP or HDRP.
    You can create CPU based water objects, but you'll have to use a LWRP compatible shader.
     
  37. uniwarden

    uniwarden

    Joined:
    Nov 30, 2017
    Posts:
    2
    Thanks for the swift reply. i'll figure it out :)
     
  38. Akiramechan

    Akiramechan

    Joined:
    Jun 20, 2019
    Posts:
    2
    Hello Nicrom,

    I just bought the 2D Tool and tested it in my scene.
    I created a GameObject - 2D Water - CPU Water - Water with 2D Collider, but there is an error, it says :

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

    I checked the line "50" on the PolygonClipping script but I don't know what's the problem is.
    Can you please help ?
     
  39. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    I'ts a little hard for me to guess what caused this error, just from this information. Is it possible for you to create a new project, replicate the problem in it and send it to me?
     
  40. Akiramechan

    Akiramechan

    Joined:
    Jun 20, 2019
    Posts:
    2
    I just tested the 2D Water Tool in a new scene in a new project and it works.
    It must have a problem in my work scene, I'll go figure it out.

    Thanks for your quick answer !
     
  41. Mikhail-Alexeev

    Mikhail-Alexeev

    Joined:
    Jun 9, 2016
    Posts:
    2
  42. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    Are you testing on a mobile device or on PC?

    In the case of the GPU based water, increasing the value of the field Segments to Units will not make the water look better.The look of the GPU based water depends on the resolution of the Render Texture used by the water object. To increase the resolution of the render texture, increase the value of the field RT Pixels to Units.
     
  43. ChasingRatsGames

    ChasingRatsGames

    Joined:
    Jun 26, 2018
    Posts:
    1
    Hello Nicrom,

    I'd like to know if it is possible to change the shape of the water to something other than a square/rectangle or to use a mask in order to simulate another shape?

    We're basically trying to fill a trapeze shaped container, thank you for your time.
     
  44. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi.

    Currently you can't make the water have another shape other than a rectangle. Many water features require the water to be a rectangle, so without some major modifications to the code its impossible. As for masks, I have never tried to hide portions of the water with masks, so I can't say for sure if it is possible or not.

    Best regards
    Nicrom
     
  45. PoorbandTony

    PoorbandTony

    Joined:
    Oct 7, 2015
    Posts:
    16
    Hi,

    Sorry to bother you. I'm using your package for a project I'm working on. I'm struggling a little with something fairly simple, but I'm not sure if the package caters for it.

    Basically I'd like the waterline to render in front of the character, but keep the body of water behind the character - retaining the material.

    At the moment, if I set the order in layer for the front mesh to behind, I get this:

    example.JPG

    But if I set it in front, I get this:

    example2.JPG

    Ordinarily that'd be fine - but it mutes the colours too much - but I still want to retain the water gradient.

    Is the package capable of this - or can you think of any workarounds?

    Thanks in advance - it's a brilliant package by the way - purchased it years ago but haven't got around until now to use it!

    Cheers,
    Tony
     
    Nicrom likes this.
  46. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. Thank you for buying water 2D Tool :).

    By default you cant do that, but there are a few things you can try.
    1. Import the water texture in an image editor and try to make the gradient part more transparent
    2. Duplicate the water object. Create 2 textures. One with only the water gradient and the other with only the water line. Create 2 materials that use those 2 textures. Assign the materials to the two water objects. Since they use two different materials you can use the sorting layers now. Also if you are using the Water 2D Tool buoyancy, make sure that only one water object has the buoyancy enabled, generates sounds and particle effects.

    Best regards,
    Nicrom.
     
  47. PoorbandTony

    PoorbandTony

    Joined:
    Oct 7, 2015
    Posts:
    16
    Thanks for such a quick answer Nicrom!

    That sounds like a good idea. I was a little concerned about performance on mobile - but the idea of turning off one of the buoyancy components sounds perfect.

    Thanks again!
     
  48. Innocent-Dev

    Innocent-Dev

    Joined:
    Apr 1, 2015
    Posts:
    23
    HI Nicrom Best 2d water in Asset store.
    But I have a problem, It looks like your asset does not support LWRP, do you plan to do LWRP support in future
     

    Attached Files:

  49. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. Thank you :).

    I'm currently working on an update that will make the GPU based water work with LWRP. There will be some limitations. At the moment I was able to port only the unlit shader for the GPU based water. Not sure I will be able to port the lit shader. I tried to recreate the GPU based water shader in Shade Graph, but had no success, so I created a custom shader that would work with LWRP.
     
    Last edited: Sep 6, 2019
    DrOcto likes this.
  50. Innocent-Dev

    Innocent-Dev

    Joined:
    Apr 1, 2015
    Posts:
    23
    VERY BIG THANKS, I will wait.