Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[RELEASED] Lux Water

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

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    you may have to adjust the "Edge Blend Factor" and scale of the foam.
    the foam visible on your screen shot is foam from gerstner displacement.

    you will have to setup and enable screen space reflections.
     
  2. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    123
    My problem is that there is no foam except the gerstner. Tweaking the blend factor does nothing, because there seem to be nothing to blend.



    I can see that working in your other demo scenes, but in the endless ocean it is not visible.
    Will try to reimport in a empty scene later and report.

    As for the reflextion, never used or setup screen space reflection for water but I´ll figure it out. Just thought it´s out of the box with this water.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    you may have to raise the foam's "Scale" param as well.
    then dampen the gerstner foam.
    water is rendered using forward. so it does not support screen space reflection. real time reflections instead can only be achieved using real time planar reflections: these will render the scene a 2nd time from the view of a reflection camera.
     
  4. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    123
    Thanks Lars, that helped !
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    fine.
     
  6. yankow

    yankow

    Joined:
    Apr 10, 2018
    Posts:
    7
    Hi Lars,

    I am trying to access the elements from the WaterSurface Tesselation shader though script, for instance to enable/disable Gerstner waves or foam depending on where the player is located, but haven't found in the manual how to access these. Could you help? Thanks again for your splendid water!
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    you have to look up the keyword that is connected to the feature you want to turn off/on in the shader file.
    then use Material.EnableKeyword / Material.DisableKeyword
    you have to make sure that the keyword you want to toggle uses:
    #pragma multi_compile
    and not
    #pragma shader_feature
    latter can not be changed at runtime.
     
  8. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    692

    Playing a little bit with water interaction ... awesome result with only two particles (normal and foam).

    AncientShip-LuxWaterProbesFloating.jpg
     
    Last edited: Oct 13, 2019
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    that looks brilliant!
     
  10. yankow

    yankow

    Joined:
    Apr 10, 2018
    Posts:
    7
    Thank you for your quick answer!
    I just found this: #pragma shader_feature _GERSTNERDISPLACEMENT
    So that means, in this case, that I can't control it from script, nor anything related to it, like _GSteepness for instance, right?
    But then - and forget my ignorance - what if I wanted to Enable Caustics or to modify _AbsorptionDepth at runtime for instance? How do I know what it is related to these and if they are accessible?
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    nope :)
    if you want to enable/disable it from script you have to change it to:
    #pragma multi_compile __ _GERSTNERDISPLACEMENT
    material properties like _GSteepness can always be changed via script.
     
  12. yankow

    yankow

    Joined:
    Apr 10, 2018
    Posts:
    7
    ok thank you it is becoming clearer. Still, now this is done I am having a hard time getting to the material properties via script. Let's say I want to enable Gerstner displacement, after having modified the shader script as you suggested. I would then create a script attached to my water object like this, which does not do anything (here in Start as an example, but still):

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class WaterStrength : MonoBehaviour
    {
    private Material water;

    // Start is called before the first frame update
    void Start()
    {
    water = GetComponent<Material>();
    water.EnableKeyword("_GERSTNERDISPLACEMENT");
    }
    }

    I must admit I have been looking around on this forum and in the doc to find out how to call the various parameters but I seem to be completely missing the point. Also, there is his parameter in the shader_

    [Header(Gerstner Waves)]
    [Toggle(_GERSTNERDISPLACEMENT)]
    _GerstnerEnabled (" Enable Gerstner Waves", Float) = 0

    and I could not call that one either using, say, water._GestnerEnabled = 1.
    Again sorry for my lack of competence, and thank you for your time.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    a material is no component... so:
    water = GetComponent<Renderer>().sharedMaterial;
    first it would be:
    water.SetFloat("_GerstnerEnabled", 1.0f);
    but second this would not do anything as _GerstnerEnabled is evaluated by the material editor which then enables or disables the keyword. in play mode / game there is no material editor. so you have to enable/disable the keyword by script.
     
  14. yankow

    yankow

    Joined:
    Apr 10, 2018
    Posts:
    7
    Yes, and that at least I could do. Thank you for your fast and accurate reply Lars, it works and I can develop my ideas further now.
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    fine!
     
  16. carodak

    carodak

    Joined:
    Sep 22, 2018
    Posts:
    10
    Hello,

    How can I have a clear underwater like this?


    I would like a blue water like this one, without a high depth so everything underwater look enlightened, sharp but I can't find a way to do it.

    To have a blue underwater, I decrease the strength of the light absorption but it is too dark, I want an enlightened underwater environment.

    I have another question: If I don't increase view depth, there is a separation between the limits of the plan and the water (picture attached below). Is this possible to have infinite water without those boundaries?

    Thanks
     

    Attached Files:

  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    lux water does not support light shafts – but anything else are just settings.
    you either have to reduce the light absorption (along view / along depth) or make the underwater fog "overwrite"or "kill" it by raising "Absorption cancellation". this will prevent underwater from getting too dark.
    i do not get this, sorry.
     
    carodak likes this.
  18. carodak

    carodak

    Joined:
    Sep 22, 2018
    Posts:
    10
    Thank you for your fast answer.

    Finally, the problem was that I had not add the Sun (the directional light) in "Lux Water_Under Water Rendering Script" that is attached to the camera.

    I do not have those black boundaries anymore and it is more clear and coloured!

    It's day and night. Thanks :)
     

    Attached Files:

  19. Ava42

    Ava42

    Joined:
    Aug 4, 2012
    Posts:
    9
    Hi!
    i have scene with.. many camera switches, and also sometimes several cameras render same time (sometimes cameras can be created at run-time as copy from some other camera...).
    when i did switch between cameras in code - it makes a lot errors, and render fails (till re-enable some scripts on cameras, or manually copy some scripts from camera to camera.) is there any way to not keep luxwater scripts on camera, and make it work properly on all scene cameras? also impossible get render of 2 underwater cameras at same time.
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    ah, that screenshot looks nice!
    well done!
     
    carodak likes this.
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    when switching camera all cameras need the script components of course.
    using multiple cameras at the same time however is not recommended at all: this will slow down all your rendering. this is nt related to lux water but a general issue. why do you use multiple cameras at the same time?
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    yes, the underwater rendering needs the sun (to get position, direction and color) to lit the underwater. it is an image effect so it does not have any knowledge of the lighting in your scene. so you have to provide it via script.

    but 15fps and 65ms on the cpu are not nice... what is ging on there?
     
    carodak likes this.
  23. carodak

    carodak

    Joined:
    Sep 22, 2018
    Posts:
    10
    I think it is because I am running Unity with a MacBook Pro 2015. It looks less laggy when my colleagues run it on the desktop.
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    i am running it with a mac book pro from mid 2014.
     
  25. yiyingwu

    yiyingwu

    Joined:
    Aug 9, 2019
    Posts:
    1
    Could I control the wave scale in Lux Water?
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    yes, you can.
     
  27. Ava42

    Ava42

    Joined:
    Aug 4, 2012
    Posts:
    9
    i know its slow, but steel i have tasks to make it work. I can make 2 cameras water rendering, but underwater blur does not activate on both. Cameras have under water blur and trigger scripts as well




    p.s. right after adding a screenshot i figured out how to make it work. i just disable and enable water volume script.
     
  28. carodak

    carodak

    Joined:
    Sep 22, 2018
    Posts:
    10
    I am using occlusion culling, number of bashes are pretty low..
    What could it be?
    Could it be that I am running an old version of Unity like 2017.1.x?
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    i wrote lux water using 5.6.3. so i doubt that.
    but – er – i forgot the original question and had to look it up again: 65ms in the cpu.
    it might be just the time the cpu is waiting for the gpu to finish rendering.
    does your mac book already have a retina display? und do you run unity at full res?
    then this would expalin it: retina at full res is like 4k? way too much for the rather weak gpus.
    i always run unity at low res (finder -> info -> check: open in low res).

    would be good if you could share a screen shot from the profiler to see where all the cpu goes...
     
  30. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    314
    Hi,

    I had to turn off "Enable Deepwater Lighting" and now my water is black when I get on the same level as the water



    it works if I look from above



    If you ask why I turned off Deep Water Lighting, its because if I leave it on and go in the water, then I go out my whole beach turns black



    The water also gets black if I get closer and have the Deep Water Lighting enabled.

    Is there any solution to this issue?
     
    Last edited: Oct 23, 2019
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    sorry, but i do not really get the problem here.
    your screen shots look strange tho.
    regarding deep wter lighting: have you set up the water height properly?
     
  32. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    314
    Yes I have set it to 70 but it makes no difference. As you can see on the first screenshot the water is black when I get close to it and then if I go away from it (I think the height matters here) it becomes blue as it should be.

    I dont want the water to turn black.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    just disable the water and keep deepwater lighting. all it should do is killing the directional light below the given height in world space.
    adjust the height property until you get a decent result regarding light attenuation.
     
  34. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    314
    I found where the problem is - I have 2 more water planes on the same island which are way higher than the ocean, if I disable them the problem is gone and the water doesnt become dark, but how can I keep them enabled I need multiple water sources on the same island?

    The ocean Y is 70, the ponds are 126 Y
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    hmm, use box colliders to set the height?
    or just make the ocean rule deep water lighting only. ponds i guess are not deep enough to cause attenuation regarding the directional light.
     
  36. carodak

    carodak

    Joined:
    Sep 22, 2018
    Posts:
    10
    Wow, I didn't know about this! Thank you very much! Yes, I have a Retina display and I didn't pay attention about the res, I guess I ran it at full res. So now, I have between 20 and 40fps and my CPU is about 40ms.
     

    Attached Files:

    • sc3.png
      sc3.png
      File size:
      404.1 KB
      Views:
      16
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    :) it is a trap.
     
  38. onefaceoneface

    onefaceoneface

    Joined:
    Dec 7, 2017
    Posts:
    3
    IMG_1036.PNG IMG_1037.PNG IMG_8808.PNG IMG_1036.PNG IMG_1036.PNG IMG_1037.PNG IMG_6317.JPG IMG_8808.PNG
    I builded the deep water forward render scene with setting opengles3 and then tested it in three device:iphone6s,iphone6,iphonese,but only the water is ok only in iphone 6(below) IMG_6317.JPG )
     
  39. onefaceoneface

    onefaceoneface

    Joined:
    Dec 7, 2017
    Posts:
    3
    the wave of the waterplane also looks not smooth in iphone6s and iphone se.the scene has no change except the joystick control.I trying to upload the video
     
  40. onefaceoneface

    onefaceoneface

    Joined:
    Dec 7, 2017
    Posts:
    3
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    i think i have seen something like this before but can not find it or remember details, sorry.
    first thought: broken normals.
    but if you have a closer look you can see very detailed reflections...
    so my 2nd guess: caustics?
     
  42. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,140
    any way to get the underwater effect render on android? I can't get it to work on it.
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,265
    i am not on android – but i think other users managed it to work...
     
  44. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,140
    All I have to do is switch to Android the editor and the underwater effect and several other things will be gone.

    Also, please check with 2020.1 alpha. All underwater demos don't work, not even on pc.
     
    Last edited: Oct 29, 2019
  45. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,140
  46. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,140
    how can we do this? I don't need the wave, but i do need that foam generated by the boat. Any graphics or anything we could use would be awesome, it will add lot to the scene.
     
  47. AHFontaine

    AHFontaine

    Joined:
    Aug 3, 2017
    Posts:
    6
    Hi, I'm trying to incorporate "Curved World" to it. I'm going through the Core cginc Vert section to insert one line to get a curved effect but I can't seem to find the right spot to insert it.
    I was wondering if it's incompatible due to how verts are being displaced by the waves function, or am I just not finding the right spot to do this?
     
  48. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    692
    You can find similar setup in the demo scenes "04 LuxWater Water Projectors Demo"
     
    Last edited: Oct 29, 2019
  49. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,140
    I don't find a nice boat wake like that... you've got it from there?
     
  50. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,140
    I'm getting a very annoying white/border line around every object. Similar to a toon like shader. Even when I'm not on top of the water. My mountains, player, bridges, everything gets that extra weird line (black or white, not sure what color it goes). It's very annoying and I've tried changing it to "pixel", "MSAA_4x" snapping, removing z-test and write buffer. Nothing fixes it. It makes the whole scene look so bad... what's the trick so I don't get that?