Search Unity

[RELEASED] Lux Water

Discussion in 'Assets and Asset Store' started by larsbertram1, Jun 18, 2018.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    oh, sorry: i totally missed this one.
    no, grid size should not be size of the chunks!
    this most likely will break it and might be the source of all your pain.

    grid size determines the steps in which the sliding volume will be moved according to the camera's position.
    so lets assume that your chunk is 100x100m in size and subdivided into 10x10 quads. in this case the grid size would be 10. every 10 meters in world space you have a unique vertex.
    so the sliding volume will follow the camera in 10x10m steps. which ensures that the sliding volume will be repositioned using these 10m steps and vertices of the volume fall exactly on top of vertices of the surface.
    this is needed by the tessellator to create the same results for the water surface and the underwater mask.
     
    jchambers likes this.
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i am glad you solved it!
     
  3. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    200
    Hello, I just bought your asset and I am trying to make it compatible with Overcloud by following the instructions in this link. But the clouds are still invisible when the water is behind the clouds. Have I done something wrong or is that compatibility out of date?

    upload_2020-11-25_17-29-36.png
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you have to also follow the instructions for transparent materials (in the overcloud docs).
     
  5. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    200
    Do you mean section 4.2? "Adding OverCloud support to a transparent shader"?
    If so, I wouldn't know how to modify your shader to make it compatible. Sorry, I have no idea about shaders, so I need your help in more detail.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    all i can give: it the very end of the LuxWater_Core.cginc you have to tweak the alpha:

    float alpha = CloudAttenuation(surfaceEyeDepth, i.grabUV.xy, 1);
    then the return has to look like this:
    return half4(c.rgb, alpha);
     
    Duende likes this.
  7. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    200
    Thanks for the help.
    You mean this, right?
    Code (CSharp):
    1.     // Smooth water edges
    2.     c.rgb = lerp(OrigRefraction, c.rgb, edgeBlendFactor);
    3.     float alpha = CloudAttenuation(surfaceEyeDepth, i.grabUV.xy, 1);
    4.  
    5.     // c.rgb = i.color.rgb;
    6.     // c.rgb = test;
    7.  
    8.     return half4(c.rgb, alpha);
    Unfortunately nothing changed, still the same.

    I'm using the plane "OceanPlane_500x500" from the demo scene "11 LuxWater Ocean Demo". And the Unity version is 2018.3.7f1, to add more information.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, it just works for me?!
     
  9. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    200
    I have created a clean project. I just added Overcloud and Lux Water and I have added Overcloud to "11 LuxWater Ocean Demo". I have followed the steps of the link and the last thing you told me but it remains the same:
    upload_2020-11-26_13-38-0.png

    If I do the optional step to add cloud shadows to the water the shadows work but the clouds are still transparent.
    upload_2020-11-26_13-37-9.png

    Another thing, the link says that I add the changes to the #endif of line 1231, but in that line there is no endif because the shader will have changed since the last time that page was updated.
    I added it on line 1227 and it looked like this:

    Code (CSharp):
    1.     //  -----------------------------------------------------------------------
    2.     //  Diffuse lighting at the surface = foam
    3.         #if defined (GEOM_TYPE_BRANCH_DETAIL)
    4.             // As it is just foam here, we skip DisneyDiffuse and use Lambert (NdotL) – roughly +3%
    5.             half diffuseTerm =
    6.                 #if defined(DISNEYDIFFUSE)
    7.                     DisneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;
    8.                 #else
    9.                     nl;
    10.                 #endif
    11.             half3 diffuseLighting = Foam.rgb * (
    12.                 #if defined (UNITY_PASS_FORWARDBASE)
    13.                     gi.indirect.diffuse +
    14.                 #endif
    15.                 lightColor * diffuseTerm
    16.             );
    17. // here it gets translighting twice...
    18. // diffuseLighting += lightScattering * Foam.rgb * _FoamTranslucencyIntensity;
    19.  
    20.             UNITY_BRANCH
    21.             if(backside) {
    22.             //  Add underwater fog
    23.                 diffuseLighting = lerp(diffuseLighting, diffuseUnderwaterLighting, FogDensity) ;
    24.             //  Apply absorption
    25.                 diffuseLighting *= ColorAbsorption;
    26.             }
    27.         //  Blend between water and foam
    28.             Refraction = lerp(Refraction, diffuseLighting, Foam.a);
    29.         #elif defined(FOG_OVERCLOUD)
    30.         if (!backside) {
    31.             #if defined (UNITY_PASS_FORWARDBASE)
    32.                 OVERCLOUD_FRAGMENT_FULL(c, i.grabUV.xy / i.grabUV.w, worldPos)
    33.                 OVERCLOUD_OCEAN_BASE(c, i.grabUV.xy / i.grabUV.w, worldPos)
    34.             #elif defined (UNITY_PASS_FORWARDADD)
    35.                 OVERCLOUD_FRAGMENT_FULL_ADD(c, worldPos)
    36.                 OVERCLOUD_OCEAN_ADD(c, i.grabUV.xy / i.grabUV.w, worldPos)
    37.             #endif
    38.         }
    39.         #endif
    40.  
    41.     //  -----------------------------------------------------------------------
    I don't know, maybe I'm doing something wrong and I don't know what it is.
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    your 2nd snipped looks odd. the overcloud code i way too high up in the code.
    fog is added at the very bottom where you find azure, aura and enviro fog integration.

    the transparent stuff ( CloudAttenuation() ) comes at the very end - like you showed earlier.
    i am not familiar with overcloud, maybe you have to enable the needed cloud depth textures somewhere. so you could reach out for felix. he should know best :)
     
    Duende likes this.
  11. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    200
    I have thought that you could share your modified version that works, and I test it. Or even the scene as well.
    I asked Fewes if he could help us. I'm waiting for his answer.

    Thanks again for the help. :)
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    pm send with tweaked shader code.
     
    Duende likes this.
  13. ecarbin

    ecarbin

    Joined:
    Mar 16, 2013
    Posts:
    2
    I purchased your asset and enjoy the effect and how the code is set up. The one problem I am having is underwater fog density. It way too thick and I haven't found a way to adjust the density. What is the advised way to adjust the underwater increase underwater visibility?

    I can barely even see the character the camera is attached to.
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
  15. Christ0phoros

    Christ0phoros

    Joined:
    Sep 1, 2019
    Posts:
    13
    Hi. Could you tell me haw to fix that bug? It's hapen when i use fish shader to animate their swimming. It's looks like the water behind object is not render. Thanks
     

    Attached Files:

  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    looks like a bug with the fish shader: it seems to not properly render into the depth buffer.
    so most likely the vertex animation is not applied in the shadow caster pass of the fish shader.
    nothing i can help with then.
     
    Christ0phoros likes this.
  17. Christ0phoros

    Christ0phoros

    Joined:
    Sep 1, 2019
    Posts:
    13
  18. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    78
    I have a question about oculus. The water looks and runs great until I look down or move. I get what looks like all the level geo is inverted and invisible. Is there a setting to fix this??
    I am using the muddy water volume and forward rendering with the depth script.
     
  19. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    48
    Any plans for HDRP in 2021?
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    nothing i would count on...
     
  21. julienc

    julienc

    Joined:
    Nov 26, 2012
    Posts:
    5
    And what about urp do you think it is achievable? I would like to combine lux essentials and lux water in urp. Thanks
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    which features would you need in urp?
     
  23. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    48
    Fingers crossed for 2022 then :) I'm stuck in hdrp now for better or for worse, and lux water is the only thing I really miss. I have a visceral reaction to it that I haven't found in any other water shader yet. e.g. this demo which is beautiful but always makes me feel a bit sick lol
     
  24. ScorphiusMultiplayer

    ScorphiusMultiplayer

    Joined:
    Nov 10, 2018
    Posts:
    66
    I wanted to use Lux Waters.
    However, on installation I found that Lux waters adds 18 new shaders which tips the total global shader count 256+ in unity. I had to uninstall it again.
    At present its not usable. I cannot remove other projects.
    I also Have R.A.M which adds only 2 shaders but its very heavy on the editor.

    Any tips on reducing shader count from Lux Waters ?
    Thanks in advance for your replies.
     
    Last edited: Jan 1, 2021
  25. vampir26

    vampir26

    Joined:
    Mar 29, 2010
    Posts:
    108
    Hi
    Thank you for this great asset.
    Do Lux Water support edge wave blending? Similiar to edge blending, but including gerstner waves. This would be great to smooth the waves on terrain.
    Thanks in advance.
     
  26. glenneroo

    glenneroo

    Joined:
    Oct 27, 2016
    Posts:
    231
    I'm getting this error while trying to make a build for Oculus Quest (Android):
    Shader error in 'Hidden/Lux Water/UnderWaterPost': undeclared identifier 'sampler_CameraDepthTexture' at line 144 (on gles3)

    Compiling Vertex program with STEREO_MULTIVIEW_ON
    Platform defines: UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_ENABLE_REFLECTION_BUFFERS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_NO_CUBEMAP_ARRAY UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 SHADER_API_MOBILE UNITY_HARDWARE_TIER2 UNITY_LIGHTMAP_DLDR_ENCODING

    This is the line of code:
    float sceneDepth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv));

    Anybody have any idea how to fix this?

    EDIT:
    Nevermind! Solution is here: https://answers.unity.com/questions/1529224/opengles3-fails-to-compile-shaders-hiddenpost-fx-f.html

    For LuxWater specifically, open LuxWater_UnderWaterPost.shader
    replace this line: sampler2D _CameraDepthTexture;
    with this line: UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);

    @larsbertram1 If I'm not the only one getting this error, perhaps you could add a conditional compiler flag for Android/Oculus Quest builds?
     
    Last edited: Jan 7, 2021
  27. RakkuAmiya

    RakkuAmiya

    Joined:
    Jan 9, 2016
    Posts:
    53
    This is the best looking water shader I've found that works in VR, minus the reflections of course.

    I've recently moved to the new Unity XR system for VR use, and for OpenVR you have choices for either multi-pass rendering, or single-pass instanced. I have been unable to get Lux Water to work with single-pass instanced and get the error:

    "Shader error in 'Lux Water/WaterSurface': invalid subscript 'instanceID' 'UnitySetupInstanceID': no matching 1 parameter function at Assets/LuxWater/Shaders/Includes/LuxWater_Core.cginc(276) (on d3d11)"

    Is there any way around this? I'm going to try multi-pass in my project, but I'm concerned about any performance drop.

    I'm using Unity 2019.4.17f1, SteamVR 2.7.1 (OpenVR), Lux Water and Enviro.

    Many thanks;

    Graeme
     
  28. julienc

    julienc

    Joined:
    Nov 26, 2012
    Posts:
    5
    The gerstner waves seems to be the most visible missing spot. thanks
     
  29. RakkuAmiya

    RakkuAmiya

    Joined:
    Jan 9, 2016
    Posts:
    53
    In the end I've reverted to the previous depreciated XR system, and it just works. Lux Water, Enviro, VR, single pass rendering ... apart from a few visual glitches within Enviro, it's all good. The issues I was having are due to a Unity bug logged since August. :(

    This is still the best looking water shader I've found for VR. If it could deal with reflections in VR, it would be perfect. :)

    Graeme
     
  30. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    anyone have any idea or tips to make this water look toony / stylized .. maybe even just a little bit stylized?
    it is the best looking water ive seen, moreso, i like the underwater effect, its the best ive tried,
    but i like toony or stylized aesthetic
    thank you
     
  31. 747423517

    747423517

    Joined:
    Jan 29, 2015
    Posts:
    8
    Could you please tell me why my water can't record 360 video normally? After recording, the state is like this
     
  32. MOBILIN

    MOBILIN

    Joined:
    May 6, 2017
    Posts:
    15
    Water is visible in the Scene view, but not in the Game view. I have checked the Deferred shader, Culling Mask, Rendering Path, Clipping Planes, etc. What more should I check?
     
  33. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    Hey folks,

    Bit confused as to the current situation around shadows. Documentation mentions options for them under Planar Reflections but those options don't seem to be exposed any more.

    To have an option to enable shadow receiving would be awesome. Noticed a post a couple years back mentioning this needs to be sampled per pixel per cascade and is expensive, is this why its not an option any more?
     
  34. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    I have also just come across the issue of needing shadows to be cast on the water. I'm rendering from directly above the water and when the water is not perfectly clear it needs a shadow cast on it. Is this possible?
     
  35. northman

    northman

    Joined:
    Feb 28, 2008
    Posts:
    144
    How to get exactly water surface height (Y) in a location (X,Y) ?
    I try to use LuxWater_SetToGerstnerHeight.cs, but it doesn't set object on the watersurface.
    What parameters can let object put on watersurface exactly? or how to program do that?
    I need your help. Thanks.

     
  36. alaynahughes

    alaynahughes

    Joined:
    Apr 24, 2016
    Posts:
    1
    Great shaders, but it dissapears in VR! I have it at level and as soon as i move the headset it disappears and I cannot find a setting where it does not move with the eyesight.
     
  37. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    78
    I had this same problem, but I am pretty sure the author doesn't respond to this thread anymore. But I could be wrong about that. It might be just the vr questions that go unanswered.
     
  38. RakkuAmiya

    RakkuAmiya

    Joined:
    Jan 9, 2016
    Posts:
    53
    Unless they correct me otherwise, no VR is not supported. In older posts on this thread, responses were made with regards to VR issues. However last I checked any VR post was simply replied with a "VR not supported" post. This is a real shame as this is the best water shader I have found for VR, and it works really well with the exception of underwater or any of the camera effects (water drops on screen etc). It could be *the* go-to VR water shader.

    That said... I'm not having issues with the above surface view of the water personally. I'm using 2019.4.19f1.

    Graeme
     
  39. trnenmic

    trnenmic

    Joined:
    Feb 15, 2017
    Posts:
    6
    Hello, I am trying to make an underwater lab with windows, so I am basically looking for the effect of water behind the glass. Imagine something like this: under-water-effect2.jpg
    I think that for me it would be enough if the water looked like this (as I could use it in the window).

    I underwater-effect.jpg
    But in 10 LuxWater Water Volume Deep Water Demo, if I am not directly under water, it looks like this:
    water-cut.png
    Underwater effects are not applied. Is there a way to tweak this?

    Thank you for your time!
     
  40. julienrobert

    julienrobert

    Joined:
    Sep 15, 2014
    Posts:
    65
    Hi, I'd like to modify the parameter Normal/Speed Global Factor by script. How do I do it?
     
  41. julienrobert

    julienrobert

    Joined:
    Sep 15, 2014
    Posts:
    65
    Ok I managed to find out that we have to modify the color named _BumpSpeed and the global factor is the alpha. But when we change it gradually, it jags. It's not smooth. Is it possible to modify this smoothly?
     
  42. julienrobert

    julienrobert

    Joined:
    Sep 15, 2014
    Posts:
    65
    Can you elaborate a little? I tried different things with these and managed to move the bump with _FinalBumpSpeed23 but as soon as I stop to change the value, the bump stops.
     
  43. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    103
    @larsbertram1
    Hi,

    I am trying to use LuxWater for my VR unity 2020.1.17f1 Built-in RP Windows MultiPass project, above the surface I have no problems, everything works, below the surface the only thing that does not work is the caustics only for right eye vision, when the camera approaches or moves away from a surface the caustics move destroying the stereoscopic vision, I tried for hours to modify LuxWater_UnderWaterPost but without success, does anyone know how I can solve?

    Edit: SOLVED!!!

    CalculateFrustumCorners and Lux_CameraWS for both eyes


     
    Last edited: Mar 5, 2021
  44. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    Found a bug in the FOG btw, its not reading the Unity settings at all! To fix it add this:

    #pragma multi_compile_fog

    To 'LuxWater CG.shader'. I added it around line 263
     
  45. graphicsayy97

    graphicsayy97

    Joined:
    Dec 24, 2020
    Posts:
    50
    Hello, I am interested in buying this asset while its on sale. (and even when its not)

    as I have been watching it for awhile and deciding on using it VS crest

    I need a water asset for ocean water, but I want to replace the shader to use more styles of graphics/art, is that possible?

    also, I am only interested in an asset for water to make giant waves to combine with https://assetstore.unity.com/packages/tools/physics/dynamic-water-physics-2-147990

    does your asset allow users to make any kind of waves? like super talls ones?

    i understand that crest and SUIMONO also offer solutions similar to yours, but I am wanting to know if yours faces any hard limits
     
  46. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    How do i remove the reflection of the direction light used as the sun, i have a cloudy sky with no sun but still the sun(direction light) is in the reflection, i have tried placing the sun on a layer and ecluding it but it still shows?
     
  47. Faizalski

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    27
    @larsbertram1 Are there a possibility to move the sun around in real-time and get the lights projected correctly? I tried moving the light but it just stays at one static position. I tried the infinite ocean, by the way, Your help on this little issue of mine is greatly appreciated.
    Thank you.
     
  48. Faizalski

    Faizalski

    Joined:
    Oct 4, 2018
    Posts:
    27

    Hi @Monil , Looks like I'm stuck on the same boat. I can see that you've managed to find a solution.
    I'm not sure what those that you've mentioned refers too though :(
    "CalculateFrustumCorners and Lux_CameraWS for both eyes"

    Can you share a little bit more on what you have to do?

    Thank you
     
  49. c0mas

    c0mas

    Joined:
    Jun 10, 2015
    Posts:
    1
    Hi @larsbertram1, I have a question about LuxWater, how can I activate shadows on the water surface?
     
  50. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Im getting this errors on Android Opengl 3 on unity
    Shader error in 'Lux Water/WaterSurface': 'UnitySetupInstanceID': no matching 1 parameter function at Assets/LuxWater/Shaders/Includes/LuxWater_Core.cginc(259) (on d3d11)

    anyone got it to fix?