Search Unity

[RELEASED] Lux Water

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

  1. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    244
    Yes - I noticed. Which is great btw :)

    No - it worked out all right. I was able to caught other cameras trying to trigger the OnWillRender... I can't recall why I referred to tried. Sorry for that.

    About a farclip override.
    I couldn't get it this work. I remember implementing it in our own cubemap reflection script (for cars) a long time ago and it was working. I know there is/was an 'issue' with a custom projectionmatrix not using or overriding the farclip. However I am/was basing this on an old post on here and I am unsure if this is still an issue or even related to how things work in Lux.

    Nevertheless, as I said, I didn't spend too much time looking into it - always pressed for time here - and I had good results with implementing layerCullDistances as well.

    Would be great to have both though ;)

    EDIT: @larsbertram1 I misread your post. Edited accordingly.
     
  2. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    Hi.
    I have a problem that I summarize in 3 images.

    1- Photo of the sea in the editor.
    2- Photo of the sea in the editor, having pressed PLAY
    3- Photo of the sea in the editor, having pressed PLAY and activating-deactivating the "USES WATER VOLUME" option of the WATER OCEAN material

    In "standalone" mode it appears as in photo 2

    I need your help.

    Unity version 2019.2.9f1
    Lux Water updated to latest version

    Regards

    LUX_1.png LUX_2.png LUX_3.png
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i assume that you have not set the water y position properly.
    so when you hit play, the underwater rendering script assumes that you are underwater – and forces the water shader to go into the underwater mode.
     
  4. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    65
    @larsbertram1 ?
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i don't know... i once started to work on it... but it stalled.
     
    no00ob likes this.
  6. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Re: Planar Reflections in scene with multiple rivers and lakes:

    Okay. But I don't see anywhere to assign the plane to use?

    Also (and mainly): I mostly only want Planar because it gets a better skybox reflection. See screenshots -- first one is without Planar Reflections, second one is with Planar, with Reflect Skybox enabled but Reflection Mask=Nothing. Just getting Planar reflection of the skybox (Enviro skybox) makes a huge difference. But is that surprising? Why wouldn't Lux grab that without Planar enabled? Or is something else going on here to create that lighter blue surface?

    river lux no planar.PNG
    river lux planar skybox only.PNG
     
  7. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    65
    Okay that's fine. Will figure it out myself.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    lux grabs the reflection probe which gets fed it by the unity engine. if enviro does not overwrite the scene's skybox, and there is no local one you will get the built it one.
    if there is a local one the river will grab the one closest to its pivot which might be very far away in case you have a long river.

    lux water does not do any magic when it comes to reflections but fully rely on the unity engine.
     
  9. unityrlmg

    unityrlmg

    Joined:
    Nov 7, 2016
    Posts:
    6
    Hi,

    I'm having a little trouble integrating a fish with a semi-transparent texture into the underwater fog (the camera and fish are both underwater). I have limited experience writing/editing shaders so any help you can give me would be greatly appreciated! As an example, when I switch the Standard shader's Rendering Mode to "Fade" or "Transparent" the fish no longer disappears "into the mist" (so to speak). I'm not sure if it makes a difference but I'm using the deferred rendering path. I really love your asset and am just trying to overcome this last hurdle in creating my scene.

    Thanks! :)
     
  10. bangell

    bangell

    Joined:
    Dec 4, 2015
    Posts:
    3
    Is anyone seeing issues with infinite ocean demo and android? I am seeing black in the sun reflection (missing , however I do not see that on windows/mac os. All I did was take the infinite ocean demo and build for android (turned off z-write). Anything else I need to do? Thank you in advance

    Nvidia SheildTV Android 9.0[
    od.png
     
    Last edited: Nov 12, 2019
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you have to use one of the transparent shaders that ship with the package. please have a look into the deep water demo.
     
  12. unityrlmg

    unityrlmg

    Joined:
    Nov 7, 2016
    Posts:
    6
    Thanks for getting back to me, I had looked into those. The issue is that I can see through the fish with the included shaders. A two-sided shader works for the fish model but then isn't affected by the underwater fog. It looks like I'll need to try and figure out how to turn one of the included shaders into a two-sided version. If you have any hints please let me know! Thanks
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you have to declare:
    Cull Off
    in case you need double sided lighting you also have to use vface and flip the tangent normal accordingly.
     
  14. unityrlmg

    unityrlmg

    Joined:
    Nov 7, 2016
    Posts:
    6
    Thanks, I really appreciate the info. Unfortunately this is a bit beyond me at the moment but I'll keep at it. Unless I can figure it out soon I'll have to abandon your asset for this project... which is a shame because it looks amazing! I'd happy buy an expansion pack with double sided shaders if you have them too ;)
     
  15. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    erm... you just have to open the shader file and add those words "Cull Off".
     
  16. unityrlmg

    unityrlmg

    Joined:
    Nov 7, 2016
    Posts:
    6
    I added "Cull Off" to the shader but it didn't help.
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    give me a moment...
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    this is a basic surface shader which does double sided rendering.
    it renders backfaces and support proper back face normals using vface.
    i added 3 comments where the magic :) happens:

    Code (CSharp):
    1. Shader "Custom/DoubleSided" {
    2.     Properties {
    3.         _Color ("Color", Color) = (1,1,1,1)
    4.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    5.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
    6.         _Metallic ("Metallic", Range(0,1)) = 0.0
    7.     }
    8.     SubShader {
    9.         Tags { "RenderType"="Opaque" }
    10.         LOD 200
    11. //    Disable back face culling
    12.         Cull Off
    13.      
    14.         CGPROGRAM
    15.         #pragma surface surf Standard fullforwardshadows
    16.         #pragma target 3.0
    17.         sampler2D _MainTex;
    18.  
    19.         struct Input {
    20.             float2 uv_MainTex;
    21. //    Add facingSign to the input structure
    22.             float facingSign : VFACE;
    23.         };
    24.  
    25.         half _Glossiness;
    26.         half _Metallic;
    27.         fixed4 _Color;
    28.  
    29.  
    30.         void surf (Input IN, inout SurfaceOutputStandard o) {
    31.             // Albedo comes from a texture tinted by color
    32.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    33.             o.Albedo = c.rgb;
    34.             // Metallic and smoothness come from slider variables
    35.             o.Metallic = _Metallic;
    36.             o.Smoothness = _Glossiness;
    37.             o.Alpha = c.a;
    38.  
    39. //    Flip normal according to IN.facingSign
    40.             o.Normal = half3(0,0,1);
    41.             o.Normal.z *= IN.facingSign;
    42.         }
    43.         ENDCG
    44.     }
    45.     FallBack "Diffuse"
    46. }
    47.  
     
    unityrlmg likes this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i would recommend to edit the "Lux Water/Underwater/Transparent Premultiply" shader.

    find line 42: LOD 200
    after this line you insert:
    Cull Off

    find line 95: float depth;
    after this line you add:
    float facingSign : VFACE;

    find line 146ff:
    #if defined(_NORMALMAP)
    o.Normal = UnpackScaleNormal(tex2D(_BumpMap, IN.uv_MainTex), _BumpScale);
    #endif


    here it gets a bit more complicated as you have to replace all 3 lines with this code:
    #if defined(_NORMALMAP)
    o.Normal = UnpackScaleNormal(tex2D(_BumpMap, IN.uv_MainTex), _BumpScale);
    o.Normal.z *= IN.facingSign;
    #else
    o.Normal = half3(0,0,1);
    o.Normal.z *= IN.facingSign;
    #endif


    that is all.
     
    Last edited: Nov 12, 2019
    unityrlmg likes this.
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    let me know if this helps.
     
  21. unityrlmg

    unityrlmg

    Joined:
    Nov 7, 2016
    Posts:
    6
    Thank you for your your help, I really appreciate it. And sorry for my delayed response, I've been trying to figure out the issue but so far am unable to achieve the right look for the fish. With the modified "Lux Water/Underwater/Transparent Premultiply" shader I can still see through the parts of the fish with full alpha... almost as if it's made of glass...

    Lux_Water_Underwater_Transparent_Premultiply_DoubleSided.png

    Using an example "double sided" (modified Standard) shader the fish isn't see through but the underwater fog isn't respected when it moves off into the distance...
    StandardSpecular_Edited.png

    I'm sorry if my description of the issue has thus far been lacking, hopefully the images help. This isn't the final version of the model's texture but shows a rough example of the transparency I'm hoping to achieve in parts of the fins. I really like the look of the water and don't want to give up on it... even though I'm a bit out of my depth (that was a horrible pun really :p). Let me know if you have any more advise, it's been super helpful.
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it is a transparent shader. so it assumes that the things are somehow like glass.
    transparent shaders do not write into the depth buffer. so both sides of the body of the fish are rendered: you explicitly disabled back face culling...

    if you need smooth transparency on the fins you have to split up the model into 2 materials:
    body and eyes should use a standard opaque shader (the standard shader). as it writes to depth and culls back faces it will not have any problems like in your first screen shot. underwater fog will be added by the image effect.

    the fins may use the modified transparent shader. they must be made out of single sided geometry. so they do not have any thickness.

    you may get a little discontinuity between body and fins tho – as the transparent shader only mimics the fog as calculated by the image effect. if this look too distracting you will have to use alpha testing as this writes to depth.
     
    unityrlmg likes this.
  23. unityrlmg

    unityrlmg

    Joined:
    Nov 7, 2016
    Posts:
    6
    Thank you so much, you’ve been extremely helpful. I’ll try moving forward with a multi-material approach. Your support, and the asset itself, are both incredible. I really appreciate it.
     
    no00ob likes this.
  24. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    With Planar Reflections deselected, I tweaked the Enviro Reflection strength and can see the effect on the river, so Lux Water is actually picking up the Enviro Reflections. So that's good. And I realize that what provides that bluer color (screenshots here: https://forum.unity.com/threads/released-lux-water.536631/page-20#post-5164328 ) to the river when Planar Reflections is enabled is from Reflect Skybox -- is that forcing it to grab the Enviro skybox? Is it simply not using any skybox otherwise? Is there a performance impact from enabling Reflect Skybox?

    thanks!
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    that looks like an overflow of the specular value. win and osx use float – android (gles30?) most likely half.
    so one would have to clamp the specular value in the lighting function.
    you can first try to set smoothness to e.g. 0.1.
    but already you screen shot shows that specular looks ine – except from the very inner specular highlights.
     
    bangell likes this.
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you may also have to increase the size of the enviro reflection probe. if you have a lake like 2000m away from the camera it will not be covered by enviro's reflection probe and fall back to sky.
    if the renderer component is set to "reflection Probes" = "Blend Probes and Sky" and the river is inside the volume of enviro's probe unity should send both probes (enviro and sky) and the shader will blend them. "simple" will make unity only send the probe from the skybox – i think.
    lux water lets you enable planar reflections only... the shader will sample the skybox or a local reflection probe otherwise. or even blend between both according to the settings on the renderer component.
     
  27. bangell

    bangell

    Joined:
    Dec 4, 2015
    Posts:
    3
    Thanks, that did it! The documentation should document that the demos need to change for mobile.
     
  28. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    The reflection probe follows the player, and the box size is set to 25000 cube, so I don't think that's the problem...

    That's set to Simple on objects in this scene, and dimmed/disabled so I can't select anything else. But in Graphics Settings, Blend Reflection Probes is enabled for all tiers.

    How do I do that?

    Thanks, and sorry this is such a pain.

    Dave
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    well, that is nothing but a dirty "fix".
    that is nothing but a dirty fix.

    you may try to "really" fix it so you are able to get nice and crips specular highlights on android as well.

    open the "LuxWater_Core.cginc" file and find line 1011:
    specularTerm = max(0, specularTerm * nl);

    after this add the following lines:
    #define LW_HALF_MIN 6.103515625e-5
    specularTerm -= LW_HALF_MIN;
    specularTerm = clamp(specularTerm, 0.0, 100.0);

    let me know if this fixes the problem on android.
     
    bangell likes this.
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    its a checkbox in the material. of course this will not create a reflection camera and set it all up. it only makes the shader sample a global 2d texture (which must be provided by the reflection script) instead of a cubemap.
     
  31. bangell

    bangell

    Joined:
    Dec 4, 2015
    Posts:
    3


    Ok i created a new project and imported Lux ocean again just to make sure i had default settings.. I did the change to the include file and it worked.. thank you so much. the smooth setting was left at .92 I tried infinite ocean and a few of the other demos.
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    thanks a lot for reporting!
    i will add that code then to the official package :)
     
  33. recaremo

    recaremo

    Joined:
    Jun 13, 2019
    Posts:
    5
    Need more help. I want to use Lux Water in a FPS Adventure. I added the known scripts to the FPS camera but I don't get a view underwater. Is anyone here to create a good video tutorial for newbies in Unity and Lux Water????? Maybe create a scene from scratch.

    • All demos working well.
    • using the same parameter as demos used
    What I've to do that it worked with my FPS camera?
    In the upper left corner following information is shown:

    Active water volume: none
    Registered volumes: 1

    How can I disable this info?
     
    Last edited: Nov 22, 2019
  34. cruising

    cruising

    Joined:
    Nov 22, 2013
    Posts:
    329
    I have some problem with white outlining on objects at the water surface, how can i fix that (Unity 2019)?
    You can see on the ships and on the airplanes wheels that they have a white outlining.
    On my terrains i have a lot of trees, i have Fade length = 250 and Billboard starts = 0 to be able to have a big amount of trees for a low cost for the fps.
    As you can see it is a flight game and i dont need good quality on the trees because you are high in the sky anyways. However, when you fly low over the terrain the visible water cuts the billboards of the trees as shown in the picture, any fix for that to?
    Svea Lejon White outlined.png Svea Lejon White outlined2.png Svea Lejon Tree Cut Of.png
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you may tray pixel snapping.
    please have a look into the documentation:
    https://docs.google.com/document/d/...m38h-u3Az-ozaaOX0/edit#heading=h.w7fbhma9yexu
    in case you use forward rendering and msaa you even may disable ztest as shown in the docs.

    regarding the billboards:
    you have to make sure that they get rendered before the water. do so by editing the render queue in the billboard shader or the water.
    if you want to edit the billboard shader you have to download the shader resources from unity. then copy the billboard shader into your project and edit it.
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    what is the problem?
    have you enabled debug in the underwater rendering script?
    it should give you proper feedback if you have entered a water volume collider (which is a trigger) so that unter water rendering may kick in.
     
  37. cruising

    cruising

    Joined:
    Nov 22, 2013
    Posts:
    329
    Thank you! It was the camera that i had to set to "Legacy deferred"
    About the render queue, how do i change that in your "Lux Water/WaterSurface Tessellation"?
     
  38. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    65

    Change that to a different value so the water renders before the billboards.
     
  39. cruising

    cruising

    Joined:
    Nov 22, 2013
    Posts:
    329
    Ah it was just that simple, thank you!
     
  40. recaremo

    recaremo

    Joined:
    Jun 13, 2019
    Posts:
    5
    I made a short video, hope it explain my problem better.
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    the volume is always inactive.
    probably because physics will never register any trigger due to a missing collider on your camera. at least i could not see any.

    from the docs:
    1. Add the “LuxWater_WaterVolume.cs” script to your water plane.

    2. Assign a proper “Water Volume Mesh” to the corresponding slot in the script inspector.

    3. Add a box collider to your water plane, make sure it has a proper size and check “Is Trigger”.

    4. Make sure that your camera has a collider and a Rigidbody assigned. Check “Is Kinematic” in the Rigidbody inspector. Then add the “LuxWater_WaterVolume-Trigger.cs” to the camera.
     
  42. recaremo

    recaremo

    Joined:
    Jun 13, 2019
    Posts:
    5
    Thanks for help, I'll test it soon.
     
  43. recaremo

    recaremo

    Joined:
    Jun 13, 2019
    Posts:
    5
    I've forgotten point 4. of your instructions. Now it works. Sorry, I didn't read the complete documentation because I was very confused. I'm more a "visuell" learner. :)
     
  44. cruising

    cruising

    Joined:
    Nov 22, 2013
    Posts:
    329
    Will there be a update with floating objects support that are affected by the waves in future?
    I want to able to land my Grumman Goose aircraft on this beautiful water.
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i don't think so. physixs is nothing i am into.
    but you can use dynamic water physics 2 together with lux water:
    https://assetstore.unity.com/packages/tools/physics/147990
     
  46. cruising

    cruising

    Joined:
    Nov 22, 2013
    Posts:
    329
    Yes i saw that water physics, but a bit costly to just have a object floating on water, i dont need any vehicle scripts from it. And it cost like 3 times more then the actual water -_-

    And i dont know if i have missed this on your water , but is there any shore support in Lux? The waves is constant even near the terrain and the waves pop ups from under the terrain where it is low.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    the "10 ocean demo" shows some spheres floating on the water using a quite simple script.
    so this might already cover you. and dwp2 is rather cheap for what it does. it is not dwp2 fault taht lux water is even cheaper :)
    no, there is not. lux water was not written with oceans in mind. it works on any custom mesh be it lakes or rivers.
    and with some more work you may even create an endless ocean...
     
  48. avivoren

    avivoren

    Joined:
    Sep 21, 2014
    Posts:
    42
    How can I make a depth mask ? Like if I have a boat I don't want to see the water inside it, don't render the water inside the boat. I hope you understand what I mean.
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you can use a depth only shader that masks the inside of your boat.
     
  50. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hi @larsbertram1, I wasn't sure if this was answered but are there any plans for URP support? I loved how Lux Water looked and was sad to lose it in the conversion, and I wasn't sure if you were putting your focus on the LWRP Essential package instead. I've got both but would love to get the underwater functionality back. Thanks.
     
    ProtoPottyGames likes this.