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

Dynamic Water System [Released]

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

  1. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963

    Dynamic Water System is a custom interactive water physics system designed with Unity Free in mind. While not a full-scale ocean simulation, it works really great for small water bodies such as small ponds, pools, fountains, waterfalls etc. Realistic look of water is achieved through wave simulation applied to a high-poly mesh.
    Also includes realistic voxel-based buoyancy system.

    Demos:
    Features:
    • Full support for Unity 3.5.7 - 2017.x versions (both free versions and Pro).
    • Designed to work on mobile devices (50 FPS on Motorola Droid 2 with 64x64 water mesh).
    • Interactive buoyant object that cause ripples.
    • Static obstruction geometry for achieving non-rectangular shapes. All collider types are supported.
    • Highly customizable code for your own wave functions.
    • Buoyancy simulation system is totally separable from water simulation. In fact, you can use it independently for things like air balloons and blimps.
    • Optimized for low-end hardware.
    • Documented demo examples.
    • Full source code documentation included.
    Support:
    For any questions regarding this plugin, feel free to contact me at contact at lostpolygon.com or post in this thread.​

    Version history:
    1.0:
    • Initial release.
    1.1:
    • Added Boat demo (includes an example of generating pseudo-oceanic waves).
    • Added splashes to the Pool demo.
    • OnFluidVolumeEnter / OnFluidVolumeExit events.
    • Improved demo scenes visuals.
    • Limited Flash support.
    • Minor fixes.
    1.2:
    • Added Character demo scene.
    • Added underwater fog script.
    • Inverted obstruction geometry (allows to create more complex shapes).
    • Added support for obstruction textures.
    • Added circular waves feature to Advanced Ambient Waves.
    • DynamicWater and SplashZone now support arbitrary transformation
    • Fast normalization redone with much improved quality. It is now recommended and used by default.
    • A lot of workflow and UI improvements.
    • Added some example scripts.
    • Tons of optimization, some heavy methods moved to a native library (only for Windows x86 and Android at the moment).
    • Code cleanup.
    • Various bugfixes.
    1.3:
    • Improved Unity 4.3 compatibility (new Undo system, no more nasty warnings).
    • Fixed DllNotFoundException issue that occured on some installations.
    • Added a menu item to relocate the asset files for JS scripts.
    • Minor fixes.
    1.3.2:
    • Improved Unity 4.5 compatibility.
    1.3.3:
    • Improved Unity 5 compatibility.
    1.3.4:
    • Improved Unity 5.6 compatibility.

    Documentation:
    If you like the asset, please review/rate it on the Asset Store, I'll greatly appreciate that :)
     
    Last edited: Nov 27, 2017
    Mister-D likes this.
  2. TheNorthridge

    TheNorthridge

    Joined:
    Jan 4, 2012
    Posts:
    193
    That is the prettiest water system Ive seen in Unity yet. And its cheap too?!

    Are you some sort of wizard?

    Shall be getting this ASAP :)
     
  3. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Send you a PM, please answer.

    Edit:
    Send a second PM now.
     
    Last edited: Aug 15, 2013
  4. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Webplayer demo updated with a new Boat scene, showing how to create a simple boat controller and integrate it in your game. Check it out! ;)
    The asset itself will be updated with this demo soon.
     
    Last edited: Aug 17, 2013
  5. BigDaz

    BigDaz

    Joined:
    Apr 8, 2013
    Posts:
    54
    Love the interactivity and ripples, is it easy to add splash effects?
    It's the only thing missing when an object falls in.
     
  6. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    I guess it'll be quite easy to achieve by spawning a particle system in where the object falls in the water. I'll try to make an example in one of the nearest updates. Stay tuned!
     
  7. carl010010

    carl010010

    Joined:
    Jul 14, 2010
    Posts:
    139
    This is absolutely amazing. The best water I have ever seen in unity hands down. Side note the water fall in the water fall scene is laking quite a bit
     
  8. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Hi,
    Great work
     
  9. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Thanks for support everyone! :grin: I've made a small update based on your suggestions. The update is currently pending for review and should be approved soon, but the updated demos are already online!

    Changes are:
    • Added Boat demo (includes an example of generating oceanic waves).
    • Added splashes to the Pool demo.
    • OnFluidVolumeEnter / OnFluidVolumeExit events.
    • Improved demo scenes visuals.
    • Limited Flash support.
    • Minor fixes.
    If you want to get the update before it is approved - just send me a PM.

    P.S. If you like the asset, please leave a review or rate the asset on the Asset Store, I'll greatly appreciate that :)
     
    Last edited: Aug 21, 2013
  10. V0odo0

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Best water system for Unity I ever seen! It is possible to make with it something like dirt surface? Like snow in Assassin's Creed 3 for example.
     
  11. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Thanks! I'm pretty sure it is possible with some coding work, but at the current state it would be a quite inefficient thing to do performance-wise, so I can't really recommend that :)
     
    Last edited: Aug 21, 2013
  12. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    Is there some way to simulate walking through shallow water? Like perhaps putting voxel colliders on the foot bones, or making the character collider interact with the water?
     
  13. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Yes, it's easily possible with DynamicWater.CreateSplash method. I've made a simple example script, just add it to your character controller:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. [RequireComponent(typeof(CharacterController))]
    5. public class DW_CharacterRipples : MonoBehaviour {
    6.     // Ripple parameters
    7.     public float SplashRadius = 0.2f;
    8.     public float SplashForce = 10f;
    9.     private DynamicWater _water;
    10.  
    11.     void OnTriggerEnter(Collider otherCollider) {
    12.         // Making sure the object we have entered is DynamicWater
    13.         if (otherCollider.CompareTag(FluidVolume.DynamicWaterTagName)) {
    14.             _water = otherCollider.gameObject.GetComponent<DynamicWater>();
    15.         }
    16.     }
    17.  
    18.     void OnTriggerExit(Collider otherCollider) {
    19.         // Making sure the object we have left is DynamicWater
    20.         if (_water != null  otherCollider.CompareTag(FluidVolume.DynamicWaterTagName)  otherCollider == _water.Collider) {
    21.             _water = null;
    22.         }
    23.     }
    24.  
    25.     void FixedUpdate() {
    26.         // If we are in the water volume
    27.         if (_water != null  _water.PlaneCollider != null) {
    28.             CharacterController controller = GetComponent<CharacterController>();
    29.             // If we are actually submerged to a some extent
    30.             float waterLevel = _water.GetWaterLevel(transform.position.x, transform.position.z);
    31.             if (controller.bounds.min.y < waterLevel  controller.bounds.max.y > waterLevel) {
    32.                 // Create the ripples
    33.                 _water.CreateSplash(transform.position, SplashRadius, SplashForce * Time.fixedDeltaTime);
    34.             }
    35.         }
    36.     }
    37. }
    38.  
    So it looks like this:
    $ss10_.jpg
     
    Last edited: Aug 22, 2013
    Mister-D likes this.
  14. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Very impressive!
     
  15. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Will you ad some kind of underwater shader to this?
    I could not imagine on how to do this because of the waves so there is no exact line where to switch things i.e. to nebula ....
     
  16. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    I don't have Unity Pro, so I can only make a demo with the standard fog.
    There is actually a very easy way to detect exactly when you have to enable the effect by using DynamicWater.GetWaterLevel method, which takes the actual wave level into account. The code is very similar to the one above. Attach this script to the character controller:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. [RequireComponent(typeof(CharacterController))]
    5. public class DW_UnderwaterFog : MonoBehaviour {
    6.     private DynamicWater _water;
    7.  
    8.     private void OnTriggerEnter(Collider otherCollider) {
    9.         // Making sure the object we have entered is DynamicWater
    10.         if (otherCollider.CompareTag(FluidVolume.DynamicWaterTagName)) {
    11.             _water = otherCollider.gameObject.GetComponent<DynamicWater>();
    12.         }
    13.     }
    14.  
    15.     private void OnTriggerExit(Collider otherCollider) {
    16.         // Making sure the object we have left is DynamicWater
    17.         if (_water != null  otherCollider.CompareTag(FluidVolume.DynamicWaterTagName)  otherCollider == _water.Collider) {
    18.             _water = null;
    19.         }
    20.     }
    21.  
    22.     void FixedUpdate() {
    23.         // If we are in the water
    24.         if (_water != null) {
    25.             CharacterController controller = GetComponent<CharacterController>();
    26.             float waterLevel = _water.GetWaterLevel(transform.position.x, transform.position.z);
    27.             // Switch the fog on if both character and camera are in the water
    28.             RenderSettings.fog = controller.bounds.center.y < waterLevel  Camera.main.transform.position.y < waterLevel;
    29.         }
    30.     }
    31. }
    32.  
    Result:

    $ss11.jpg

    I think I'll add a demo scene soon to make this more illustrative.
     
    Last edited: Aug 22, 2013
  17. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    The 1.1 update is now live on Asset Store!

    Also, Webplayer demo now includes Character demo, which shows both shallow water interaction and underwater effects.
     
    Last edited: Aug 23, 2013
  18. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    the boxes look great

    but when the guy jumps in it does not cause it does not splash enough

    also underwater looking at things it does not distort them

    finally, the physics is wrong, boat and boxes in the current is not moved by the current, in real life it would be

    could u add more realistic physics to floating and have it interacting with current and splashing and such, it should move things around like in real life

    thanks in advance.
     
  19. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Hi, thanks for a thorough review!

    True, I've totally forgot to add splashes to the character. Expect the demo to be updated soon. UPD: Webplayer demo updated

    Yes, because that'd require Unity Pro, which I do not own, and I also want to keep it working under Unity Free. Note also that this is not a shader package, it a scripting asset. So if you want really great shader effects, you should consider buying one of those water shader packages available on Asset Store.

    The problem about current is the fact that there is actually no such thing as current in the simulation - it's basically just a heightmap. Still, it is possible to emulate to some extent. So yes, physics are not ideal, but I'll definitely be doing some improvements.
     
    Last edited: Aug 24, 2013
  20. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    Any chance of bringing this to a full Ocean system?
     
  21. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Looks amazing! Did you say it works on mobile ?!!!!!!! :D
    And it supports Unity 3.5.7! Definitely top of my shopping list!
     
  22. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    There is a chance. I've done some research, and I think I could handle that, but most probably that would be a new asset, because I want to keep this system cheap and simple. Anyway, it's too early to say something with confidence, as I want to polish this system first before extending it drastically.

    Thanks for your support :)
     
  23. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    That would be great, unity really needs an affordable ocean system.
    And if anything like this, would be a fantastic solution.
     
  24. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    That'd truly be awesome. But you must understand there is a good reason why ocean systems cost so much - developing them is ridiculously difficult, orders of magnitude more difficult than developing something like my Dynamic Water System. Moreover, for best performance you have to make specific optimizations for a lot of cases and platforms (that's probably a reason why even Triton Ocean only supports Windows atm), and it won't probably ever run on mobile platforms. Having said that, I do not plan on making such enormously complex project all by myself until at least Dynamic Water System is successful enough. And for the price of $30, Dynamic Water System is even now not a bad subtitute for a full-blown ocean system at all, despite it's simplicity (see Boat demo. I'll also be doing some improvements to make it look better).
    I'm not saying I'll never develop an true ocean system, but that won't probably happen soon. I hope that cleared some things a bit.
     
    Last edited: Aug 25, 2013
  25. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
    Just bought it and I really enjoy everything, but can you provide a demo or explain how to make the underwater effect in the character demo?

    I'm also having a bug, when looking at tress far away they appear behind the water. Print:
    http://i.imgur.com/hLcs8zZ.jpg
     
    Last edited: Sep 10, 2013
  26. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    I've already answered you on e-mail, but just in case someone has these questions too:

    The underwater effect script can be found at the previous page of the thread. You may need to modify it a little bit to fit to your situation.
    As for the tree issue - that's because the included water shader is mostly for demonstration purposes and may not fit all needs. To fix this issue, you'll have to edit the Queue parameter in the shader so that trees are rendered after the water (refer to Unity shader docs on that).
     
  27. Casto

    Casto

    Joined:
    Aug 14, 2013
    Posts:
    44
    This looks great!
    Is water animation handled in a shader or in a script (via mesh manipulation)? I'd like to know if I can use my own water shader with your system.
    Also, how big can the water plane be?
     
  28. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Water animation is done via mesh manipulation on the CPU, so you can use any shader you want.
    The size of the water plane depends on your needs. If you want interactive water simulation (making ripples etc), then you are limited to something like a big swimming pool in size. If you don't need simulation, then you can make much larger water bodies, as seen in the Boat demo.

    However, the size really depends on the quality settings. The higher the quality - the larger you can make the water plane (and for example, Boat demo uses quality 50 out of 256). Technically there is no particular size limitation - it will just look not so good at extreme sizes.
     
  29. Sam_Pr

    Sam_Pr

    Joined:
    Aug 23, 2012
    Posts:
    66
    This is a quite impressive system, I just have one question: Is it possible to allow for swimming?

    Thanks a ton for this awesome asset!

    Also I don't get ripples like the docs say I should..
     
    Last edited: Oct 2, 2013
  30. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    What kind of swimming do you want to achieve? That strongly depends on the game, but basically, it's quite easy to make a swimming script.
    The ripples problem is odd, are you getting any errors/warnings?
     
    Last edited: Oct 2, 2013
  31. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Would buy this if there is a possibility of integrating your outstanding "water physics" with any custom "liquid" geometry/material in my project (if those would have to fulfill specific requirements, that would be ok though).

    Reason: while I love your water physics (buoyancy, ripples, the whole lot), I most likely prefer the graphics rendering (shading, reflections, refractions, specularity foams etc.) of another different external water package. Or I might want to switch from one water solution (perhaps Unity's own) to a better one 2 months later, or if Unity 5.x gets totally awesome with water, back to out-of-box much later on again. So I wouldn't want to burden you with the trouble of having to keep up with water rendering/shading and would just use this for the "physics" provided.

    Would this be possible/feasible, and if so, how tricky might it be for "me, the Water user"?
     
    Last edited: Oct 2, 2013
  32. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Hi, this asset is designed to be a scripting asset (physics and simulation). Included water shaders are just for demonstration - you can use any material you want to actually render you water. So there is totally no trickiness in doing that - it is intended :)
    Edit: This, of course, fully applies only to the material/shader. Some water packages have a whole bunch of their own scripts, and I obviously can't make Dynamic Water 100% compatible with every single one of them. But if Dynamic Water is missing some features, or if there are any problems while interacting with other scripts - it'd be very thankful if you notify me about that, so I can try to fix that.
     
    Last edited: Oct 2, 2013
  33. Sam_Pr

    Sam_Pr

    Joined:
    Aug 23, 2012
    Posts:
    66
    For swimming I'm just trying to do something basic for a fps game.

    Sorry for the noobish questions, and thanks for answering them!

    EDIT: I fixed the error, I feel nooby now, but swimming is still a mystery.
     
    Last edited: Oct 2, 2013
  34. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    What scripts are you using as your FPS controller? Basically, the swimming for FPS is simple:
    • Check if we are submerged into water
    • If "Swim Up" key is pressed, push the player Transform up
    • If "Swim Down" key is pressed, push the player Transform down

    I've made you a simple prototype for a swimming script, but you'll probably have to adapt it to FPS scripts you are using.
    http://pastebin.com/sbz5Eq1u
     
  35. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Sound great! Then I'll put it on my wishlist and grab it soon ;)
     
  36. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Version 1.2 released!

    Changelog:

    • Added Character demo scene.
    • Added underwater fog script.
    • Inverted obstruction geometry (allows to create more complex shapes).
    • Added support for obstruction textures.
    • Added circular waves feature to Advanced Ambient Waves.
    • DynamicWater and SplashZone now support arbitrary transformation
    • Fast normalization redone with much improved quality. It is now recommended and used by default.
    • A lot of workflow and UI improvements.
    • Added some example scripts.
    • Tons of optimization, some heavy methods moved to a native library (only for Windows x86 and Android at the moment).
    • Code cleanup.
    • Various bugfixes.

    Demos and docs will be updated soon.
     
  37. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Demos updated! Check out the new scenes and features :)

    Webplayer demo

    (includes demo scene with Tasharen water)
     
  38. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    congrats on new release

    very nice
     
  39. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
    Awesome job with the update.
     
  40. Streamside7

    Streamside7

    Joined:
    Nov 8, 2013
    Posts:
    9
    Very, very nice! How well does this work on iOS?
     
  41. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    I haven't done performance tests on iOS, but I'm sure it'll work just fine on at least iPhone 4S and higher. For reference, Motorola Droid 2 produces around 50 FPS with 64x64 water mesh, and the performance of that device is around the level of iPhone 3GS-iPhone 4.
     
    Last edited: Nov 8, 2013
  42. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Hi everyone! :)

    Version 1.3 is now available on Asset Store! This is mostly a Unity 4.3 compatibility and bugfix release.

    Changelog:
    • Improved Unity 4.3 compatibility (new Undo system, no more nasty warnings).
    • Fixed DllNotFoundException issue that occured on some installations.
    • Added a menu item to relocate the asset files for JS scripts.
    • Minor fixes.
     
  43. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
  44. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Hi! :)
    That's very easy to fix - MonoDevelop allows to rename classes easily. Just open the FluidVolume.cs script, click on the class name, press F2, rename it to something else, save, and the name conflict should be resolved.
     
  45. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Worked great, looks like The fluidity author will be updating his scripts as well to help this.
    Thanks!
     
  46. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Hi, I'm the author of Fluidity, in order to 'fix the problem stated above I've explicitly used type name qualifiers when accessing inner namespace objects.

    The problem occurs because you have left your 'FluidVolume' in the global namespace, which in C# will override any reference to my 'Fluidity.Volume.FluidVolume' where I don't use the full name.

    I would recommend using namespaces wherever possible in Unity 4 to protect your customers from future problems.
     
  47. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Hi, thanks, yes, I've already made a fix for that, it's being reviewed on Asset Store at the moment. Actually, the only reason why some classes are in global namespace is because Unity 3.x doesn't supports MonoBehaviour's in namespaces. Oh well, had to put a ton of conditional defines in my code, but at least Unity 4 users won't have that problem anymore :)
     
  48. Enuniq

    Enuniq

    Joined:
    Oct 17, 2013
    Posts:
    10
    How good is the underwater system? Any pics? Can I decide to not use the buoyancy system? Sorry, I'm a noob to this. Most of the underwater scenes/systems aren't the greatest.

    Thanks!
     
  49. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Hi,

    there is pretty much no underwater system, as this asset was designed to provide simulation/physics. You could easily use your own underwater effects, but in this asset there is nothing except a simple fog effect, sorry.
    As for the buoyancy system - yes, it is totally separate from the water simulation, so you may just ignore it.
    Hope that helps.

    -Serhii
     
  50. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Hi, this asset looks really great!
    I have only some questions regarding the obstruction of the waves:
    Could I use moving objects as obstruction?
    Is it possible to use a dynamic obstruction texture (render into this texture and change the obstruction dynamically)?