Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

[RELEASED] Lux Water

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

  1. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Been watching this asset for some time now. But still unsure whether it will meet my requirements. Is there an easy way to dynamically control the scale of the waves and its choppiness for a Water Volume set up like that?
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    i guess i am too biased to answer this question :)
    but theoretically i would say: yes. if scale means height, frequency and amplitude you should be fine to tweak these params at runtime.
     
  3. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Thanks for the reply! hmm... But for now I think I will wait and see how this asset develops further. I need something proven and really easy to use because of time constraints. Will check this again in the future.
     
  4. ShuTheWise

    ShuTheWise

    Joined:
    Dec 23, 2016
    Posts:
    3
    Hi.

    I have a question regarding camera's behavior when it's cutting water surface.

    Basically I need an event when camera is submerging or resurfacing so that i can hook up some sounds to it.

    Is anything like that available?

    Edit: Collision-based solution simply won't cut it because water mesh is moving dynamically. The best thing would be like a percentage of the view which is currently underwater.
     
    Last edited: Oct 5, 2018
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    you can simply use a trigger. in case you use gerstner waves this would not 100% accurate tho. so i am working on a script that lets you sample the water height at a given position.
     
  6. PPMike

    PPMike

    Joined:
    Jan 3, 2013
    Posts:
    2
    Hi, I've been using stochastic SSR with a custom water shader based off the unity standard standard shader but it does not have refractions which I'm sorely missing. Does Lux water support refraction along with SSR?
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    lux water uses forward rendering in order to be able to offer refractions. so no ssr, sorry.
     
    PPMike likes this.
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    version 1.05 is now available.

    change log
    # Metal: Normals fixed when using "Culling" = "Back" or "Front".
    # Metal: Deferred rendering support added.
    # Scripts added to sample the displacement/current water height as produced by Gerstner Waves.
    # Shader compilation warnings fixed.
     
    Rowlan and sjm-tech like this.
  9. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    33
    I wonder if there will be a separate shader made with this for translucency/refraction mixed with the other lux shaders
     
  10. thatsgerman10

    thatsgerman10

    Joined:
    Dec 15, 2015
    Posts:
    16
    Do you happen to have any code that gets the y position of a pixel at a x,z point with the Gerstner wave code? Asking as I need to get the y position for buoyancy calculations, I tried importing GerstnerOffset4 from LuxWater_GerstnerWaves.cginc to c# but the position I get doesnt seem to match up with what the shader is calculating.

    Here is my attempt
    Code (CSharp):
    1. Vector3 GerstnerOffset4(Vector2 xzVtx, Vector4 steepness, Vector4 amp, Vector4 freq, Vector4 speed, Vector4 dirAB, Vector4 dirCD)
    2.     {
    3.  
    4.         Vector3 offsets;
    5.  
    6.         Vector4 AB = Vector4.Scale(Vector4.Scale(new Vector4(steepness.x, steepness.x, steepness.y, steepness.y) , new Vector4(amp.x, amp.x, amp.y, amp.y)), new Vector4(dirAB.x, dirAB.y, dirAB.z, dirAB.w));
    7.         Vector4 CD = Vector4.Scale(Vector4.Scale(new Vector4(steepness.z, steepness.z, steepness.w, steepness.w), new Vector4(amp.z, amp.z, amp.w, amp.w)), new Vector4(dirCD.x, dirCD.y, dirCD.z, dirCD.w));
    8.  
    9.         Vector4 dotABCD = Vector4.Scale(freq, new Vector4(Vector2.Dot(new Vector2(dirAB.x, dirAB.y), xzVtx), Vector2.Dot(new Vector2(dirAB.z, dirAB.w), xzVtx), Vector2.Dot(new Vector2(dirCD.x, dirCD.y), xzVtx), Vector2.Dot(new Vector2(dirCD.z, dirCD.w), xzVtx)));
    10.         Vector4 TIME = new Vector4();
    11.         if (true)
    12.             TIME = Time.time * speed;
    13.         /*  TIME = _Lux_Time.xxxx * speed;
    14.       else*/
    15.  
    16.         Vector4 abcdTime = dotABCD + TIME;
    17.         Vector4 COS = new Vector4(Mathf.Cos(abcdTime.x), Mathf.Cos(abcdTime.y), Mathf.Cos(abcdTime.z), Mathf.Cos(abcdTime.w));
    18.         Vector4 SIN = new Vector4(Mathf.Sin(abcdTime.x), Mathf.Sin(abcdTime.y), Mathf.Sin(abcdTime.z), Mathf.Sin(abcdTime.w));
    19.  
    20.         offsets.x = Vector3.Dot(COS,new Vector4(AB.x, AB.z, CD.x, CD.z));
    21.         offsets.z = Vector3.Dot(COS, new Vector4(AB.y, AB.w, CD.y, CD.w));
    22.         offsets.y = Vector3.Dot(SIN, amp);
    23.  
    24.         //offsets  = Vector3.Scale(offsets, new Vector4;
    25.  
    26.         return offsets;
    27.     }
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    mixed in which way?
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    latest version ships with a utility function for this :).

    well, the shader is limited in resolution (resolution of the mesh). the script is not. this already may cause a huge difference.
     
  13. thatsgerman10

    thatsgerman10

    Joined:
    Dec 15, 2015
    Posts:
    16
    Perfect! Script works great. Doing a quick test, it set a test cube around 1.5 units below the surface instead of at it, but thats easily fixed. Thanks!
     
  14. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    33
    Mixed in how it can be the refractive/color absorb part of a standard shader
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    absorption is special to water tho...
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    you are welcome!
    and if it is a bug (that 1.5 m mismatch) just let me know please.
     
  17. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    33
    Still, a non waves/foam version of this shader mixed with other Lux Materials would be nice
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    what do you want to achieve?
     
  19. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    33
    I guess making an alternate version of this shader to be used as an overall translucency solution instead of just water. It's really nice
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    thanks, but lux plus offers deferred translucency – which makes it really fast. lux water is forward...
     
  21. gaiastellar

    gaiastellar

    Joined:
    Nov 8, 2013
    Posts:
    47
    Hi , will this work on spherical planetary terrain / spherical mesh, or a flat plane that is not orientated to y+ being up - eg orientated to meshes local up, or even uses vertex normal to define up?

    Thanks

    Paul uk
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    world axis y is up...
     
  23. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    234
    In case it helps, I've tried Aquas, Playway, Ultimate Water, Hydroform, and pretty much every other high-quality ocean shader. I bought them all but Lux is the only one I'm still using. It is a killer physically correctly water shader, has tons of nuance and detail, and keeps it simple so it interacts well with other systems (Enviro and Microsplat in my case.) Can't recommend it more highly.
     
    pixelsteam, Olander and sjm-tech like this.
  24. Diego_Graphics

    Diego_Graphics

    Joined:
    Nov 3, 2014
    Posts:
    90
    It looks very promising and also so incredibly cheap. I will definitely buy today! I would be very happy if there would soon be an HDRP support.
     
  25. Niels40

    Niels40

    Joined:
    Nov 6, 2017
    Posts:
    20
    hi @larsbertram1 .

    You water asset looks really amazing. Great job! Especially for this price.

    I do have 1 small question tho. Say i have a sailing boat. Will the interior be underwater if it is floating? Or does Lux Water actually take into account whether an object should be 'filled with water' or be completely empty?
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    it does not – but you could simply use a depth write shader like this one:
    http://wiki.unity3d.com/index.php/DepthMask
     
  27. Niels40

    Niels40

    Joined:
    Nov 6, 2017
    Posts:
    20
    Dont have any shader knowledge myself so wasnt sure whether it is an easy thing to implement. Glad its not! Il search some more info about it and will see how it goes.

    In thea meantime i bought your asset and cant wait to see it in action
     
  28. Diego_Graphics

    Diego_Graphics

    Joined:
    Nov 3, 2014
    Posts:
    90
    what can i say... wow. how beautiful this water shader reacts to light is fantastic. And with Enviro the day night rhythm is simply breathtaking. i'm really looking forward to the new versions.

    i would be happy about a HDRP support in a new update like i said before. also there are some problems with the water volume. it would be great if you could see the volume outside of it. then the volume water would even be suitable for a sidescroller. also a better inspector integration would be nice, it's a little bit more broken down into single components. nice would also be the possibility to set the water to infinity. Tesselation would also be very useful.
     
    mmaclaurin likes this.
  29. muzboz

    muzboz

    Joined:
    Aug 8, 2012
    Posts:
    68
    Hi, I just bought this.

    I'm using Azure Sky, and wondered if you could include the alternate version of the shader that the developer (Denis Lemos) has sent you, that supports his fog system?

    Thanks! All the best.
     
  30. muzboz

    muzboz

    Joined:
    Aug 8, 2012
    Posts:
    68
    I'm pulling my hair out.

    I find that I get my Water Volume working nicely, with nice caustics, etc.

    Then I save the scene, save the project, close Unity, then open it again, and Caustics are not working.

    It's a complete mystery to me.

    I somehow spent about 2 hours getting them working again, then saved, closed, opened again, and the Caustics are gone again!

    I am at my wits end.

    Can you please offer some insight?

    [If I load the Water Volume demo scene, then load my scene, it seems to jiggle something into place, and it starts working again. I have no idea why.]
     
    Last edited: Nov 9, 2018
  31. DenisLemos

    DenisLemos

    Joined:
    May 1, 2015
    Posts:
    546
    I still have not sent the modified shader to @larsbertram1 for him to test. For those who want Lux Water and Azure[Sky] to work 100% together, just follow the instructions from post #890 of the Azure[Sky] official forum.


    [Edited]
    I think it will not be a good idea for @larsbertram1 to include the alternate version of the water shader with support to work with the Azure's fog scattering because every time there is a change in Azure[Sky], he will need to update his package too.

    Instead, I'll create step-by-step tutorials showing how to modify the transparent shaders so they work properly with the Azure's fog scattering and I'll add these tutorials on the first page of the Azure[Sky] official forum so that everyone will have access to them.

    @larsbertram1 Let me know if you want an Azure[Sky] voucher in case you need some sky system to test with your assets.
     
    Last edited: Nov 9, 2018
    ftejada likes this.
  32. muzboz

    muzboz

    Joined:
    Aug 8, 2012
    Posts:
    68
    Thanks Denis, trying that now.
     
    Last edited: Nov 9, 2018
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    hmm, strange. but unity's material serialization may sometimes fail...
    so try simply uncheck/check caustics in material inspector.
     
    antoripa likes this.
  34. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    581
    You are a Crack Denis !!!
    regards
     
    DenisLemos likes this.
  35. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    33
    Any consideration for light dispersion?
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    what do you mean with that?
     
  37. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    33
    You know, how light splits into colors?
    Though I guess that can only work for still ponds..
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    oh,i guess it is already expensive enough – so i focused on the most important features.
     
  39. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    97
    When using Gerstner Waves (Vertex animation), the highlight look wrong, Did I missing something?

    small_Screen-2018-11-17_14-18-39.jpg
    Gerstner waves off, everything fine.

    small_Screen-2018-11-17_14-18-56.jpg
    Gerstner waves on, the highlight gone every where.
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    gerstner waves use a quite simple normal animation (based on unity's water 4) which does not give you accurate per vertex normals.
    but of course also the amount of subdivision of your mesh is important. your screen shoot doesn't show it...
     
  41. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    97
    OK! the subdivision is very low.
    So the question is Can lux water use for ocean? since I need a large mesh for the ocean, even low subdivision will need 10K polygon.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    it is not a dedicated ocean shader and does not support techniques like e.g. a projected grid.
    but you could create e.g. a plane divided into 9 sections where only the middle one has a high subdivision.
    mask gerstner waves by adding vertex color red (see docs: water volumes).
    then you would have to move the plane according to the camera position and the grid size you have chosen on the inner section.
     
  43. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    33
    Do the caustic lights use their own material/shader?
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,084
    Hey, that is gorgeous! Would you mind sharing a screenshot of your material inspector? I just finally got Lux Water and have been experimenting with the river demo, but can't get close to what you've got there....
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    caustics are calculated within the regular water shader (and need deferred rendering to look best): no projector, no extra material or additional shader.
     
  46. dongliang28

    dongliang28

    Joined:
    Oct 3, 2010
    Posts:
    161
    hi,lars,great work agian!
    i tried lux water with TimeOfDay sky system,and found it dosent work with the height fog effect in TOD.
    As most sky system have a height fog effect and i know it is hard to make water like shaders working with the image effect needs depth channel.
    Could you please add rendering a height fog layer on the top water shader like how you support unity native fog effect?
    and expose these parameters for us let us adjust the water fog to blend with the height fog in sky system : fog color, fog height falloff, fog density, fog start distance, height start zero level.
    Thank you.
     
    Last edited: Nov 18, 2018
  47. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    708
    Hi gecko,
    it's been a while since that test ... i will looking for this project and i'll post here my settings. ;)
     
    ftejada, gecko and Rowlan like this.
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,661
    lux water already renders to the depth buffer. but as it uses the transparent queue this will most likely be ignored by tod.
    and actually it is quite difficult if not impossible for me to support all time of day solutions out there. but a few athors added support for lux water like enviro and azure.
    maybe you should ask the author of tod to do the same.
     
    muzboz likes this.
  49. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,084
    Hmm, seems like the water shader isn't working properly for me. I get this error:

    ArgumentNullException: Value cannot be null.
    Parameter name: shader
    UnityEngine.Material..ctor (UnityEngine.Shader shader) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Shader.bindings.cs:104)
    LuxWater.LuxWater_CameraDepthMode.OnEnable () (at Assets/LuxWater/Scripts/LuxWater_CameraDepthMode.cs:36)


    in both Metal / Deferred (with ZWrite off), and Metal / Forward (with Zwrite on). Water is just kinda flat and murky, little or no effect when I change most of the sliders. Tried in several demo scenes, and my own scene. Any ideas what's not working? 2018.2.14 on Mac High Sierra.

    thanks
    Dave
     
  50. dongliang28

    dongliang28

    Joined:
    Oct 3, 2010
    Posts:
    161
    yes,that's why i suggest you rendering a height fog layer on the top and let the users adjust it to fade into other sky system.
    it should be simple and easy but useful because you could support a lot more sky systems in the future by doing this.

    your water is limited usefull because no height fog support.so it could only be used for near water rendering.
    professional artist wont use native unity fog for large scene,they will use height fog for it.
    if someone want do AAA game,height fog is the one must have thing and your water cant do the job for large scene rendering without height fog support.

    btw,i found some water systems work with TOD' height fog effect out of box(ex :suimono water ),but i really want stick with your shader,Lux plus and ATG and AFS.they are all great.

    i can drop TOD just for your shaders but i dont know the next one sky system will work with your shader or not.
     
unityunity