Search Unity

  1. 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. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Hey, the buoyancy script in the samples is just an example to show you how to get information to do your custom things.
    Buoyancy is a complicated subject so we have to cut corners and/or make assomptions.

    In this example, the main assomption is the object is a sphere, so it's simple to calculate the displaced volume of water.. etc

    As a result, It should work with a reasonably scaled spheroïd but as soon as you start to stick it to a complex shape with a huge mass etc.. things start to break down and this is where you have to modify it to fit your custom needs :)
     
  2. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Hi guys at Unity,

    I can see that your deformation code in WaterUtilities.hlsl only adds the vertical deformation to the displacement.

    Code (CSharp):
    1. #if defined(SUPPORT_WATER_DEFORMATION)
    2.     // Apply the deformation data
    3.     float3 positionAWS = GetAbsolutePositionWS(positionRWS).xyz;
    4.     float3 displacedPosition = positionAWS + displacementData.displacement;
    5.     float2 deformationUV = (displacedPosition.xz - _WaterDeformationCenter) / _WaterDeformationExtent + 0.5f;
    6.     float verticalDeformation = SAMPLE_TEXTURE2D_LOD(_WaterDeformationBuffer, s_linear_clamp_sampler, deformationUV, 0);
    7.     displacementData.displacement += float3(0.0, verticalDeformation, 0.0);
    8.     displacementData.lowFrequencyHeight += verticalDeformation;
    9. #endif
    Just throwing it out there, but any chance you might consider extending that to allow deformation in all three axis? We've currently got a wave simulation done with breaking waves, and we'd really like to upgrade from a custom implementation in Unity 2021, to utilising this ocean system in 2023.2. I'd rather not go down the path of creating individual shaders for minor tweaks if possible. I'm pretty sure I wouldn't be the only one that'd like to get some breaking waves in, even if it's just to update the Shore Waves.
     
  3. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,092
    Is it possible to have the water rendered with the excluders like eg a window on a boat? I tried the demo scene, but couldn't achieve what I'm looking for.

    Basically it's this:


    ie having a mesh and have the water rendered outside of a mesh. In the video the mesh is a tube.

    Would be the same for eg a window on a boat, a submarine or eg an aquarium.
     
  4. MoruganKodi

    MoruganKodi

    Joined:
    Feb 11, 2015
    Posts:
    77

    One key element I would like to be able to do with any water systems is to be able to sample an accurate wave height on the CPU (or in Physics) - not just be a visual effect.

    Is this possible (specifically, I would be interested in being able to sample an accurate wave height for the infinite plane)
    - For phsyics (boats)
    - For Physics (collisions - eg - bullets), etc.
     
  5. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    We don't currently support this because the waterline always intersect with the near camera plane, meaning if you want to look at the water surface from a glass tube, sphere or a porthole you won't be able to get an accurate water line.

    However, with excluders you will be able to create a dry room going underwater and rendering will be fine (caustics will render, absorption etc).

    Let me know if it's unclear.
     
    Rowlan likes this.
  6. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    You might want to look at this documentation page, it should contain what you are looking for.

    In latest version, the default is using the result of the GPU simulation so you can an accurate result but with a few frames delay, but you can trade a few ms of computation and still use the CPU simulation (with a few caveats) to have the exact result from this frame if it's critical to your setup.
     
  7. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Hey, thanks for the suggestion, it's currently being evaluated.
    It is possible, it's just a matter of making sure it won't cause any unexpected issue, I'll keep you posted!

    Can you give more information about your usecase? You just want to create custom waves using deformation on the water surface not only vertically but also by using horizontal displacement?
     
  8. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Yeah, sure. We're in an "exploratory" phase at the moment. The new Water System has a number of nice features, and at the moment, we could retrofit our earlier system, or move to the new. The result we currently have is this:


    This is using displacement data that was rendered out from Houdini.

    So as I type, I'm in the process of taking the custom code reading the displacement, and creating custom Shader Graph nodes. It's a bit of a brute force attempt at injecting the data, using your example "Island" scene, with each step trying to ascertain the viability of the system and all the moving pieces. As I said, this is mostly exploratory at this stage. I've also come across a couple of further questions I'll need to work out as well, such as when the waterline is visible on the screen (I assume the waterline interacting with the camera's near plane...?), we get the underwater view triggering for everything under that line, but when I've got a large vertex displaced wave, the underwater rendering will shut off when the camera is higher than the "sea level", leaving us seeing through to the ocean floor unshaded. This also happens when I used your Sphere Deformer. I'll work it out (unless you want to throw me a bone in regards to changing the "sea level" dynamically in these cases :))but these are just a couple of the things we're trying to work through.

    Here's a gif of the Sphere Deformer also sometimes losing the underwater renderer when the water level falls.
    DeformedUnderwater.gif
     
    Last edited: Dec 5, 2023
    chap-unity likes this.
  9. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    You should use the 'Volume Height' parameter in the underwater section to tell the system how high it should consider underwater
     
    chap-unity likes this.
  10. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Hi @adrien-de-tocqueville, thanks for your response. Could I ask for a little more information? I did a test, by grabbing a texture and trying both plugging in to vertex Displacement and Position, and both had the same result. I had set the "Volume Height" to 10,000.

    Camera height ~5.5m
    upload_2023-12-6_10-2-14.png

    Camera height ~6m
    upload_2023-12-6_10-2-23.png

    It's evident injecting the texture data directly in to the final Displacement (or Position) doesn't work. So I traced it back, and, correct me if I'm wrong, but it looks like the waterline is actually calculated in a crazily named WaterLine compute shader...

    A couple things I'm going through in my mind - in an attempt top make this work, is it better to try and tackle the _WaterDisplacementBuffer or the _WaterLine?
     
    Last edited: Dec 6, 2023
  11. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    Ok took a closer look and it seems to be a 'by design' bug. It's kinda difficult to compute a waterline that works in all situations efficiently, so the one we have now is just an approximation. If the issue you have is what i reproed, then it's not related to the height of the camera, it's just that the water line is screenspace and when there is very large discontinuities in the water line then it doesn't work. In your case the issue is that left of the screen, the waterline is below the screen, and on the right it's above the screen, and i haven't found how to handle that efficiently
    It's actually pretty easy to make it fail with weird settings, but hopefully that shouldn't be cases that would ever happen in a game. I agree your case could be relevant, but it's not supported for now upload_2023-12-6_11-49-11.png
     
  12. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Thanks @adrien-de-tocqueville. I spent some time trying to gauge what's happening here. One thing I seemed to notice is that no matter how I displaced the vertexes, the WaterLine seemed to be calculating the values as if it were the old vertex positions. So in the following example, where there's a fairly uniform displacement across the screen, the underwater still wouldn't trigger until the waterline would have been visible if the vertexes hadn't been displaced.

    The following image shows where I would have expected the waterline to be, but it only triggers when I get down to about ocean level, and thus the original waterline would have been visible on screen.
    upload_2023-12-6_22-51-2.png


    I was wondering if it might have had something to do with the Shader Graph and depth texture issue, as per this post? Or possibly that the waterline is being calculated before the displacement takes place.

    I'll have to take a look at this again tomorrow with a fresh set of eyes. But again, thanks for looking in to this for me, and if there's any other useful bits of information you could throw my way, I'd be massively grateful.
     

    Attached Files:

  13. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    Are you displacing the water from the shadergraph or using a deformer ?
    In both cases the water line computation is the same as it analyzes the depth buffer (which is obviously written as you see the water). If it doesn't work then i assume the waterline shader isn't dispatched from CPU, you can check if that's the case either by doing something like a renderdoc capture and see if there's a waterline pass or if you have a local clone of the repo check that EvaluateUnderWaterSurface in HDRenderPipeline.WaterSystem.Underwater.cs correctly finds your ocean as the surface for which to evaluate underwater
     
  14. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Hi @adrien-de-tocqueville, to answer your first question, I'm currently displacing the water surface through the ShaderGraph.

    In the image, I'm reading in a single channel (red) to displace the height of the surface. Thee's two sections, that represent two separate attempts. Section A was the first run at it. A1 was used when trying to displace the vertex by Position, and A2 was used when trying to displace by Displacement.

    Section B used a custom node, which was essentially "Evaluate Water Displacement", to which I simply added in the extra wave displacement values:
    Code (CSharp):
    1. #if defined(SUPPORT_WATER_DEFORMATION)
    2.     // Apply the deformation data
    3.     float3 positionAWS = GetAbsolutePositionWS(positionRWS).xyz;
    4.     float3 displacedPosition = positionAWS + displacementData.displacement;
    5.     float2 deformationUV = (displacedPosition.xz - _WaterDeformationCenter) / _WaterDeformationExtent + 0.5f;
    6.     float verticalDeformation = SAMPLE_TEXTURE2D_LOD(_WaterDeformationBuffer, s_linear_clamp_sampler, deformationUV, 0);
    7.     displacementData.displacement += float3(0.0, verticalDeformation, 0.0);
    8.     displacementData.lowFrequencyHeight += verticalDeformation;
    9. #endif
    10.  
    11.     // The new waveDisplacement code. All two lines of it.
    12.     displacementData.displacement += waveDisplacement;
    13.     displacementData.lowFrequencyHeight += waveDisplacement.y;
    14.    
    15.     // Make sure the low frequency is packed
    16.     displacementData.lowFrequencyHeight = PackLowFrequencyHeight(displacementData.lowFrequencyHeight);
    upload_2023-12-7_8-9-55.png

    I haven't made some obvious mistake have I?
     
  15. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    Ok i see, so unfortunately we rely a lot on 'GetWaterCameraHeight()' for the waterline, which takes into account water deformation and deformers, but not custom shadergraphs. I'd like to be able to generate a compute shader from the shadergraph to be able to evaluate that but that's for a future improvement.
    So only workaround for now is either use deformers, or modify HDRP to put your displacement code inside WaterEvaluation.compute that computes if the camera is below the water line :(
     
    VOTRUBEC and chap-unity like this.
  16. ravenmdt

    ravenmdt

    Joined:
    Mar 14, 2023
    Posts:
    2
    No need to leave the editor for a flow map turns our! Figured out a way to sample points on the water volume in relation to a spline that represents a current, and do some vector to / tangent lerping. All data stored per pixel in a texture and done. Its very fun messing around with the water system!

    I guess the next step is following the same principle to generate a foam map for the sides of a river (following the current spline and shooting raycasts perpendicular to it) or just lay out a spline manually that follows the contours and generate a texture from that... Any thoughts?
     
  17. ravenmdt

    ravenmdt

    Joined:
    Mar 14, 2023
    Posts:
    2
    @chap-unity I'm sampling wave height in script with the goal to pass data to the graphics buffer of a VFX graph to generate water splashes at the peak of waves. I've noticed the few frames delay in sampling water height. I'm a bit confused about 'but you can trade a few ms of computation and still use the CPU simulation(with a few caveats) to have the exact result from this frame'. Confirm there is a way to get frame accurate wave heights? I've referenced the documentation page that you posted and looked through the settings in the editor and of the water search parameters / results but I've got no leads. Could you help me in the right direction how to achieve this?

    Edit: I've enabled low latency, full resolution in the editor and implemented the '
    Multiple objects (with Burst)' method to sample height. Unfortunately my generated gizmos still have a delta with regard to the water surface. I've posted a screenshot showing the Gizmos. Obviously it's a still from a moving frame but there seems to be a latency still. Hence the question about getting exact result from this frame.


    Thanks in advance!

    Edit2: Turns out that when using a shore wave water deformer the position updates frame perfect. Looks so nice! Am I doing something wrong with the regular water motion due to wind effect I wonder?
     
    Last edited: Jan 1, 2024
  18. unity_z_R0bT96Yn_9uA

    unity_z_R0bT96Yn_9uA

    Joined:
    Dec 15, 2018
    Posts:
    2
    I was also trying to achieve this and gave up. With the current excluders I was not able to create submarines with portholes, underwater stations etc.. The excluder only works well if the camera is over the waterline and you don't want to render water at all (like the boat in the Island sample scene).

    I tried to create a VR game where the player is sitting inside a submarine. The plan was to have a waterline on the window/porthole (instead of the camera plane) while submerging. I'll go with a DPV (diver propulsion vehicle) now to work around this ;-)

    In future it would be great to have sth. like excluder volumes.
     
  19. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    173
    If i use Water System with the following code, this error occurs.
    (in RenderPipelineManager.endCameraRendering)
    Code (CSharp):
    1. screenShotTex2D = new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, false);
    2. screenShotTex2D.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
    3. screenShotTex2D.Apply();
    [d3d11] attempting to ReadPixels outside of RenderTexture bounds! Reading (0, 0, 2560, 1440) from (1024, 1024)

    Default Water Surface values can reproduce the problem

    What's the problem?
    How can I screen capture when using Water?
     
  20. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
  21. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    173
    Yes I used the following method
    1)
    ScreenCapture.CaptureScreenshot("SomeLevel.png");
    This works. The image is saved to a file just fine
    But it still has a problem
    It gives a different result than using ReadPixels in RenderPipelineManager.endCameraRendering.
    (UI is included in the screenshot)
    Of course, this is a problem that can be bypassed by temporarily adjusting the camera's layer.
    But it's not very clean, and even for a single frame, the flicker is visible.
    I also don't think it's suitable for its original purpose of being used directly as a texture in-game.

    2) ScreenCapture.CaptureScreenshotAsTexture
    I can't get a normal result.
    I tried to make it work through the WaitForEndOfFrame(); coroutine, but I still can't get a normal result.
    Similar to using the ReadPixels way, it doesn't work correctly
    I'm worried that I'm using something incorrectly.
    Have you tried this and does it output the results normally?
     
  22. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    173
    water.gif
    And another Bug
    (completely different from the ReadPixels issue mentioned above)
    The reproduction is simple
    1. Create Water
    2. Check Under Water Option
    If you come out from under the water, like in the gif, the under water will start affecting the entire scene.
    But if it comes out above the water, it's fine.
    Even this is a Local Volume
    Actually for me this became a problem.
    my camera was teleporting at runtime, and even where there was no water,
    some of the water was still being rendered and affecting the scene
     
  23. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Hey, having low latency (so running the simulation on the CPU) and at full resolution is already the max you can do in terms of accuracy as of right now.

    However, you are right that there still might be some discrepancies since it's pretty complicated to make sure the Update in the C# are executed at the exact same time of the simulation, so if it's really an issue for you (and not just a gizmo problem) we can have a look and see if there's an acceptable solution for this on our side.
    Let me know.
     
  24. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Thank you for this, on my side, I wasn't able to reproduce this easily. Whenever the camera gets outside the collider it should default to "over water". If you still think you have an issue, please report a bug with the unity bug reporter and someone on our side will have a look.
    Thanks :)
     
  25. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    173
    Okay, I just reported that bug(IN-65409)

    And can I ask you about this issue as well?
    https://forum.unity.com/threads/wat...-render-pipeline.1203751/page-14#post-9566584
    I couldn't solve the problem even when using the ScreenCapture API (ScreenCapture.CaptureScreenshotAsTexture)

    Is there reason why using the Water System would cause problems
    with the ReadPixels or ScreenCapture APIs?
    ScreenCapture.CaptureScreenshot("SomeLevel.png");
    saving to a file works fine. good.
    However, if Water is enabled, ReadPixels or CaptureScreenshotAsTexture will have problems.
    they seem to work fine when Water is off :(
     
    chap-unity likes this.
  26. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
  27. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    173
    upload_2024-1-10_1-18-8.png

    After some testing, I'm pretty sure this is a problem with the water system.
    Caustics is the cause of this
    The last number to come up in this error is the Water Caustics Resolution.
    In fact, the problem occurs when Caustics is turned on.
    When Caustics is turned off, the problem goes away.

    Does that error also occur when the water system is off and is the problem reproducible?
    I'm not sure how it differs from what I'm using.
    So is it a problem with ReadPixels or the CaptureScreen API itself?
     
  28. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Yes, that was my main reason to why it's probably something "bigger" than the water system and the water system might be impacted by this larger issue I would believe. If you can manage to report a bug using the editor that would be awesome!
     
  29. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    173
    When testing, did you test with both the scene view and game view visible?
    Like in this image?
    upload_2024-1-11_8-48-22.png
    If so, it will throw the same error.
    But you can get around that by keeping only one View.

    upload_2024-1-11_8-48-47.png

    Of course, this is a bug in the editor itself.
    I held off on reporting it because I didn't see it in the build,
    and it's a workaround in the editor,
    (I don't know if it's already a known issue)
    Anyway, it can be bypassed by keeping only one view.

    The problem is that this temporarily solved the problem,
    but when I use Caustics, it happens again.
    And the number the error is talking about is the Resolution number for Caustics.


    +
    If I understand correctly from the responses on this issue,

    https://issuetracker.unity3d.com/is...when-entering-the-play-mode-on-a-hdrp-project

    Isn't the problem due to the order of the rendering process of ReadPixels and Water after EndCameraRenderCallback?

    ReadPixels is recommended to be used via the EndCameraRenderCallback.
    (Official document / Unity answers to other related issues)
    However, this seems to be a problem with water.

    There are other reasons why i want to use ReadPixels
    https://discussions.unity.com/t/scr...making-a-milky-white-tinted-screenshot/226341
    https://issuetracker.unity3d.com/is...righter-when-the-color-space-is-set-to-linear

    Anyway.
    I will going to pass on this issue as an unsatisfactory workaround.
    (Using ScreenCapture.CaptureScreenshotAsTexture / copied the result to another texture for Color Space Bug)
    I understand this is a Water thread. I'll stop posting about this issue here.

    seem to be able to reproduce the issue well and have communicated the relevant information well.
    If there's a better way, or if you need something from me, feel free to let me know :)
     
    chap-unity likes this.
  30. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    I didn't take a look at the case myself but seeing the resolution fo the bug report, i think you are missing something like a call to CoreUtils.SetRenderTarget before using readpixels to ensure you are reading from the correct texture
     
    seoyeon222222 likes this.
  31. akshit1008

    akshit1008

    Joined:
    Jun 7, 2023
    Posts:
    1
    Hey there! I was trying to incorporate the FitToWater method in my own class method and I was facing the same issue as JRW_WSP. I've created a new question regarding this but mainly I was trying to understand how these methods work and I cannot find the related documentation. Could you have a look at my question on this link: Using WaterSearchParameters and WaterSearchResults to get distance from water - Questions & Answers - Unity Discussions and just explain how this Method works so that I can check if there's something wrong with my usage? Alternatively, I'd grateful if you could share the documentation link.

    Cheers! :)
     
    chap-unity likes this.
  32. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Hi gang, has anyone had the Water Surface stop responding when they used 'simulationStart'? As soon as I try and set a time, the water system stops, but not completely. If I select other items in the hierarchy, the water system will step forward what looks like one frame worth of simulation, and then stop again. I'm not discounting it's something I'm doing wrong, but the documentation doesn't have any extra information about things to looks out for when using 'simulationStart'.

    If I do
    Code (csharp):
    1. waterSurface.simulationStart = waterSurface.simulationStart;
    the water surface still simulates. However, if I do:
    Code (csharp):
    1. waterSurface.simulationStart = new DateTime ( 2008, 5, 1, 8, 30, 52 ); //straight from the documentation
    This doesn't work and the simulation stops.

    Unity 2023.2.5f.

    Update
    It seems it's a time difference thing. If you change the current simulationStart to some time within about 10 days from the current time, the simulation runs. But when you set the simulationTime beyond that, the simulation stops running. Setting the simulationTime back to the current DateTime causes the simulation to start running again.

    Code (csharp):
    1. private IEnumerator Wait ( )
    2. {
    3.     TimeSpan ts = TimeSpan.FromDays ( -5 );
    4.     yield return new WaitForSeconds ( 1 );
    5.     _waterSurface.simulationStart = _waterSurface.simulationStart.Add ( ts ); // Runs
    6.     yield return new WaitForSeconds ( 1 );
    7.     _waterSurface.simulationStart = _waterSurface.simulationStart.Add ( ts ); // Runs
    8.     yield return new WaitForSeconds ( 1 );
    9.     _waterSurface.simulationStart = _waterSurface.simulationStart.Add ( ts ); // Stops Running
    10.     yield return new WaitForSeconds ( 1 );
    11.     _waterSurface.simulationStart = _waterSurface.simulationStart.Add ( ts ); // Not Running
    12.     yield return new WaitForSeconds ( 1 );
    13.     _waterSurface.simulationStart = _waterSurface.simulationStart.Add ( ts ); // Not Running
    14.     yield return new WaitForSeconds ( 1 );
    15.     _waterSurface.simulationStart = DateTime.Now; // Starts Running Again
    16. }
     
    Last edited: Jan 15, 2024
  33. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Are you sure you are not setting the simulationStart variable everyframe on update?
    The result you are describing sounds something like that.

    I know the documentation is succint on this but this variable needs to be set once for multiple water surface to be synced properly. Hoping this is that or we have bigger issues :p
     
  34. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    upload_2024-1-15_17-15-14.png

    I'm happy to be proven wrong... In fact, I REALLY want you to point out some obvious and silly mistake on my part, so I can slap my forehead, and keep progressing.

    The above was attached to the Ocean gameobject that has the Water Surface component, in the Island demo scene.

    Note that the test code came about from me testing how far out it was (in increments of 5 days) where the simulation stopped working. I first noticed the issue when I set the value once, to a value of 01/01/2024 (greater than the approximate 10 days). I also set up a breakpoint to make sure that, as you guessed, it wasn't continually setting the simulation time to the same value. Even if that had been the case, I would envisage that simulation would still run, as it'd be the same value being set, not a value exactly x ticks from now.

    One thing I will do is start a fresh project, without any of our extra project code that might be running in the background... I don't think there's any other running code, but I'll rule that out as well.

    Update
    I used the same code on a completely separate "blank" project (just the Unity samples), and the problem is still evident.
     
    Last edited: Jan 15, 2024
  35. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    it is highly possible if you put a time far back in the past (like in 2008) you exceed the float max value and it stops working. From your testing it seems the simulation cannot run for more than 10 days straight. I'd say it's a reasonable limitation for now but i'll track that down on my side to see if there's a possible improvement here
     
  36. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Our use case is that we record peoples games and upload that data to the servers for playback, for themselves and competitors. Essentially a ghosting playback. Part of that is recording a player's position, which was influenced by the ocean surface at that time, along with the ocean "seed" so that we can match the water surface with the one which was recorded. In that way the player's "bobbing" up and down on the ocean surface matches with the simulated water surface.

    Even if we stored today's date, within 10 days the save file will be rendered useless. The player's transform will be bobbing on an ocean surface which isn't being simulated.

    Could you clarify your comment about running the simulation for more than 10 days? These tests I did weren't run for 10 days. I was just setting the "simulationStart" to a point 10 days in the past. And please don't take this as me being argumentative, but might I point out, the documentation itself uses a date in the year 2008 as the example, which is what threw me yesterday.
    upload_2024-1-16_8-18-45.png

    I haven't dug down into the code far enough, but is it possible that there might be a data type in the code somewhere that's using a half or even fixed precision, for performance reasons?

    Suggestion
    In fact, if there was an additional Property that allowed setting the simulation time from an int or float, that would solve our issue altogether, as all we need is just the seed value, not a specific date or time. Something like 'simulationSeed'. It seems this is what's essentially being done in code anyway. From WaterSurface.Simulation.cs:
    Code (csharp):
    1. /// <summary>Used to sync different water surfaces simulation time, for example across network.</summary>
    2. public DateTime simulationStart
    3. {
    4.     get
    5.     {
    6.         float timeScale = Time.timeScale * timeMultiplier;
    7.         if (timeScale == 0.0f) timeScale = 1.0f;
    8.  
    9.         return DateTime.Now - TimeSpan.FromSeconds(simulation != null ? simulation.simulationTime / timeScale : 0.0f);
    10.     }
    11.     set
    12.     {
    13.         TimeSpan elapsed = DateTime.Now - value;
    14.         if (simulation != null)
    15.             simulation.simulationTime = (float)elapsed.TotalSeconds * Time.timeScale * timeMultiplier;
    16.     }
    17. }
     
    Last edited: Jan 16, 2024
    Bungarra likes this.
  37. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Hey, quick update on this.
    I know it took us some time but we experimented with 3D deformations last week and aside from a few limitations we are considering fixing this in current versions. It will probably take some additional time to clean it up and to ship a proper sample with it but the general idea and process is there.
    Here's a far from perfect proof of concept:

    PoC.gif
     
    Peter77, VOTRUBEC, soleron and 13 others like this.
  38. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,092
    As nice as that kind of detail is, but focus on a more general purpose would be appreciated. Like automatic shoreline generation, automatic river generation, spline support, flowmap for rivers, etc :)
     
  39. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    832
    Refraction for water in VR (single instanced) is still wrong, I reported the issue in March 2023, issue was closed today with "can't reproduce"; I reopened it, as I can still reproduce the issue with both 2023.3.0b3 and 2023.2.5.
     
  40. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    yes it's me who closed it. i will try again if you can still repro, but i couldn't get the issue with a quest 2 on the repro project..
     
    Qleenie likes this.
  41. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    832
    Thanks. I’m the project I provided the issue is easily recognisable, looking at the legs of the Roboter under water, producing some ghost shadows on both sides. Just switch single instanced off at the bottom of the HDRP asset to see how it should look like. All other objects under water are offset, too, but you’ll probably only recognize in direct comparison of single instanced and multi pass.
     
  42. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    ok maybe i was doing something wrong, i managed to repro and find a fix
     
    chap-unity and Qleenie like this.
  43. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    546
    Water disappeared from 2022 LTS to 2023.2 and no matter what I do,
    even deleted the whole thing, and created a new one, it does not show the water!

    Is it something I did wrong during upgrading the scene (I noticed there were some changes?)
    Or is it a bug?
     
  44. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    It could be a corrupted shader during the upgrade of the project.
    Try searching for "Water" shader in the HDRP package using the project tab and re-import it, it happened to me a few times.
     
    soleron likes this.
  45. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    546
    I tried but nothing happened.

    However it appears something is wrong with the material?
    Or is the pink normal until you put it in the scene?

    upload_2024-1-30_1-35-29.png
     
    Last edited: Jan 31, 2024
  46. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    i just tried the upgrade and it seems for oceans the geometry type doesn't upgrade properly, could this be what you are seeing ? (infinite switches to instanced quad so the surface becomes very small)
     
  47. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    546
    Indeed that happened. But it is unlikely that was the issue with it.
    Nothing was showing, not even very small.

    And despite switching back to Infinite, and even cycling through all modes, deleting the ocean water object and creating a new one, nothing returned to what was expected.
     
  48. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    61
    I came across this thread to find the API for server synchronisation.

    Is it not dangerous to synchronise a water with the date? Locally, different time zones on different systems can give very different displays. The surest way would be a simple float value assignment.

    In this case, the unity water system could be completely useless for us.
     
  49. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    could be the volume system that got disabled maybe, or in the framesettings in the global settings. Otherwise maybe you can share you project in a bug report cause there's something wrong happening
     
    chap-unity likes this.
  50. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    244
    Using c# datetime is independent of timezone or anything so it shouldn't be an issue
    Issue with float assignement is that if you transfer that over a network then you have to compensate for the network lag yourself so not sure it's the surest nor simplest way.

    The current issue with time sync is that the water system itself becomes unstable due to floating point precision issue if you leave your game (or server) running for a few days. That's an issue that should be solved but it's unrelated