Search Unity

[RELEASED] Lux Water

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

  1. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    yeah that looks similar to the same problem i'm getting. And you can see clearly also that the shadow has the same shape than the objects but as if they were flipped.
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    strange mismatch.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    did a quick test with an m1 - closest i can get. looks fine there.
     
  4. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    maybe someone can get a full small project to share? Mine is huge so I can't do it :(
     
  5. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    I would like to add some underwater audio effects. I know that Lux has the Listener & Event scripts but those only work when you collide with the Plane (which in my case starts well before the camera is actually under the water). Where would be the best place for me to add an event to trigger audio when the camera is blurred?
    Would it be in the UnderWaterBlur script in the OnEnable/OnDisable methods? Or would it be the OnRenderImage method?
    Any ideas would be great.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    unfortunatelay there is no 100% accurate methode to detect underwater on the cpu.
    you can look into the LuxWater_Utils.cs and use the Vector3 GetGerstnerDisplacement() to get an approximated displacement of the water surface.
     
  7. shibaverse

    shibaverse

    Joined:
    Feb 9, 2022
    Posts:
    1
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    unfortunately no: the scene wasn't made by me.
     
  9. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    734
    Hey,
    Lux water is fantastic by default without special settings...I'm pretty sure I used (4 years ago) one of the included materials with a few value changes.
     
    Last edited: Jul 4, 2022
  10. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Is anyone having the issue when the Camera is underwater, there is some "clipping" going on? Not sure what else to call it.
     

    Attached Files:

  11. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    How did you do the wake?! That's awesome.
     
  12. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,294
    Multiple projectors at various bones of the Crocodile. I just followed what was done in the demos that come with the asset :)
     
    hopeful and jnbbender like this.
  13. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Well, I found the issue. It was down in the docs. I didn't realize that my WaterPlane could not exceed my FarClip Plane.
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    well, the overall water plane can - if you use a sliding volume and create your water plane out of tiles.
     
    jnbbender likes this.
  15. Danibi

    Danibi

    Joined:
    Nov 10, 2012
    Posts:
    36
    Hello, on Playstation 4 I got this error:

    ERROR: Shader Lux Water/Underwater/Light Beam shader is not supported on this GPU (none of subshaders/fallbacks are suitable)

    The water is completely black.

    Any suggestions to make it work?
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    do you get any more information?
    from a quick look into the code: ps4 is very picky about lerps. so line 234 might cause a problem:
    col.rgb = lerp(col.rgb, _Lux_UnderWaterFogColor * fogLighting, fogDensity);
    try to change it to:
    col.rgb = lerp(col.rgb, _Lux_UnderWaterFogColor.rgb * fogLighting, fogDensity.xxx);
    same with:
    ColorAbsortion = lerp( d, -ColorAbsortion, _Lux_UnderWaterAbsorptionColorStrength * (1.0 - d));
    to:
    ColorAbsortion = lerp( d.xxx, -ColorAbsortion, (_Lux_UnderWaterAbsorptionColorStrength * (1.0 - d)).xxx );
     
  17. Woolf

    Woolf

    Joined:
    Dec 4, 2012
    Posts:
    35
    Hello. After switching to the Unity 20213.8 LTS
    my lux water is buged. Underwater vegetation (Nature/SpeedTree shader) starts flashing and displaying strangely. Maybe you can tell me what could be the matter here?

     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i have never heard about anything like this. and in order to really track down the issue you will have to analyze a bugged frame using the frame debugger or renderdoc.
    from what i can see in your video going through it frame by frame: single instances of the grass suddenly go black.
    could be shadows (but the terrain below does not go black), could be underwater fog if the depth buffer gets corrupted.
    i checked the ocean demo and placed some cubes there using the speetree shader (leaf mode) but could not reproduce your issue - neither in forward nor deferred. tested with unity 2019.4. which is the lowest version i have.
    any further information you can share?
     
  19. Woolf

    Woolf

    Joined:
    Dec 4, 2012
    Posts:
    35

    I think I found the cause of the problem. I migrated from Unity 2019 to Unity 2021 and apparently the nature/speedtree shader was damaged. I forced re-imported the vegetation asset materials and this blinking disappeared. I'm sorry that I turned on the panic and started writing to you right away. This problem was solved.
     
  20. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    A lot of times deleting the library folder fixes all those random weird glitches in Unity. I've solved from visual glitches to random android device crashes just by deleting that folder.
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    great!
     
  22. Danibi

    Danibi

    Joined:
    Nov 10, 2012
    Posts:
    36
    Hello,
    we have a problem using the luxWater shader with the screen space reflections on xbox one and xbox series.
    On PC, playstion and switch it works great!

    You can find two screenshots attached, the first one from Editor and the second one from xbox series X.

    upload_2022-9-18_17-22-37.png
    upload_2022-9-18_17-21-34.png

    The shader was customized by another developer, so I don't know well how the shader works.
    I need some help, I am not a shader expert.
    Do you have any suggestions?

    Thank you.
     
  23. Woolf

    Woolf

    Joined:
    Dec 4, 2012
    Posts:
    35
    Is it possible to implement such effects in any way? The zone of local waves, I think, can be realized through a wave projector, but with reflections I'm in a stupor.

    I have a game about fishing and water is the main thing, so it takes so much effort) upload_2022-9-19_18-8-41.png


    upload_2022-9-19_18-4-16.png
     
  24. Woolf

    Woolf

    Joined:
    Dec 4, 2012
    Posts:
    35
    In general, there is an idea that the zones of local unrest can be tied to the color of the watermesh vertex, and paint the water with any vertex coloring tool, either from R.A.M or from Polybrush

     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    difficult... 1st question: is the reflection rendered properly? and does only the water shader break the final image?
    you could debug the reflection by writing a simple shader that would read the created render texture. then create a material and place it onto a cube.
    if the reflection is fine the customized shader breaks it.
    having another look at your 2nd screen shot: they just seem to be missing...
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    in the BIRP we have either cubemap reflections or planar reflections. latter are constrained to planar reflecting surfaces but lux water also cheats a bit here.
    in order to get blurry reflections over distance you would have to create mip maps for the planar reflection render texture (should just be setting a bool tu true) and then find a sampling formular for the water shader picking the right mip level using trilinear filtering.
     
  27. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Hi,

    Is there a tutorial for this part:

    Water projectors which allow you to add local foam as well as local normals (and displacement)
    • Tessellation and projected displacement

    I want to try make waves for a car's wheels when entering water, is that possible, but my own waves?
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    water projectors would be the right way.
     
    khos likes this.
  29. StefanoSanitate

    StefanoSanitate

    Joined:
    Oct 21, 2018
    Posts:
    6
    Hi! We have some issues on Metal. I followed the instructions on the documentation but the artifacts are still there. Here's an in-game screenshot and a screenshot from the Lux Water Simple Demo. Both taken in editor from a Macbook with an M1 chip.
     

    Attached Files:

  30. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Ok thanks :)
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    oh, i haven't checked it on M1 so far...
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i just did a quick test. you have to uncomment the //#define LUXWATERMETALDEFERRED in both shaders: the "LuxWater CG" and the "LuxWater CG Tessellation". and of course activate "Grab depth texture" on the "camera depth mode" script. then the result in the game view looks fine. scene view is broken tho...

    luxwatermetalm1.png
     
  33. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    How would we go about adding some sun shafts/godrays effect to lux water underwater postprocessing? Any tips?
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    KarloE likes this.
  35. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
  36. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    For some reason underwater effects are not working in lux water simple demo scene? Using unity 2020.3 LTS @larsbertram1
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i do not think that there are any underwater effects in the simple demo. try the ocean emo instead.
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    if ypu want to fake godrays using some planes e.g. you need to use one of the transparent shaders that come with lux water and add the missing features such as camera fade or animation.
     
    KarloE likes this.
  39. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    How do I correct underwater fog "distortion"? To put it plainly, on the edges of the screen fog is "further away" which makes some objects being kinda invisible right in front of you, but when you rotate your camera they become visible when nearing the edge. Here is the sample:

    https://gyazo.com/c125d4ad0301ec9625d71be48b21ab4c

    Look at the red cube when in middle of the screen, and when on the edges. I boosted fov for it to be more obvious.

    I'd ideally like the fog to spread in a perfect circle around, not being warped like this. How would I go about correcting this?
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    fog is calculated based on the distance to the camera. so it looks pretty accurate the way it looks now.just look at the terrain: it vanishes when the red quad vanishes.
     
  41. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    I got you as far as calculations go, but my point is - when I turn my head around around in real life I can't see better through the fog if its in my peripheral vision. Seems weird.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    oh, you can't? :)
    might be a problem with the interploation from vertex to fragment shader or i really did something wrong... i would have to dive into the code but won't have the tiome to do so withinn the next days, sorry.

    EDIT: just a quick look, the vertex interpolator is used for wpos, not depth so we can rule out this.
    and depth is calculated using:
    float sceneDepth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv));
    float dist = sceneDepth * _ProjectionParams.z;

    you could try and replace the dist definition using:
    float dist = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv));
     
    Last edited: Oct 12, 2022
  43. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Not urgent at all, I will remind you about it next week. :)
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    see above's edit.
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, i know why i hate working with the depth buffer...
    we have to derive dist from the camera relative position.
    in our case this is (wDir is misleading naming here...):
    dist = length(wDir);
    so you have to move the calculation of dist a bit downwards in the shader.
     
    hopeful likes this.
  46. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Thanks I'll try this over the weekend the latest and let you know of results!
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it needs you to tweak the surface shader too...
     
  48. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    764
    Hi,
    The more i check other water assets the more i go back to Lux water!! still amazing and for the price can't be compared...
    How can i access wave final displacement values by script....sorry for the noob thing...
    I dont know how to get to the material reference...:oops:
    thx
     
    Baldinoboy, iddqd and sjm-tech like this.
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    look into the ocean demo e.g. where you will find some spheres following the waves.
     
  50. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    764
    Thx, actually i want to set the values by script to create waves only when leaving the shores. An old idea i never tried...
    I want the shores to be calm when my character in on the beach. Then if sailing i wanna learp those values to get a real ocean ...
    Could you give me some example of coding:oops:? I try to understand this from the Seettogerstnerwaves script but to complicated for me...
    thx in advance