Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Official Water System for the High Definition Render Pipeline

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

  1. Mirkle

    Mirkle

    Joined:
    May 13, 2022
    Posts:
    17
    Thanks for the answer, I really see how much quality work is put in the water system. This specific problem however ends up having a huge impact on the usability of the water system in a game setting.

    This problem happens with a brand new project, in editor view and in game. For example, if a player swims on the surface of water in first person view, there are many camera angles looking down where he sees the whole underwater content without any underwater effect. Sadly, this totally breaks immersion, and gives sight+info on the underwater region to the player that he should not have.

    Is that something Unity can look at, there has to be a way to solve this, the water solutions that I tried on the asset store didn't have this problem.

    Thank you!
     
    Last edited: May 6, 2024
    VOTRUBEC likes this.
  2. Misaki_eKU

    Misaki_eKU

    Joined:
    May 3, 2018
    Posts:
    104
    Maybe it can be fixed by moving the water line on the y axis by the near clips times the camera rotation? But anyway, I think this is not a "actual" problem.
     
  3. Mirkle

    Mirkle

    Joined:
    May 13, 2022
    Posts:
    17
    Thanks for the idea Misaki_eKU!

    I hope this will help the unity team find a solution!

    I don't know if I use the correct word calling it a "problem" but I 100% confirm that it would be an issue/problem for my game (and most likely many many other games), as when the player transitions from out of water to underwater the whole underwater content becomes visible at a certain point without any underwater effect.

    Thanks!
     
    Last edited: May 7, 2024
    Wattosan and impheris like this.
  4. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,737
    it is an unwanted issue so calling it a problem is not bad, it is a "bug"
     
    Mirkle likes this.
  5. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    324
    That's what we do but it doesn't work in all cases

    Unfortunately due to the time constraints i don't think i will be able to look at it, but you can still report a bug. I am sorry but i can't guarantee it will be fixed though
     
    Mirkle likes this.
  6. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    130
    I have this issue with exclusion too. If I have exclusion mesh and my camera in problem point - the exclusion mesh not working and I saw the water.
    For first-person games, I can use water only for decor which you do not interact with.
     
    Mirkle likes this.
  7. D1234567890

    D1234567890

    Joined:
    Aug 11, 2019
    Posts:
    72
    With "Volumetric fog sampling caustics texture", is it possible to achieve this effect of same quality using a local fog volume?
     
  8. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    324
    You can do something similar by putting the caustics texture as cookie on a directional light (or a box light)
     
  9. turnerryan774

    turnerryan774

    Joined:
    Jun 26, 2021
    Posts:
    1
    I had a problem, when I imported HDRP into my project everything else worked except the water, I had everything enabled as the https://docs.unity3d.com/Packages/c...h-definition@14.0/manual/WaterSystem-use.html told me to and no matter what iI did, I deleted HDRP and reimported it, but I kept getting this issue:
    undeclared identifier '_SurfaceGradientResolveNormal_df1ef2108a5245e3bb0489b02997e1a0_NormalOutput_2_Vector3'
    Compiling Subshader: 0, Pass: GBufferTesselation, Vertex program with PROCEDURAL_INSTANCING_ON WATER_THREE_BANDS
    Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
    Disabled keywords: DEBUG_DISPLAY SHADER_API_GLES30 STEREO_INSTANCING_ON UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING WATER_ONE_BAND WATER_TWO_BANDS _ADD_PRECOMPUTED_VELOCITY _DOUBLESIDED_ON _SURFACE_TYPE_TRANSPARENT _TRANSPARENT_WRITES_MOTION_VEC
     
  10. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,449
    I tried those boids. At first I thought it'd be the announced VFX boids, but it's just - as you labeled it in the asset - fake boids.

    I rather recommend you don't show anything that's not worth showing. It's just not impressive. That's some dev stuff, nothing usable.
     
    Last edited: May 13, 2024
    chap-unity likes this.
  11. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    324
    Hello, this seems to be a compilation error in the shadergraph, are you using a custom material or the default one ? you can try to create a new one one to make sure and check what fails in the shadergraph
     
  12. Jac01

    Jac01

    Joined:
    Dec 4, 2018
    Posts:
    2
    Hello,

    I'm using the water system with two top down splitscreen cameras. Water works great but foam and deformers are limited to one area per water object, not compatible with two cameras. Ideally, having two areas would save me having to create two ocean meshes in sync with area center update in realtime. Otherwise i can :
    - use 2 render textures with top down ortho cams => lots of CPU/GPU power waste
    - make 2 render textures and blit custom particle quads into it => unnecessary work for me + not using the super cool deformers & foam scripts, but good performance.

    Thanks
     
  13. D1234567890

    D1234567890

    Joined:
    Aug 11, 2019
    Posts:
    72
    Apologies, but I misquoted. I am interested specifically in making an underwater fog effect by tapping into HDRP's volumetric lighting similar to HDRP's water. I was wondering if you thought this was feasible with a local fog volume plus fog material? Or if there was anything down the line for us to take better advantage of volumetric lighting? I made a few attempts in the past but none seemed feasible.
     
  14. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    324
    yes it's possible with a local volume and custom material. You are probably gonna have troubles on the surface boundary depending on your resolution when a froxel is partially above and under surface, although that's not really a unity specific problem
     
    chap-unity likes this.
  15. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    Is it possible to access the lighting/distance data used to blend objects into the water? When looking into the water deeper objects are more obscured, and this effect seems to be calculated at the WaterSurfaceRenderingDeferred stage using textures such as _WaterGBufferTexture0. We'd like to access this data (ideally as a greyscale texture) so we can do some threshold calculations in our own shader. Any pixels representing surfaces deep enough in the water to be almost black in the depth texture will exceed our threshold, so we can process them accordingly.

    246f69bd-749a-4571-947d-80d0d852bd21.jpg

    Any help you can provide will be much appreciated. To be clear, I'm referring to the visual appearance of objects in the water, not position data from scripting.
     
  16. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    324
    This is not something we can output. The data is computed while rendering water by using the water depth and the depth coming from the depth pyramid (this is done by function named ComputeWaterRefractionParams and output in variable absorptionTint).

    Computation is essentially exp(-distance * extinctionCoeff)
    where extinctionCoeff can be computed on CPU by:
    Code (CSharp):
    1. (-Mathf.Log(0.02f) / surface.absorptionDistance) * new Vector3(Mathf.Max(1.0f - surface.refractionColor.r, 0.01f), Mathf.Max(1.0f - surface.refractionColor.g, 0.01f), Mathf.Max(1.0f - surface.refractionColor.b, 0.01f))
     
  17. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    633

    I had the same problem and after busting my head for some time, I found out by coincidence that for some reason, the water had been turned off for some quality level and the editor had switched to that.
     
  18. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    We might be able to fake it using _WaterGBufferTexture0. How would we access this in our own shader?
     
  19. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    In WaterSystem.RenderWaterLighting() this ComputeShader texture parameter is set:

    ctx.cmd.SetComputeTextureParam(data.parameters.waterLighting, data.parameters.waterLightingKernel, HDShaderIDs._WaterGBufferTexture0, data.gbuffer0);

    If we could access data.gbuffer0 as a global shader texture property that would probably be enough for our shader to work. Is this possible?
     
  20. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    324
    No we don't expose those internal textures. You can make a local copy of the repo and change it to public if you need it though
     
  21. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    We need to work with the official package for our project. Effectively what we need is some way to capture to water lighting output so we overlay it into our own custom render pass.
     
  22. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    My boss is bound to ask, is there any chance you could expose this texture?
     
  23. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    324
    No there's no chance unfortunately. Otherwise you can use the method i mentionned above, if you approximate the water to be a plane that should be fairly simple to implement
     
  24. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    I'll try something along these lines. Thanks.
     
  25. ArIaNFury008

    ArIaNFury008

    Joined:
    Dec 22, 2019
    Posts:
    29
    Hi, where we can request features for the water system HDRP? Can I post it here?

    Request Feature: if it would be possible to make the geometry in Custom mode (water system), adding points around the surface we want and then automatically creating plane shapes?

    is there anywhere to do this without going to the blender? my terrain is a little complex, I should export the mesh to Blender and then create the geometry.

    anyway, it's good to have this option, similar to Crest. Thanks Unity team, the water system is amazing!
     
  26. Misaki_eKU

    Misaki_eKU

    Joined:
    May 3, 2018
    Posts:
    104
    you can do this with pro builder
     
    ArIaNFury008 likes this.
  27. edvart-ros

    edvart-ros

    Joined:
    Aug 15, 2023
    Posts:
    26
    I'm more or less finished with my robotics sim project (which uses the HDRP water system). It has physically-based buoyancy (submerged volume and centroid estimation for arbitrary meshes) and hydrodynamics (simplified).
    Also did LiDAR simulation, RGB+D camera simulation and propulsion. Also, integrates with ROS 2 which is used a lot by developers, through the ROS-TCP-Connector. Anyway, just wanted to applaud y'all for making this cool water system!

    Here's the github:
    https://github.com/edvart-ros/unity_asv_sim

    Next on the agenda:
    physically based sonar simulation with compute shaders (maybe ray-traced)
     
    chap-unity likes this.
  28. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    In our project scene we have a single water surface and multiple transforms each using a custom FitToWaterSurface component to adjust their y position to the water level. What is the most efficient way to do this? Is there a way to pass a collection of transform positions to a single water surface and get the closest points on the water level for each?
     
  29. edvart-ros

    edvart-ros

    Joined:
    Aug 15, 2023
    Posts:
    26
    Yes, there is a Burst version of that script which handles multiple floating objects efficiently:
    https://docs.unity3d.com/Packages/c...nition@14.0/manual/WaterSystem-scripting.html
     
    chap-unity likes this.
  30. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
  31. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    Is there a way to access the foam overlay on a water surface? We have custom shaders used to segment objects, rendering individual elements a different colour for masking and other work in external applications. I can include water depth visibility falloff in these calculations so that the object segments are cut off at the appropriate point, but it would be good to also use the alpha value for the water foam.

    To illustrate here is an actor with the water level up to the nose. The water absorption distance allows us to see the rest of the body down to the abdomen:

    Screenshot 2024-06-14 095214.png

    Our segment capture uses the water visibility falloff to discard fragments once they are no longer visible. If we also had water foam around the actor could I get hold of this data to include the alpha value in our visibility cut off calculation?

    Screenshot 2024-06-14 095230.png
     
    chap-unity likes this.
  32. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    790
    You should be able to access the foam buffer of the water system using the GetFoamBuffer() function documented here.

    If you need to, there's example of how to use this in the Water Samples Island scene.
     
  33. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    157
    Thank you.