Search Unity

Physics Dynamic Water Physics - Realistic. Fast. Universal.

Discussion in 'Tools In Progress' started by NWHCoding, Apr 21, 2017.

?

Which water asset do you use with DWP?

  1. Crest

    112 vote(s)
    54.9%
  2. AQUAS

    15 vote(s)
    7.4%
  3. RAM

    17 vote(s)
    8.3%
  4. Ocean Community Next Gen

    6 vote(s)
    2.9%
  5. Ceto

    4 vote(s)
    2.0%
  6. SUIMONO

    7 vote(s)
    3.4%
  7. Ultimate Water System

    6 vote(s)
    2.9%
  8. Other Flat Water Asset

    8 vote(s)
    3.9%
  9. Other Water Asset With Waves

    29 vote(s)
    14.2%
  1. 3dship

    3dship

    Joined:
    Jun 17, 2017
    Posts:
    7
    I would like to thank you for new version of the DWP

    my request is just digital rpm indicators for each control unit
     
    jbb1979 likes this.
  2. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    Please, don't bloat this asset with unnessecary features - this is a water physics not a build your own ship game asset.

    Features that are physics related like sinking ships etc. are awesome, but enabling, disabling controls or switching to first person are features that probably <1% of your users need or want and really shouldn't be in there - in my opinion
     
    jbb1979 likes this.
  3. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I can go with that.
    I agree that it needs to be streamlined to cause as little FPS drop as possible.
     
    jbb1979 likes this.
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Water physics are still the focus of the asset and this is where the most changes will be. About 95% of the code (actually, all the code except for mesh decimation library) related to the water physics has been rewritten to take advantage of Unity's job system, while the ship controller part is in a different namespace with only parts of the code changed from DWP1. There will be some highly requested features such as engine start/stop and input improvements, along with some ideas from the previous page, but those have no influence on the water physics part.

    Sinking and the like will not be calculated on mesh basis (not only that would be problematic but would tank the performance as a lot of cases would need to be checked, and it would be far from universal). It will be quite similar to what it is now (COM shift, mass increase) but with some improvements - so just a gross estimate.

    Expect this to be 80% water physics update, 20% ship sim update. You are correct that this is water physics asset and not a game template for a ship simulator. It is just that the demand is quite high for the simulator part so I can not just ignore it.
     
  5. xDeveloper

    xDeveloper

    Joined:
    Sep 27, 2015
    Posts:
    10
    1. Idea from me: what about support physics for https://en.wikipedia.org/wiki/Hydrofoil?

    2. A modest question follows from my idea: you created good assets for ground (cars) and water, but what about air and aircrafts?
     
    jbb1979 likes this.
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    1. There seems to be a misunderstanding about DWP and what it does. Long story short you can do Hydrofoils in DWP as-is. That is the whole point of mesh-based solution - it is not just a ship hull that works. Of course, it is an approximation and will not be 100% accurate but it will work well with some tweaking of the size of the foils.

    2. Heh, you guessed it. This is a video of mine from a year ago:

    At the moment there are no plans to release this as an asset since I am working on a game that the physics as the main element of the game. Actually, the same game is where the idea for DWP2 and job system originated as there will be waterplanes. At the moment game is pre-alpha so I can not share any more info, the video above is just a test with a 1:1 model I used to validate aerodynamics and compare behavior to FSX and XPlane.
     
    jbb1979 and dsilverthorn like this.
  7. xDeveloper

    xDeveloper

    Joined:
    Sep 27, 2015
    Posts:
    10
    It looks interesting and promising. I wish you good luck in the development of the game! And I hope that you will share news about this game in the future, as well as see this asset in the Unity store. ;)
     
    jbb1979 and dsilverthorn like this.
  8. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    PlayMaker integration would be nice.
     
    jbb1979 likes this.
  9. cabanel

    cabanel

    Joined:
    Sep 22, 2014
    Posts:
    68
    quando sarà disponibile DWP2?
     
    jbb1979 likes this.
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Just a preview of the new WaterObject inspector:

    upload_2019-5-19_16-58-3.png
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I have added a poll to the thread to get the feel for which water asset people are using with DWP the most.
     
    jbb1979 likes this.
  12. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I use Aquas but am transitioning to Weather Maker which has a nice wave water and is being updated regularly. Weather maker is also getting an overhaul right now on the water to make it much better.
    Please check them out, this one could end up better than most. And it is pretty good right now.
     
    jbb1979 and Wim-Wouters like this.
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I do have a licence for Weather Maker, just was not aware of the waves being implemented. Will wait for the overhaul to complete and then add support for it.
     
    jbb1979 and Wim-Wouters like this.
  14. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Cool. Weather maker water is looking pretty good. The dev says that a much better is in the works and coming. :)

    Glad you will include it.
     
    jbb1979 likes this.
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    If you have not already, please vote in the poll at the start of the thread for your preferred water asset.
     
    jbb1979 likes this.
  16. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I'm using DWP and Playmaker, but cannot figure out how to switch from the boats into first person to walk ashore.

    Does anyone have any ideas on how to do this?
    I've only used a small script in the past to get in and out of cars, but the boats are a new thing I'm trying to work out.

    I appreciate any pointers.
     
    jbb1979 likes this.
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Since at the moment ships do not have a turn-off function, you just need to switch to the player camera and disable the "Advanced Ship Controller" script on the boat and the boat's camera. Check the Changer.cs script.
     
    jbb1979 and dsilverthorn like this.
  18. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Excellent!
    I will give it a try.
    Thank you very much!!
     
    jbb1979 likes this.
  19. MCPGNZ

    MCPGNZ

    Joined:
    Sep 29, 2016
    Posts:
    42
    Hi,

    First of all, great plugin!
    We're currently using it in our project and I had to optimize few internal things.
    I think at least some of them could be integrated into the plugin itself.

    • WaterLine and BuoyTri could be made structs - this way the arrays are compacted in memory and adding new objects to WaterLine does not allocate memory on heap
    • BuoyTri.Set normalizes gravity vector in each call, this could be precalculated, stored in FloatingObject and passed to the Set function (Physics.gravity could be stored too, as we do not know what is the real cost of the Physics getter) (this assumes that gravity will be constant across the gameplay - so if it's not the case - you could provide some settings checkbox to disable said caching)
    • FloatingObject.GenerateSplitMesh checks if the WaterHeightFunction is set to default (GetWaterHeightFlatSurface) - delegate comparison allocates memory - this could be mitigated by just simple bool variable that is set when the default function changes, and then checking this instead of delegate comparison
    • FloatingObject.FixedUpdate uses multiple calls to transform.position - you can use t variable and further cache position at the start of the method - this way you don't need to call position getter multiple times.
    • FloatingObject.GenerateSimplifiedMesh declares three local variables that are not used in the method
    • FloatingObject.GenerateSplitMesh can inline GetDistanceToSurface like it does for flat case
    Cheers,
    MCPGNZ
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    DWP2 is in the making at the moment and will be out sometime next month. It features a complete code rewrite and a move to job system so the things above will not be fixed (directly). Check the previous posts for more info on the update.
     
    Bartolomeus755 likes this.
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    A quick update on the progress of DWP2. There has been some serious optimization over the last few days and I have managed to get it to about as fast as it will get as the bottleneck now is setting the array values and this can not be optimized much since Array.Fill() is only in preview for .NET 2.1. Note that the performance below is with water effects enabled and all data read-backs from the job system.

    upload_2019-5-23_15-58-20.png

    So about half a milisecond for 874 simulated tris on 31 objects with 0B of memory allocations. That should be enough for 10-20 boats/ships (depending on quality required), or about 30-40 floating props.

    One more change that is happening at the moment is a complete rewrite of Water Effects which now will use Unity's Particle System with manual particle emission. Effects will look about the same but expect drastic performance improvements in that aspect due to the fact that Unity's particle system consists mostly of native code and is very well optimized.
     
    Mohamed-Anis, MCPGNZ and dsilverthorn like this.
  22. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    That did the trick! Works like a charm!

    Thanks for pointing me in the right direction.

    David
     
    jbb1979 and NWHCoding like this.
  23. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    @NWH Coding

    Do you think DWP could be used to make the character swim and dive?

    I was thinking it would be nice to be able to boat out to underwater ruins or a shipwreck and dive down scuba style to explore underwater. Kind of like the submarine but without the submarine.

    Can it be modified to work this way?
     
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Yes, and quite easily. The physics already work underwater and if you were to make the character grab to one of those underwater jet thingies (swimming would be hard to replicate) and set the total density to match that of water, combined with some type of control for steering you could actually move as if the gravity did not exist.
     
    dsilverthorn likes this.
  25. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I'll play around with it and see if I can work it out.

    Thanks!
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I have decided to replicate the ship video using DWP2 and here is the result:

     
  27. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Hi, does this work with LUX Water?
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Not yet but have purchased both it, RAM and WeatherMaker so it will on release of DWP2.

    EDIT: Support for Lux has been added to DWP2.
     
    Last edited: May 28, 2019
    dsilverthorn and web76 like this.
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Did some work on WaterDataProvider (replacement for WaterInterface from DWP1) and implemented Lux Water support this afternoon. Here is the result.

     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    DWP2 progress update:
    Most of the small tweaks have been finished and bugs ironed out.
    There have a few improvements to the ShipController: added Activate/Deactivate functions, engine Start/Stop including - optional - start and stop sounds, anchor, improved submarine water height and API improvements.
    Currently in the making are documentation, videos, images, etc. and after that is done DWP2 will be submitted to the Asset Store. So estimate for submission is middle of this week. Add to that a week or two for the asset to get approved and so the estimate release date is middle of this month. Could be sooner but that depends on Unity folk doing the review process.
     
    Last edited: Jun 1, 2019
    web76, obstudio, Vincent454 and 4 others like this.
  31. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    How is DWP2 coming along?
    Really looking forward to seeing it in action. :)
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    It has been delayed by a few days, but the code base and documentation are done. Working on the meta at the moment and as soon as that is done it is going to the store. Sorry for the delay - it really was not planned.
     
    Vincent454 and dsilverthorn like this.
  33. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Sounds good!
    Don’t rush it out or it might hurt your sales;)
    We want to keep you around for a long time!

    Looking forward to the release to see what you have added to make it better than DWP:)
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    There will not be much added as it is a rewrite. Expect about the same functionality but better and faster, and a general step up in quality. Also, a lot of creature comforts were added to make setup and use easier.
    In total over two months of work went into it and hopefully it will not disappoint as I did my best. It could have been out much earlier but I have been going over all the details and possible uses, not to mention over a week worth of optimization (at the moment I am running 97 objects in the demo scene at decent resolution with foam enabled which results in 1.2ms of CPU time, so I think that part was worth it).
    I am finishing things up at the moment and will push tomorrow morning.
     
    dsilverthorn and Vincent454 like this.
  35. SpeedySpike

    SpeedySpike

    Joined:
    Jun 27, 2016
    Posts:
    5
    Just wondering if you could simulate a steamboat (with a rotating set of paddles) with this?
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Yes, there should be no problem there. The demo scene is using WaterObjects (previously named FloatingObjects) for rudders on all ships and you can use it for oars too.

    Also, DWP2 has been submitted on Saturday and is waiting for approval.
     
  37. SpeedySpike

    SpeedySpike

    Joined:
    Jun 27, 2016
    Posts:
    5
    Ok that's what I thought, I just wanted to confirm!
     
  38. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Is there a demo on how a row boat would be set up?
    So that when you pull the oars the speeds up and slows until you pull the oars again.
     
  39. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    What about a pulse of force that works on the object itself..two on each side..
     
    dsilverthorn likes this.
  40. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    That sounds right!:)
    But I don't know how to accomplish it.:confused:
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Good idea, and quite simple.
    I assume you have some kind of animation or rotation on your object.
    I would suggest something like this:
    Code (CSharp):
    1. if(myCondition)
    2. {
    3.      myRigidbody.AddForceAtPosition(myForce, transform.TransformPosition(myLocalForcePosition));
    4. }
    This is just simplified example code that you would attach to your ship object.
    'myCondition' would be if the paddles are rotating (you could also multiply 'myForce' with the speed of padle rotation) or in case of oars if oars are underwater and moving.
    'myForce' would just a constant that is possibly multiplied by some value such as paddle wheel rotation speed or oar speed - depends on your specific implementation.
    'myLocalForcePosition' wold be a Vector3 that you can draw in gizmos to show the point at which the force will be applied, e.g.
    Gizmos.DrawSphere(transform.TransformPosition(myLocalForcePosition, 0.1f);
    Note that myLocalForcePosition needs to be local so it keeps the position relative to the boat.
    If you have oars you would do the above for each oar. Hopefully this helps some.
     
    dsilverthorn likes this.
  42. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I'll see if I can do anything with that. I think I understand it a little, but I do really appreciate it. My talents are more on the art side, but I'll give it a try. Still creating the scenery and landscapes, so I'll be looking forward to seeing if I can make it happen. Good to know it's possible and not too difficult. :)
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Dynamic Water Physics 2 has been approved. I will release it tomorrow morning (Europe time, about 14 hours from now) so that I can fix any bugs and issues that arise, and answer any questions that you might have as fast as possible over the day.
     
    Vincent454, 3dship and dsilverthorn like this.
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Dynamic Water Physics 2 is out.

    There is a new forum thread here: DWP2 Forum

     
  45. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, I'm currently using DWP1 and I would like to ask you something before I upgrade to DWP2.

    In DWP1, I find that there are GC issues. FloatingObject.FixedUpdate() is making 2.8KB garbages at every frame. The problem is GenerateSplitMesh(). Commenting GenerateSplitMesh out will not generate garbage and the execution time will decrease to 0.02ms from 0.38ms. I think GenerateSplitMesh has both GC and performance problem. From what I read in DWP2 descriptions, each floating object takes about 0.02ms. Does that include (new) GenerateSplitMesh()?

    Many thanks.

    upload_2019-8-15_2-51-11.png
     
  46. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Above is when I'm not riding the boat but while the boat is resting and it gets worse when you drive the boat.
    FloatingObject.FixedUpdate garbage increases to 8.7KB and the execution time increases to 0.74 ms.

    And there is bigger problem when you riding the boat. As I indicated below, WaterFX.LateUpdate generates 16.9KB garbage and the execution time is 3.12.

    Could you please let me know if they have been fixed/improved in DWP2?

    Cheers!

    upload_2019-8-15_3-23-27.png
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    all the code in question has been completely rewritten and there is actually no new GenerateSplitMesh() and also no per-frame GC. Only time there will be some GC is when new objects are added and job's native arrays need to be reallocated.
     
    dsilverthorn likes this.
  48. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Awesome! It's great to know and I'm glad I asked. I'll upgrade to the new version and let you know if there are issues. I also own NWH Vehicle Physics and I expect the similar result with V2.0. ^^ Thanks.
     
  49. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Yep, NWH Vehicle Physics is also under a major rewrite following in the DWP2's footsteps.
    Hopefully the update goes well for you, I tried to make it somewhat painless :)
     
    dsilverthorn likes this.
  50. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, I just upgraded to DWP2 but I don't see much differences in terms of performance and memory garbages.
    Here are the profiling results from both DWP1 and DWP2 running the Demo scene while riding(generating WaterFx) on Racer.

    When resting, both DWP2 and DWP1 is frame rate is about the same, 200fps, and when riding, DWP1 fps drops to about 150fps while DWP2 is maintainng fps at 200fps.

    My current conclusion is that in terms of memory garbage, DWP1 and DWP2 is about the same and DWP2 is little bit better when riding the boat.

    I'm more worried about the garbage it generates and it's quite large for each frame. I appreciate if you can take a look why it's generating such large garbages.
    Thanks.

    upload_2019-8-15_22-22-50.png
    upload_2019-8-15_22-24-55.png