Search Unity

[RELEASED] Lux Water

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

  1. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Hey, I am using OverCloud, and trying to make it work with Lux Water. Got a problem though and I was hoping that you might help me out.

    Here is what happens when I am underwater: http://prntscr.com/om5ubd

    Seems to me that underwater fog is drawn before the clouds or whatever this is, and water surface from below is drawn after the clouds, thus it creates a thin line at the meet point. Which gets fatter, deeper you go.

    Here is the frame debugger:
    https://gyazo.com/5bf2c042f629d8b1379957622a29aad5

    Id really love it if I could use the assets together as they look great except for this. Can you please help me out?

    Thank you.
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    Edit: I had a closer look at your capture of the frame debugger (great thing!) and i think that the "thin line" you get is the gap between solid geometry (terrain) and the water surface - or the hemisphere used for cloud rendering and the water surface.

    due to the rendering order:
    1. underwater
    2. clouds
    3. water surface from below​
    only the water surface from below may occlude the clouds.

    but we need the underwater post effect to do so as well.
    so my first try would be to move the cloud rendering from CameraEvent.BeforeForwardAlpha to CameraEvent.AfterSkybox.
     
    Last edited: Jul 31, 2019
  3. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Fewes likes this.
  4. avivoren

    avivoren

    Joined:
    Sep 21, 2014
    Posts:
    42
    Hey how does it work with large map ? I'm looking for huge infinite water - about 100-200km^2 plane with shader.
     
  5. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    310
    Hello,
    I have a beautiful ocean with a summer sky. How to change the color of the ocean with a stormy sky? I want to be able to change that during the game
    Thank you
     
  6. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    872
    Enabling Gerstner waves causes the shader to break in play mode. What would cause this? In Unity 2018.4.4.

    With out waves enabled it works fine.

    upload_2019-8-3_13-1-18.png

    upload_2019-8-3_13-2-56.png
     
  7. atiwari1

    atiwari1

    Joined:
    Jan 10, 2019
    Posts:
    4
    Hi Team,

    Greetings of the day.
    Thanks a lot for the great asset.

    I am using "_WaterPlane" gameobject of scene "04 LuxWater Water Projectors Demo".

    I have one query that water has different output for the different build platforms. I want to use it for "WebGL" platform but it does not look as good as in "PC, Mac& Linux Standalone" platform. I tried changing properties of this asset, did not help.
    With the same property of the material it has different result for two kinds of the build platforms.

    Thanks
     
  8. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I'm getting strange artefacts all over the screen in the ocean demo, any ideas? I'm on 2017.4.x On a Mac with Metal enabled.
     

    Attached Files:

  9. glenneroo

    glenneroo

    Joined:
    Oct 27, 2016
    Posts:
    231
    I was just at Siggraph 19 in LA showing our VR art project and I guess about 80% of the people (visitors and other exhibitors) said the best part was above and below water and it was the best they ever saw (combined with Hx Volumetric Lighting when underwater). Even 2 professional divers said going underwater was just like real life, which made me very happy :D Of course I always told them it was only possible thanks to LUX Water :D but I also said it needs some time to make it work in VR... so I really hope you get a lot more purchases soon! You may also get more inquiries how to make it work in VR... ;)
     
    KarloE and Baldinoboy like this.
  10. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175


    Hmm. It might not be that then, for me it only happens when im looking at the terrain, when I go pass the terrain it doesn't happen anymore.

    I just removed overcloud and put simple skybox wiith a simple directional light, thus this looks screwed I guess, but you can clearly see that the artifacts appear directly over the terrain shape.
    https://i.gyazo.com/34a86dbec046a30f49cc1eef1fff6ece.mp4

    (Im gonna do a fresh import now to completely isolate overcloud from the project and re-test it because for me it happened in the ocean demo as well, just not as visible.)

    Ok so I did a fresh import, opened the 11 Lux Water Ocean Demo.unity scene, and looked at the terrain from underwater, the artifact are clearly showing:
    https://i.gyazo.com/8f0ca19f2ffa654b4fe521485ead711f.mp4
    http://prntscr.com/ordcnx

    They are showing when I look at the terrain, and never show when im not. Furthermore, my skybox is black(I just brought exposure back to 0 in the scene, didnt change a thing except for that, since its a fresh import in a clean project) - so its not the skybox: http://prntscr.com/ordd0l

    Im trying to catch it in frame debugger right now, will follow back if I manage to do it.
     
  11. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Last edited: Aug 12, 2019
  12. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    872
    @larsbertram1 any ideas as to why gerstner waves don't work in play mode for me? I really need this water to work soon :/
     
  13. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Can't you simply run the demo scenes and compare?
     
  14. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    872
    It does work in the demo scenes but not in my scene event if i readd the prefab and disable every object :/
     
  15. BetaJester

    BetaJester

    Joined:
    Oct 12, 2016
    Posts:
    3
    Are you using 2019.2? Because I had the same issue where, with certain shaders, the waves just wouldn't move. There were also alpha issues all over the place and lots of inconsistencies
     
  16. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    872
    No i'm in 2018.4 :/
     
  17. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    243
    Hi all!

    We're currently trying to setup Lux and Aura 2 in our project.

    I have adjusted the Lux shaders to work with Aura 2 and the results are starting to look good. However - there seems to be an odd issue going on. At the moment when a light 'intersects' the water plane the 'bounding box' of the light seems to be rendered in the water plane. See screenshot.



    I understood Aquas had a similar issue going on in a past release (even without using additional third party assets like Aura 2 or similar).

    Has anyone encountered this and how can this be fixed?
    Any help greatly appreciated!

    Pieter
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    sorry, i did not get any notifications for a while...
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    lux water may slide the water planes and volumes, so i guess the answer is yes.
    i have only tested it for 6x6 km tho.
    a single plane however never should have the size of 100-200km^2. you should use multiple smaller planes – like 500x500m – and move them with the camera. otherwise you will not benefit from frustum culling at all.
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    actually: no. what platform, settings do you use?
    and have you checked the demos? do they also break in playmode?
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    aura 2 is not supported at the moment. i will have to look into it some day when i find the time to do so, sorry.
     
    PieterAlbers likes this.
  22. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    243
    Thanks for the reply - much appreciated!

    Would love to use Lux instead of other solutions since I find it to be a much better allround asset.
    I will give it another shot - see if I can find a workaround.

    If you do find the time or have slight idea where the issue could be find please let me know as I can help out with test scenes etc.

    -Pieter
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it looks as if the fog is doubled. you must apply fog only in the first forward pass (main directional light). any additional pass (for any point or spot light) must not add fog.
     
    PieterAlbers likes this.
  24. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    243
    You're a life saver! I had my suspicions, but after another look at it I think I have a workable solution.
    I am now indeed skipping the fogging in the forwardadd pass.

    For anyone else - fastest solution would be (without adding another vertex of frag function) is to NOT to include the FOG_AURA define in the LuxWater_Setup.cginc, but add the define only to the ForwardBase pass.

    Looks great and I can use the projectors which I was aiming for!

    Great work on the asset and thanks for jumping in!

    -Pieter
     
  25. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    @larsbertram1 can you please take a look at my posts up there when you get a minute. Thanks. :)
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    white cracks may be caused by tessellation of the water volume.
    i can't think of any relation between water volume and the terrain.
    to check:
    - disable tessellation
    - have a look at the underwater mask texture. it is rendered at the beginning of the frame. usually red and green should match seamlessly – but sometimes you get tiny little cracks.
     
    KarloE likes this.
  27. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Thanks @larsbertram1

    OK couple of things I found out:

    1. yes it has something to do with the gerstner waves, when those are disabled its gone.
    2. it is ONLY visible when terrain or a 3d object is present, here is a video, it is wshort but believe me there is 0 occurence when I disable the terrain
    3. I tried it out with a 3d object underwater, looking at him, it happens also but quite a bit less visible. maybe it is because of the terrain curves/shape? not sure. maybe it is happening while there is no object/terrain actually but its so tiny its not visible. not sure why terrain or an object would influence the visibility of the artifact
    4. I think this is what you were talking about? https://prnt.sc/ot52jy

    EDIT: Yeah it is a problem with cracks in the water mask. Ill try fiddling with the code and see what I can do about it, what else.

    Thanks for the help
     
    Last edited: Aug 15, 2019
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    oh, i have never seen something like this before! red with in the dark green means: surface from above (red) in surface from below (dark green). this should never happen! you can not see both surfaces at the same time – obviously.
    are you using very high gerstner waves?
    but maybe vface bugs...

    i was talking about something like this, a black one pixel hole in the mask:

    crack.png

    but i haven't seen these for quite a while and hope i eliminated almost all of them.


    neither the terrain nor any other geometry is involved when it comes to rendering the underwater mask. only the volume mesh.
     
  29. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    @larsbertram1
    These black holes in green are the main reason it shows, so you are right about that.

    I am basically using the same ocean as in your ocean example scene, just slightly tweaked.

    Now I went to test if the issue is visible in the frame debugger when I look away from the terrain, and look, I actually caught another instance of the "red" : http://prntscr.com/ot7dby

    It doesn't manifest in the final image though: https://gyazo.com/b00e5f09f1513029f2e55dcc7d6f3ab4

    I found the code that controls the mask creation (watermask shader), and I found your reduce cracks code as well there, so Im hoping Ill figure it out and fix it somehow, because the cracks are super visible and I simply can't have that in game. :(
     
    Last edited: Aug 15, 2019
  30. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    w
    weird
     
  32. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    @larsbertram1
    Probably you know that, but with further research I concluded that the black cracks are fault of the vert part of the watermask shader, and red ones are fault of the frag part.

    What im trying to figure out is, can't it just be done the way that green is drawn on top of the green 2 and then on top of the red, or something, that way there would be no black cracks at least.

    Or would that screw up with the underwater transparent particles somehow?

    My shaders are a bit rusty so takes me bit time to go through it and figure it out. :)
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    what faults of the vertex part and fragment parts are you referring to?
    reagrding your suggestion of doing 3 passes: i was lucky to get it down to only 2 passes using vface... (which distinguishes between red and green for the water surface).
     
  34. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    @larsbertram1
    So basically, what casues red bits in the mask where they shouldn't be is the frag part of the shader is somewhere in lines 398-419 (frag part, pass 3 of the watermask shader)

    and vertex part of the same pass causes the black "holes" in the mask, your "reduce cracks" bit, but of course if that is removed then there are cracks along the intersection line.

    I found that out by testing while frame debugger was frozen on a crack bit, so I changed up the code and found problematic bits.

    The way I see it, the possible solution here if there is no other, would be to draw another pass for the "no water" part, above water surface. that way, that color could be used for no water, and the black bits can just be considered water as well, which would make the cracks invisible. This is just a suggestion of course, I am nowhere near the expert as you are for this im just trying to figure it out somehow because it simply is not good enough as it is now. And I so much want it to be Im so happy with every other aspect of this water. :)

    I don't know why you don't see those cracks as much as I do, but maybe it has something to do with unity version? 2019.1.11f1 is the one I use, clean projecta and ocean scene, looking towards the terrain should do the trick. No clue why it would matter but I can't figure out how are you missing how terrible those are. :)

    Another solution which keeps the same amount of passes is using a mask color for the "no water - above water" part, mask color for water surface, and one for surface from below, leaving the no-color for underwater. That way, the cracks would appear between water surface and "air" and would be barely visible/invisible, and the problematic part that it is now would have no cracks as cracks would be considered underwater - if I am making sense.

    Basically just (almost)flip the thing upside down, mask colors wise, so that the problematic layers are the ones where the problems will be hardest to notice.

    I have no clue if it is problematic to mask out the no-water part of the screen, I guess not? Not sure, just throwing ideas out there. :) Of course maybe I understood the system wrong in this limited time and am talking nonsense, if yes, sorry about that. :)
     
    Last edited: Aug 15, 2019
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i do not think that this will work... as no-water is: everything - water. and that is what the underwater mask shader currently does.

    anyway: optimizing the water mask shader reduced the amount of cracks a bit more.
    at the end of pass 3 and 5 the shader goes back from world to object space and then from object to clip space (which is from object to world and then to clip space). this is a) not really performant and b) needs 3 mul which may increase the discrepancy.

    so commenting the line "v.vertex = mul(unity_WorldToObject, wpos);" and writing o.vertex directely from wpos should enhance it:

    //v.vertex = mul(unity_WorldToObject, wpos); // No need to go back here to object space...
    o.vertex = mul(UNITY_MATRIX_VP, float4(wpos.xyz, 1.0f));
    #else
    // No gerstner waves -> no wpos so we have to use v.vertex
    o.vertex = UnityObjectToClipPos(v.vertex);
    #endif

    i also looked into lowering the precision of wpos using:
    wpos = floor(wpos * 100.0f) * 0.01f;
    instead of:
    wpos = floor(wpos * 1000.0f) * 0.001f;

    using both the amount of cracks went down further more as far as i can say.
     
  36. Hexaedre

    Hexaedre

    Joined:
    Jan 23, 2015
    Posts:
    110
    Hi,

    Do your water system works with non-horizontal water planes ?
    Could I make pools with underwater effects in this type of environment ?



    The caustics working too would be the cherry on the cake. Is it possible to see them like if they are casting from a side or from bottom ?

    Cheers
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i do not think so... up e.g. is used to lit the underwater fog.
     
  38. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Thank you will try it out!

    @larsbertram1 thanks a lot for the effort, this seems to be working well. Ill continue testing but it is a massive improvement and I think it will work alright like this. I already left a 5 star review but Id leave another one if I could! :) Thanks again!
     
    Last edited: Aug 16, 2019
  39. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    872
    maybe there's something missing in the scene set up? Cause it works in all the demo scenes but won't work in any new scene i make.
     
  40. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    @larsbertram1 Seems like I celebrated too early. :)

    This is happening now:
    https://prnt.sc/otq3q5

    Cause being this part of the changes:
    What to do? :)

    Just to make certain, copy pasting my line 385-390:
    }
    //v.vertex = mul(unity_WorldToObject, wpos);
    o.vertex = mul(UNITY_MATRIX_VP, float4(wpos.xyz, 1.0f));
    #else
    o.vertex = UnityObjectToClipPos(v.vertex);
    #endif

    and 606 to 610

    //v.vertex = mul(unity_WorldToObject, wpos);
    o.vertex = mul(UNITY_MATRIX_VP, float4(wpos.xyz, 1.0f));
    #else
    o.vertex = UnityObjectToClipPos(v.vertex);
    #endif

    of the watermask shader
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    just a very quick answer – and i will be offline this weekend:
    looking at your screen shot i get the impression that the volume does not get displaced at all: it has a flat line at the top...
    so i guess you missed something.
    i will send you my super dirty test shader here. please do not simply replace your current one with it but have a look at it.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    this is how the tessellated water volume looks like in render doc.
    if you have a closer look you will notice that the upper border actually is slighly displaced.

    water_volume.PNG
     
  43. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    872
    Ok so i figured it out, for some reason the waves only work if the under water rendering script is attached to the camera...

    Is that normal? The included guide doesn't mention anything about that.
     
  44. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Thanks a lot, yeah I accidentally left the old o.vertex calc at the bottom, that was the mistake.

    There are still cracks though, BUT from what I can see, only red ones appear now. Didn't see any black ones yet.

    http://prntscr.com/otutc5
    http://prntscr.com/otutqa

    Hope you can spare some more time to help me figure that out next week. :) Enjoy your weekend!

    Testing some more, really weird:
    http://prntscr.com/otuvu3


    My only conclusion is that vface might be bugged, or maybe there is some case you didn't cover with your vface checks.

    I checked it by putting this in pass 3:

    Code (CSharp):
    1.         fixed2 depth = EncodeFloatRG(i.depth);
    2.         fixed4 col = fixed4(upsidedown, depth.x, depth.y);
    3.         if (facing > 0)
    4.             col = fixed4(0.0f, 0.0f, 1.0f, 1.0f);
    while underwater, the result was this: https://prnt.sc/otv3dk

    Which means facing var is wrong at times for some reason.

    Additionally, I noticed there are still some black cracks as well, but ironically I couldn't get them in my level scene, just in your ocean scene, not sure what the reason is. Maybe just coincidence.

    Hope this info can get you started on the path to fixing this. :)
     
    Last edited: Aug 17, 2019
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    vface is nothing we set in the shader. it comes as input from the gpu.
    so all we may do is changing the threshold to detect back faces like:
    if (facing >= 0.0f)
    or even:
    if (facing > 0.5f)

    last posibility would be to draw the water surface twice...
     
  46. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    Yeah I understand, ill play with it a bit more and see what I can do.

    If everything fails, and there is no solution from your side, ill try to write my own watermask shader that might be bit less optimized but works better, not sure yet. Ideally as a user id like to be able to set "watermask quality", with it being low or high, low using this system, and high using a less optimized but better quality approach.

    Im surely gonna try my best to solve this because I swithed to using both ats colormap ultra for terrain, and lux plus for the rest of the shading. I really like the idea of having the whole family of products, both from compatibility and compactness point of view. And it all looks awesome.

    Plus I was already using advanced foliage shader, so thats great also.

    Thanks for the help!
     
  47. TyTiKi

    TyTiKi

    Joined:
    Nov 5, 2012
    Posts:
    9
    Hi Lars, I bought Lux Water some time ago and only got to use it now. I must say I'm impressed with the overall quality of the shader.

    I'm trying to make it work with another atmospheric asset, Time of day. Using the frame debugger I noticed that TOD draws everything before Lux Water so there are no reflections or fog.

    Just as a quick test I tried to change the render queue from 3000 of the shader to AlphaTest+50 and.. it works! Fog, reflections, clouds, everything.

    I just wanted to ask if it could lead to problems and if there's a more "correct" way to integrate both assets.
     
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    ideally you should make the water shader sample fog like provided by TOD. i am not very familiar with this asset but i guess it adds fog as full screen image effect? as "Atmospheric Scattering"?
    then lux water should apply fog just like TOD adds it to all opaque objects.

    as lux water may write to depth changing its render queue may TOD apply fog properly already.
    however this mighht mess with particles and other transparent objects.
     
  49. TyTiKi

    TyTiKi

    Joined:
    Nov 5, 2012
    Posts:
    9
    Thanks for the quick reply.

    I think you are right, in order to get atmospheric scattering I have to add a script to the main camera. Even in the frame debugger it gets added under Camera.ImageEffects.

    In their docs the rendering order is as follow:
    Code (CSharp):
    1. Unity depth pass
    2. Unity objects (background)
    3. Space
    4. Stars
    5. Sun
    6. Moon
    7. Atmosphere <---
    8. Unity objects (opaque)
    9. Unity image effects (depth)
    10. Clear
    11. Clouds
    12. Billboards
    13. Unity objects (transparent)
    14. Unity image effects (remaining) <---
    I think that's why the water doesn't receive any fog if it's on 3000 as render queue..
     
  50. ffertigo

    ffertigo

    Joined:
    May 31, 2015
    Posts:
    12
    I'm getting this clipping error when using a vr headset just on my right eye because of that i can't use any subsurface scattering? Do you think you could fix that bug so the plugin also becomes useful for XR headsets? Thank you