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

Official Water System for the High Definition Render Pipeline

Discussion in 'High Definition Render Pipeline' started by auzaiffe, Nov 26, 2021.

  1. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Yes, the real world assets :)
     
  2. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    The water line is only available since 23.1
     
    chap-unity likes this.
  3. Ziddon

    Ziddon

    Joined:
    Feb 6, 2015
    Posts:
    23
    Hi. I was wondering if there are any plans to make the water system work on a large sphere (like a large spherical planet). I tried this a while back, and the water at steep vertical angles became stretched, and upside down was not visible at all.
     
  4. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    760
    Hey, it's indeed tracked (because it can be cool, I'll admit :p) but not a huge priority right now given the use case! The idea would be to be support planetary radius altogether (like volumetric clouds) but fog doesn't support it yet so we need to do everything together otherwise there will be some discrepencies !
     
  5. Jack_Martison

    Jack_Martison

    Joined:
    Jun 24, 2018
    Posts:
    142
    Sorry but can I leave it there, this is jaw dropping



    I really, REALLY wish someday Unity can compete with such assets, this is not an official feature, but the performance is stunning.
    Also no additional cost of buoyancy, additional vfx, or hacks to make the illusion of waterfall/breaking waves everything works in real time.

    IMO HDRP is much better in visuals, but features provided in Unreal is just amazing.
     
    Amplify_David and chap-unity like this.
  6. Ziddon

    Ziddon

    Joined:
    Feb 6, 2015
    Posts:
    23
    Understandable. Probably not a use case most people need, but it would be awesome for creating fully spherical planets.
     
  7. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    760

    Attached Files:

  8. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Already saw and downloaded it this afternoon. Awesome, thank you very much!!! :)
     
    chap-unity likes this.
  9. seeliespright

    seeliespright

    Joined:
    Jun 29, 2022
    Posts:
    11
    I've been building a deep water ocean swimming system Script and trying to use it with your water system to have my character swim in the ocean while being pushed around by the waves.

    Using AddForce, applied to my character's Rigidbody, I move my character back and forth in the water in an irregular movement, like an ocean current. I'm using yourFitToWaterSurface's searchResult.height for Y, and searchResult.candidateLocation for X and Z position to create a Vector3, and using that Vector3 for AddForce to the Player. To create a more dramatic movement on the X and Z, I multiply those values by 4.

    What I would like to do:

    Is there a way to follow the waves on the surface of the water, moving on the X and Z with the waves, not just matching Y through searchResult.height? Running the simulation, the waves are quite dynamic at a Wind Speed of 44, and I'd like to follow them around the scene.

    Can I access the way the waves are calculated, or maybe the Chaos factor that creates non-linear movement? I'd like a current more complex than the currently available linear current in your Example Scenes if possible.

    I'm not using the latest 2023 version of the Water System, because the alpha program has been unstable as I've experimented with it using your Water Scenes. The 2023 FitToWaterSurface Script seems to operate virtually the same in the searchResult calculations as the earlier version does anyway.

    Many thanks in advance,
    David
     
    Last edited: Jun 10, 2023
  10. rgb_45

    rgb_45

    Joined:
    Sep 5, 2021
    Posts:
    1
    We need water interaction/ripples from player/objects.
     
    Ghosthowl, koirat and bdb400 like this.
  11. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    760
    Hey, it's already possible in 2023 version, you can just spawn deformations and animate them easily.
    We have a demo that works well, hopefully this will land in the sample as well in a few weeks / months.

    upload_2023-6-20_9-30-31.png

    upload_2023-6-20_9-33-25.png
     
    ccfoo242, Kirsche, saskenergy and 9 others like this.
  12. JTAU

    JTAU

    Joined:
    May 12, 2019
    Posts:
    24
    Is there any way to adapt this to URP, or is a URP version planned?

    Considering there was a URP water system in the old Boat Attack project, it's actually surprising that this is HDRP only.

    (Also what water system does the new URP demo use?)
     
  13. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    760
    I agree it would be great to have a streamlined solution for both render pipelines but, as far as I know, for now, nothing is planned to port this on URP side.
     
  14. Jack_Martison

    Jack_Martison

    Joined:
    Jun 24, 2018
    Posts:
    142
    @chap-unity Is there any way to keep buoyancy without additional CPU cost? Or stream it along with GPU? I really would love to use it, but it's just halving my fps
     
  15. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    Currently the only option is to evaluate the simulation at a lower resolution on cpu and ignore ripples, but it's still gonna be fairly expensive
    We are considering adding a cheaper option that has a few frames delay, but no eta and we should also make sure the delay is not too big anyway
     
    chap-unity likes this.
  16. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    Maybe it is better to show another way to do that (i know is not your job) because you are talking about physics simulations and that is pretty expensive for a game, i think most of the users just want a way to do that, they are no exactly talking about simulations IMO.
    Some time ago i did a script with a bouyancy effect for a client and that was perfect
     
  17. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    501
    Can you suggest a way to get the wave height using FFT simulation?
    I'm sure you just did buoyancy stimulation with a constant height without any VRAM texture async reader.
     
  18. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    that is exactly what i did, script calculates the displacement of objects from the water surface and applies a buoyancy force to them. very similar to those hover car scripts from youtube. It has some physics but way more cheaper. Also, i'm not a coder xD
    Now as you asumed my solution i'm going to asume that you think all bouyancy effects you see on games are realtime accurate physics simulations xD
     
  19. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    501
    You didn't understand my post. You can't calculate the buoyancy for waves using only constant height.
    Your boat/ship/buoy will just stand at the same height all time.
    How would you do something like that with constant height?



    Lol, how your script can calculate the displacement of FFT waves in hdrp water? Only way to do that read VRAM textures using "asyc readback"
    Just unity (as any other modern games) calculate waves on GPU, because it's faster, and your script don't have access to this data.
     
  20. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    Yes sorry i realized that after i posted but i was doing something else and i forgot to edit, what i did was something like a hover car effect with a bounce damp and bouyancy force, it was like 10 or less lines of code, i'm going to ask my client if i can share that part of the script, but you will be equal dissappointed because is very basic, my point still is, you do not need 100% accurate physics simulations to do something to looks good in a game, is not need it and it is worst for your game's performance
     
    hugokostic likes this.
  21. Misaki_eKU

    Misaki_eKU

    Joined:
    May 3, 2018
    Posts:
    91
    You can use rigid body and add force to the physics depends on the height change.
     
    chap-unity likes this.
  22. Misaki_eKU

    Misaki_eKU

    Joined:
    May 3, 2018
    Posts:
    91
    What hdrp and almost other game does is recalculate the height on CPU.
     
  23. m4robb

    m4robb

    Joined:
    Aug 2, 2017
    Posts:
    38
    thanks for making this available. Quick question, the ripple effect in the pool scene works in the editor window but not the game view. is there something I have to do to make it work for the game view?
     
  24. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    hum it looks like there is a bug with custom render textures not updating when no scene view is active. You can have a scene view openned when looking at the game view, but i'll file a bug report for that. Thanks
     
    chap-unity likes this.
  25. m4robb

    m4robb

    Joined:
    Aug 2, 2017
    Posts:
    38
    thanks Adrien, I'll stay tuned
     
  26. m4robb

    m4robb

    Joined:
    Aug 2, 2017
    Posts:
    38
    also, is there something that can make the water surface work better in single pass instance while using openxr. It works fine in multi-pass, but worried about the performance.
     
  27. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    501
    I know how buoyancy is calculated, here is my example (0:37).

    The problem is that HDRP uses not just waves along the Y axis, but also waves with an offset along the XZ axis. Because FFT simulation get "offset" map, not a "height map"
    So, using FFT sim you need to look near points to find intersection.
    Here is the example of the problem.
    upload_2023-6-27_20-29-56.png


    Therefore, for correct buoyancy you need to do a CPU loop for 100+ of iterations or use GPU method (offset map -> height map) and use async readback.
    The GPU method can return correct height for 1 iteration, instead of 100+, and you don't need to use CPU fft calculation (with low resolution).
     
    Lars-Steenhoff and Lymdun like this.
  28. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    actually after more investigations it seems to be working when entering play mode, it's just that a game view in non playmode is the same as a scene view without 'always refresh' enabled, so rendertextures don't update until you enter playmode
     
  29. seeliespright

    seeliespright

    Joined:
    Jun 29, 2022
    Posts:
    11
    I didn't hear back on my earlier post, so I wanted to ask the question briefly:

    I would like to have objects on my water surface move with the waves on the X and Z axis. So, not just matching the height, which you guys have provided, or a straight line matching the wind orientation.

    Is there a way to have my boat follow the movement of the waves on the X and Z axis, maybe along the Gerstner wave path that's determining the water surface movement?

    Is there a way to have a combined movement that responds to the 2 horizontal Gerstner wave bands?

    I've moved my character by applying force on the searchResult.candidatePosition vector, and that provides pretty good looking swaying current movement, but that doesn't push my character or my boat with the wave paths. I've also been attempting non-force movement along Cosine wave paths and using your match height.

    I tried to mimic the waves you create in your Gerstner Waves Jobs Script for the 2023 version, but I haven't been successful.

    Am I not understanding how Gerstner waves and/or your simulation works?

    Thanks,
    David

     
  30. MichaelJT

    MichaelJT

    Joined:
    Jan 28, 2015
    Posts:
    14
    How do we sync the waves for multiplayer so everyone sees the same thing?

    Is there a way to get/set the simulation time so we can sync it up?
     
  31. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Please port it
     
    Shizola and chap-unity like this.
  32. m4robb

    m4robb

    Joined:
    Aug 2, 2017
    Posts:
    38
    And so it does (work) in playmode. I could have sworn it wasn't yesterday, but maybe because I just started up the computer for the day. I'll take it for the win. But still wondering about the distortion in single pass VR. works great in multipass, but in single pass it feels like the stereo is misaligned.
     
  33. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    Hey, the script we have provided is an example of how to sample the water height at a point. You can call the function several times around the source location to estimate to normal (3 sample in total are probably enough)
    You can then use the ApplyForce function on your rigidbody to compute buoyancy.

    There are much more than 2 waves in the system, all of them having potentially different directions depending on the chaos value, so there's no 'wave direction' at a point in space
     
    chap-unity likes this.
  34. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    MichaelJT and chap-unity like this.
  35. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    So it should be working. Are you saying objects you see through water thanks to refraction are weird in single pass ? if that's the case can you please file a bug ?
     
  36. m4robb

    m4robb

    Joined:
    Aug 2, 2017
    Posts:
    38
    Bug report is filed at IN-45822
     
    Last edited: Jun 29, 2023
  37. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    851
  38. seeliespright

    seeliespright

    Joined:
    Jun 29, 2022
    Posts:
    11
    Thank you! That explains a lot. And, I forgot to say: Your waves simulation and associated scripting are awesome looking and behaving. Thanks again.
     
    adrien-de-tocqueville likes this.
  39. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    Qleenie likes this.
  40. MichaelJT

    MichaelJT

    Joined:
    Jan 28, 2015
    Posts:
    14
  41. MichaelJT

    MichaelJT

    Joined:
    Jan 28, 2015
    Posts:
    14
  42. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    Currently, if you run unity in headless mode, water isn't calculated at all. The issue is that deformers require a gpu to be computed, so if we were to run the cpu simulation on a server, you wouldn't have deformers working.
     
  43. shikhrr

    shikhrr

    Joined:
    Nov 19, 2013
    Posts:
    68
    Just tested the water, and it looks great. I would like to thank the developers for adding this to HDRP. I just hope the integration between different systems like spline, terrain, and water happens in the future.
     
  44. MichaelJT

    MichaelJT

    Joined:
    Jan 28, 2015
    Posts:
    14
    So if I run the simulation for a water surface on the server with no deformers I'll be able to use that without issue, but as soon as I add any deformers I'll have to find another solution?
     
  45. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    260
    Well currently it won't work at all, but the max we could do would be to have the regular simulation. Supporting deformers is not possible without gpu (and about water mask and current maps i am not sure. I would expect them to not be available since they are gpu resources)
     
  46. JumpingGuy

    JumpingGuy

    Joined:
    Jan 2, 2016
    Posts:
    69
    Is there a way to get foam working in 2022.2 LTS?
    * Specifically I am interested in shoreline foam for 2022.2
    I got it working in 2023 but need it to work with 2022 / HDRP 14
     
    Last edited: Jul 7, 2023
  47. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Out of curiosity, any chance to separate the water mask and water current outside the water component settings? ie similar to WaterDeformer but behave as a water simulation mask and water current projector? with possibilities to set water color too?
     
  48. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,612
    Do you need Unity 2023 to access the water example scenes? I have 2022.3.4f1 installed (HDRP 14.0.8) and I do not see the water samples in the "samples" tab.
     
  49. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    760
    Yes, they won't be backported because of all the "missing" part of the water system in 2022 :).

    Same for the github sample
     
    kdgalla likes this.
  50. m4robb

    m4robb

    Joined:
    Aug 2, 2017
    Posts:
    38
    hi Adrien, I the bug seems to be still under review. In the meantime is there any way I can hotwire a custom water system material shader graph to work with single pass instanced? multi-pass grinds to slow more often than not. Currently on 2023.1.f3, thanks