Search Unity

Dynamic Water System [Released]

Discussion in 'Assets and Asset Store' started by ZimM, Aug 14, 2013.

  1. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    How quick is Dynamic Water System compared to using Unity basic water shader for PE? Also, can it do underwater caustics/different colours for different depths and rippling if looking up from underwater?
     
  2. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Dynamic Water System is a simulation/physics package in the first place, so your questions are somewhat invalid. Unity Basic Water is nothing more than a plane with a shader applied. Dynamic Water System, on the other side, is all about wave simulation, and the included shaders are just for demo purposes and not extremely optimized. The point is - you can use any water shader with Dynamic Water, as it's designed mostly to complement your water looks, not completely replace it.
     
  3. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    @ ZimM - Ah, I understand - thanks for getting back to me.
     
  4. DrakharStudio

    DrakharStudio

    Joined:
    Mar 2, 2012
    Posts:
    8
    Hi,

    We bought your asset and it works like a charm! Except ...

    We are now porting the game to XBOX one, and when building it complains on your dll saying it is not a AMD64 binary. Is there any way to fix that ?
     
  5. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Interesting. I don't have a XB1 or a Unity license for it, so I can't say for sure, but - at which dll, exactly, it complains?.. There is only a single native dll there, located in Plugins/x86, but it shouldn't even be included into x64 build, since, indeed, it's not an x64 dll.
     
  6. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    Just want to clarify – this can work with all sorts of arbitrary mesh water shapes, correct?
     
  7. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Not exactly. The system itself supports only flat rectangular planes. You can simulate different shapes of the plane by using obstructions masks (like you can see in the Obstruction scene in the webplayer demo, where it is used to make a ciruclar-shaped water body). However, using arbitrary mesh shapes (like a sphere) is not possible.
     
  8. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    So it looks like the obstruction mask is an array? So you'd have to somehow determine the triangles which are obstructed and relate those to the array? So you'd have to create a rectangle bounding the entire area and then create a bounding box on the areas of the rectangle you want to omit and see which verts are in that area and then mark them as occlusion vertices?
     
    Last edited: Jul 11, 2015
  9. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Internally - yes. It is actually a texture that is stretched across the whole water plane and then converted into an array for your convenience. But, of course, you can fill the obstruction mask in whatever way you want.
     
  10. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    Ok, that makes sense and would occluding sections of the water speed up the simulation rendering time proportionally? One more question – would opaque water still show the ripples or does it need to be clear for the effect to be apparent? Thanks so much for the quick responses!
     
  11. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Yes, occluded points are excluded from the calculation for better performance, however, they are still not absolutely free (as they still have to be traversed), so keep that in mind.
    It's depends on whatever shader you use to actually render the water. With the included demo shaders, it doesn't really matters - as long as you can see the water, the effect is apparent.
     
  12. GreatWhite

    GreatWhite

    Joined:
    Dec 13, 2012
    Posts:
    4
    Hi,

    Does this use a cube or a plane? Can a water volume for 2.5D with dynamic surface/waterline be achieved with DWS?

    Thanks in advance!
     
    Manny Calavera likes this.
  13. JTam_HItn

    JTam_HItn

    Joined:
    Dec 13, 2013
    Posts:
    4
    Hi ZimM,
    How can I change the Buoyancy Force on a game object during runtime?

    Thanks!
     
  14. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Dynamic Water surface is just a plane, so no, you can't do that right out of the box. I was thinking about adding support for this kind of thing, but there turned out to be certain complications. Still, it is on the roadmap.
     
    Manny Calavera likes this.
  15. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Do you mean the component or the actual force applied to the object? Buoyancy force depends on the density of the object and on the density of fluid the object is in. The smaller the density of the object is compared to the density of the fluid - the bigger the force. In runtime, you can change the density of the object like this:
    Code (csharp):
    1. BuoyancyForce buoyancyForce = GetComponent<BuoyancyForce>();
    2. buoyancyForce.Density = 500;
     
    JTam_HItn likes this.
  16. JTam_HItn

    JTam_HItn

    Joined:
    Dec 13, 2013
    Posts:
    4
    Thanks! That answered my question :)
     
  17. adre

    adre

    Joined:
    Mar 28, 2014
    Posts:
    38
    Hi, i just bought the assets which seems really powerful.
    I imported in the project ( unity 5.x ) but i have the following errors just after the import:

    Assets/DynamicWater/Demos/Assets/Scripts/DW_CharacterRipples.cs(57,37): error CS1061: Type `CharacterController' does not contain a definition for `bounds' and no extension method `bounds' of type `CharacterController' could be found (are you missing a using directive or an assembly reference?)

    Assets/DynamicWater/Demos/Assets/Scripts/DW_CharacterRipples.cs(58,37): error CS1061: Type `CharacterController' does not contain a definition for `bounds' and no extension method `bounds' of type `CharacterController' could be found (are you missing a using directive or an assembly reference?)

    Assets/DynamicWater/Demos/Assets/Scripts/DW_CharacterRipples.cs(62,29): error CS1061: Type `CharacterController' does not contain a definition for `velocity' and no extension method `velocity' of type `CharacterController' could be found (are you missing a using directive or an assembly reference?)

    Assets/DynamicWater/Demos/Assets/Scripts/DW_CharacterRipples.cs(67,100): error CS1061: Type `CharacterController' does not contain a definition for `isGrounded' and no extension method `isGrounded' of type `CharacterController' could be found (are you missing a using directive or an assembly reference?)


    Any way to sort it out?
     
  18. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Hi,
    I can't confirm that, unfortunately. I've just tried importing Dynamic Water into Unity 5.0.2 and latest Unity 5.1.2 and it's all OK, no compilation errors.
    1) Which exact version of Unity are you using?
    2) What is your build target?
    3) Make sure the Dynamic Water package was downloaded from within the built-in Unity 5.x Asset Store window. You can't upgrade a Unity 4.x project, nor you can't use a Unity 4.x-specific package with Unity 5.x.
     
  19. xiewneqi

    xiewneqi

    Joined:
    Aug 20, 2012
    Posts:
    31
    Hi,
    It seems Dynamic Water doesn't support IL2CPP on IOS. There are lots of compile errors when build with IL2CPP into xcode project, similar to:
    Any solution?
     
  20. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Sorry for the slow response.
    This seems to be a bug in IL2CPP, not in Dynamic Water itself. What version of Unity do you use? IL2CPP gets tons of fixes all the time, so it is important to use the latest Unity version if you are developing for iOS. I've just tested in the latest Unity 5.2.0f1 and it compiles fine.
     
  21. MikeSz

    MikeSz

    Joined:
    Jul 7, 2014
    Posts:
    31
    What about 4.6.7? Does it compile fine there?

    I've e-mailed you a few days back with some questions, but apparently forum works faster ;) Gonna copy-paste them here:
    1) Is it possible to use your plugin just for the simulation but without any rendering? Or to remove your rendering and replace it with a custom solution? (needed to match the planned art style of our game)
    2) Is the source for modifying and passing meshes to GPU included with the plugin?

    Cheers!
     
  22. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    E-mail is usually faster most of the time, I was actually going to reply to your message just now, so it's just my bad, sorry.

    I've just tested with 4.6.7p3 and it compiles fine too.

    1) You can use just the simulation, yes, but you'll probably have to read through the source code to understand how to do that. In any case, what is specific kind of rendering you're going to? The way Dynamic Water System works, you can apply any shader and material to the mesh, and it will work just fine, so probably there's no need to overcomplicate this.
    2) Yes, all C# code is included with the plugin. There is one catch, though. While most platforms use C# code, a C++ dll is used for Android and Windows x86 to get better performance. It is optional, and it is exactly the same as C# code, just converted to C++, but it's not included in the package. I plan to include it in the next update, but meanwhile, you can request it via email if you need it.

    Hope this helps.
     
    Last edited: Aug 18, 2015
  23. soldier11213048

    soldier11213048

    Joined:
    Mar 29, 2015
    Posts:
    11
    Could Dynamic Water support IOS?
    I build faild in IOS, Couly you help me? The error is below

    Thanks.
     

    Attached Files:

  24. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    This is the exact same error that was discussed just a few posts above. Update your Unity version and the issue should be gone. You should always use the latest Unity version when building for iOS, since IL2CPP gets a ton of fixes all the time.
     
  25. kingofasgard

    kingofasgard

    Joined:
    Nov 19, 2012
    Posts:
    30
    @ZimM I have e-mailed you some queries please help.
     
  26. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    I have a larger open body of water that's surrounded by terrain. Instead of creating a giant plane which 75% of it is wasted underground, I used Blender to create a custom flat mesh like this that follows the water in terrain:

    Untitled.jpg

    Is there absolutely no way to make Dynamic Water (just some simple waves) work on a custom mesh like this?
     
  27. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963

    There is no way to do that now, unfortunately, since Dynamic Water System maintains its own mesh that has known specific geometry for performance reasons. But it's not entirely "wasted" - waves will be only be calculated in non-underground areas, if you set up your terrain as an obstruction.
     
  28. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    I have a boat out on the water all the time. It doesn't seem that there's any "occluding" so to speak to not do calculations if you are not looking at the boat, or are even very far from boat, in BuoyanceForce. Am I missing a setting or do I need to implement my own script to enable/disable the boat buoyancy?

    Is disabling the script enough? It looks like I'd have to freeze the rigibody position so it doesn't sink if I disable and enable script.
     
  29. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Well, the question is - should there even be such a thing? BuoyanceForce is designed in the same way standard Unity physics components are. And Unity physics components are not disabled automatically when you are not looking on the object, or when you are far away from it. The reason is simple - if you just disable the buoyancy script, your object will sink to the bottom, which is clearly not something you'll ever want to save some calculations. Sure, you can freeze the rigidbody position, but, again, this depends very much on the exact situation and scene you'll need this.

    Still, I was indeed thinking about some kind of LOD system to gradually reduce the buoyancy detail with distance, so maybe I'll do that in an update.
     
    Last edited: Sep 22, 2015
  30. rkstormer

    rkstormer

    Joined:
    Nov 26, 2012
    Posts:
    27
    In my game I have boats with people on them. I'm generally happy with how the buoyancy works on the boats but I always have trouble with the boats sometimes dipping underneath the water completely, submersing the people, which just doesn't look right. Is there a way to make sure the boats are never submersed beyond a certain point? I've played around with the buoyancy force parameters a bit but can't seem to find a solution.

    Thanks in advance.
     
  31. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Hi @ZimM, has there been any follow up on this?

    I would like to setup a top-down view where the camera follows the character over a large body of water. A couple of options:

    - Tiling a few DynamicWater boxes side by side. In which case the ripples would have to propagate between adjacent DynamicWater meshes. Maybe even lay 9 tiles around the camera and reposition them as needed.
    - Parent a single DynamicWater box under the camera. In which case the mesh would have to 'scroll' as the camera moves and the simulation wraparound.

    Possible? Any ideas?

    I'm mainly interested in the ripples. Buoyancy is not needed for my use case. Obstruction would be nice to have.
     
  32. rkstormer

    rkstormer

    Joined:
    Nov 26, 2012
    Posts:
    27
    I posted a question before asking if there is some way to ensure that a floating object (such as a boat) never goes completely under the water's surface, even with relatively large waves. Does anyone have a suggestion about how I might do this?
     
  33. speckpgh

    speckpgh

    Joined:
    Jan 20, 2016
    Posts:
    2
    Does this library support objects creating and properly propagating waves over the fluid? IE... I drop a rock into the pool, it will properly propagate the wave out from that point, reflecting and interacting off other objects in the fluid? I really need this behavior to explore an idea I have, and I have not found a physics engine yet that seems to handle this properly...
     
  34. Boomer_McBooms

    Boomer_McBooms

    Joined:
    Oct 14, 2014
    Posts:
    99
    Hi Zim,

    Wonderful product, but we encountered a problem with alpha layers. Trees and other items vanish or shift when they are between the camera and your water. Is there a fix for this? Thank you.
     
  35. Deleted User

    Deleted User

    Guest

    @ZimM

    I'm using your plugin Dynamic Water as one of the main plugins in my game, small water based arena, I get decent performance with 5.3.3, however after updating to 5.3.4 and also trying 5.4 Beta 12 the performance drops dramatically,

    5.3.3 - Average of between 60 - 75 fps
    5.3.4 - Average of between 15 - 20 fps
    5.4 beta 12 - Average of between 12 - 15 fps


    Can you update your plugin to work correctly with these versions, or at least release an interim fix for whatever is causing the huge drop in performance ?

    It's definitely Dynamic Water causing the performance drop, because if I disable the gameobject, performance in every version jumps back up to an average of between 60 - 75 fps again.
     
  36. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    It's highly unlikely that updating 5.3.3 to 5.3.4 will cause that huge of a drop by itself... Perhaps something else changed too? Do you use 32-bit or 64-bit versions of Unity? How many Dynamic Water instances are there, and how high is the Quality setting? Also, on what platform are you seeing those FPS?
    I'll take a look at the issue in a few days, but meanwhile, could you please run the Profiler in Deep Profile mode and examine what exactly is consuming the most CPU resources? That would be a tremendous help.
     
    Last edited: Apr 2, 2016
  37. Deleted User

    Deleted User

    Guest

    Thanks for replying.

    I don't want to disrespect your plugin, I think it's fantastic. However, it was the only constant that seemed to effect my game performance when disabled.

    To give you a bit more info. I am using Unity 5.3.3 on a iMac, there is 1 Dynamic Water instance, and in my test scene I also have 7 buoyancy objects, quality for Dynamic Water is 192, and 12 for buoyant objects, standard Mac desktop as the platform for builds, etc.

    This is some profiler information from my 5.3.3 version of the game, the 5.3.3 version of the game runs at a very good frame rate.



    EDIT : And some profiler info from 5.4 Beta 12, Overhead is marginal at best on both which makes it somewhat more confusing...



    EDIT 2 : Small update, installed 5.4 beta 12 again to test, now I'm getting 30-35 fps, so, somewhat better, but still half of what I was getting in 5.3.3, the game is playable again, still not sure what's causing the performance drop, I'm literally just loading the same file...
     
    Last edited by a moderator: Apr 2, 2016
  38. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Thank you.

    Hm... Take a closer look at the Calls column of your screenshots. On your 5.3.3 screenshot, DynamicWater.FixedUpdate and BuoyancyForce.FixedUpdate are called 1 and 7 times respectively, which matches your description. However, on your 5.4b12, they are called 2 and 14 times... Looks like the Profiler lagged a bit and recorded two frames. But if you divide the value of "Time ms" column by number of calls, you can see that the actual time spent by DynamicWater and BuoyancyForce is pretty much the same in 5.3.3 in 5.4b12. So it seems like the issue is not CPU consumption.

    I've also just checked on my Windows machine and found no performance differences between 5.3.2 and 5.3.4, so I'm assuming that this is something OS X specific. Perhaps something GPU-related?.. It'd be great if you also compare the GPU Usage tab in the Profiler between 5.3.3 and 5.3.4.

    Of course, I'm not saying that there is actually no issue here, but at the moment, it's really hard to figure out what's actually causing the slowdown... It'd be best if you PM me your project (or make a project that reproduces the problem), so I can investigate the issue.

    By the way, BuoyancyForce Quality of 12 sounds waaay too much. Usually it makes no sense to have quality bigger than 6.
     
  39. Deleted User

    Deleted User

    Guest

    Thanks for your suggestions, I will look into these and see if I can figure out what is going on. I didn't even notice that they had been called twice, I'll investigate this also.

    I actually struggled with this as it's not documented anywhere, I looked within the online documentation but couldn't find this explained. I will change this based on your suggestions.

    If all else fails, and I can't find a solution, I may take you up on your offer of looking at my project file, but I will exhaust all other options first.

    Regards
     
  40. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    is there a way to map the area bigger?
    I know there is this max mesh size, and simply stacking them next to each other will also not work.

    But is there a way?
     
  41. ashleebeggs

    ashleebeggs

    Joined:
    Sep 25, 2015
    Posts:
    4
    Hi I am using this with google cardboard and cannot select objects when water prefab is active. However if water prefab is not active I can select. Not sure why I cannot select objects that are buoyant on the water.
     
  42. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Good news everyone! Dynamic Water System v.1.3.4 with improved Unity 5.6 is now live on the Asset Store!

    Not really at the moment. In the next update, I hope to make non-interactive simulation work in world space, so they can be stacked together.
    Do you mean selecting in the Editor? Are you sure it is related to Google Cardboard somehow? It's really hard to say anything without at least some screenshots.
     
  43. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I just tested this on Unity 5.5.3f1 with Unity's GlobalFog effect and the water is not affected by the fog at all. Is there a solution to this?
     
  44. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Online Documentation link is broken. Should maybe include docs in the package. This forum appears un-monitored.:(
     
  45. Didldak

    Didldak

    Joined:
    Mar 22, 2015
    Posts:
    3
    Any hints how to make this work correctly with HDRP?
     
  46. Didldak

    Didldak

    Joined:
    Mar 22, 2015
    Posts:
    3
    Also the documentation link is 404.. damn
     
  47. M_Shazaib

    M_Shazaib

    Joined:
    Nov 20, 2018
    Posts:
    2
    I imported your project but the water is not working properly objects are falling through without any effect please help
     
  48. Deleted User

    Deleted User

    Guest

    Has anybody here had any luck upgrading this to a more recent version of Unity, 2019+ ?

    I've had some moderate success, but I've broken other things in the process, it seems the plugin will work for any object placed at the origin, 0,0,0, but if I move anything away from that location, it breaks, as the voxels generated for the buoyancy are not being calculated correctly and are offset 'elsewhere' in 3d space. My programming skills aren't good enough to figure it out properly, so wondered if anyone else had 'had' a chance to look into this and come up with a solution ?
     
  49. Deleted User

    Deleted User

    Guest

    I've spent about a week on this plugin, trying to update it, but I'm simply not a good enough programmer to figure out all the in's and outs of it. So, I'm unable to fix the voxel offset issue that affects all 'buoyant' objects within the package.

    However, I have created a new script that will allow you to have your object still affect the water zone and create fully interactive ripples within it, it's an amendment to the mouse interaction script that now casts a raycast from a physical object instead, simply attach the script below to your own object, then try moving the object around in the dynamic water zone, you will see that it will leave ripples / wakes in whatever direction you require. So, no buoyant objects ( but I can create these another way if required ), but definite water interaction ( which was all that I required anyway ).

    NOTE : Offset the Y position where you cast your ray from, so that it is always above the water zone.

    Hoping any users of DynamicWater may find this script useful :
    Code (CSharp):
    1. using UnityEngine;
    2. using LostPolygon.DynamicWaterSystem;
    3.  
    4. public class Splash : MonoBehaviour
    5. {
    6.     [Header("DynamicWater")] public DynamicWater Water;
    7.  
    8.     [Header("Properties")]
    9.  
    10.     public float SplashForce = 10f;
    11.     public float SplashRadius = 0.25f;
    12.  
    13.     private Vector3 previousPoint;
    14.     private RaycastHit hitInformation;
    15.  
    16.     private void FixedUpdate()
    17.     {
    18.         Ray ray = new Ray(transform.position, Vector3.down);
    19.  
    20.         Physics.Raycast(ray, out hitInformation, Mathf.Infinity, 1 << LayerMask.NameToLayer(DynamicWater.PlaneColliderLayerName));
    21.  
    22.         Vector3 currentPoint = hitInformation.transform != null ? hitInformation.point : Vector3.zero;
    23.  
    24.         if (hitInformation.transform != null && Water != null && previousPoint != Vector3.zero)
    25.         {
    26.             Water.GetWaterLevel(hitInformation.point.x, hitInformation.point.y, hitInformation.point.z);
    27.             Water.CreateSplash(previousPoint, hitInformation.point, SplashRadius, -SplashForce * Time.fixedDeltaTime);
    28.         }
    29.  
    30.         previousPoint = currentPoint;
    31.     }
    32. }
     
    Last edited by a moderator: Apr 6, 2020
  50. Skeketor23

    Skeketor23

    Joined:
    Apr 6, 2019
    Posts:
    49

    Hi, can you give me some details about what exactly you got working? I migrate an old project that was using an early version of this asset, but unfortunately, it does not work on 2018 LTS. I'm wondering if I should give the new version a try. Unfortunately I don't get any response from the developer.