Search Unity

[RELEASED] Lux Water

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

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    sorry, but i never looked into curved world...
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    even 2019.3 is not out of beta... 2020 alpha may be totally broken. or unity decided to start removing things.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    can you provide a screen shot (and unity version, platform infos)?
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the reflection probe? the normal map?
     
  5. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    734
    You have to replace the texture in the water foam projector and play a little bit with the particle settings. I started from the default one.
     
  6. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    It's hard to tell on screenshot, it happens only on mobile and it's obvious when it's moving. The documentation talks about it I believe, when it talks about setting the pixel snapping. But it's very weird, I only seen that happening on Water4 before, and I had to drop the package because it looked really bad on mobile due to that. I think it's related to how rendertextures are handled, but Aquas which does the same, does not have that problem. So not sure what's causing it.
    My test: Android Samsung S6 with Android 7. Try to compile the forward demo on it to see it.
     
  7. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Would you mind sharing the texture? I don't know how to do a wake like that :(
     
  8. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    734
    I can't because it is part of another (not free) asset but you can search on the web something to start with.
    Like this one for example.;)
     
  9. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Ok hopefully you can see it here- check the mountain edges. Everything has those edges since i added the water and it is very obvious when you are moving. As you can see the water is not even visible on the scene right now (it's on the side). But whatever that render texture is doing, it's messing up the edges of everything on scene.
    20191029_234254.png
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    if the water is not visible on screen i wonder how it can cause such artifacts.
    if invisible none of its components should ever render.
    but actually i doubt that you use anything apart from the water shader itself: no underwater rendering, no blur, right?

    it looks a bit as if your depth buffer is "corrupted" and the geometry covers more than it actually does – preventing the skybox from being drawn properly. please open the fram debugger and find the exact draw where these outlines become visible.

    p.s. do you use metal and the depth buffer script that comes with lux water?
    try to deactivate it.
    i guess you do not need it as your water will most likely not have any gerstner waves.
    otherwise – drawing the skybox first might fix it.
     
  11. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    nope, all i did was, add the forward water with volume, add the script camera. done. No underwater effect, no nothing attached anywhere else. It's on android, so no metal. On the editor seems ok, or at least it's not that visible that I can tell. On the android devices it looks horrible. That's my problem with the frame debugger, since on the editor I can't see them, I don't know how to debug that.

    If I remove the lux water and camera script, the scene looks fine. I don't know if you got the rendering technique from Unity Water4, because I remember having exactly the same issue with that water years ago and never with any other water asset. That's why I was forced to drop Unity Water.
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    why with volume?
    which script?
     
  13. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Sorry I didn't mean volume, some auto correct went on there. Ok let me be precise.
    1) Water plane using material: water muddy fjord planar gerstner
    2) Water settings: no write, no ztest, no culling, NO water volume, NO planar reflections, yes foam, NO caustics, NO gerstner waves.
    3) On the camera, attach Lux Water_Camera Depth Mode

    Done. That's the only script. Build and run for android. Get the outlines.
     
  14. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    It also creates weird flickering. The black dots on the left bottom part, that's not grass. That seems to be the specular lighting since it moves and shakes like the water. I don't know why it would show through, but it does.

    dfescreen.png
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    try to remove that script.
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    me neither. the terrain should occpy the depth buffer, so water usually would never be rendered there. – er, you set: no ztest? it should be LessEqual!
     
  17. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    If I remove the script, the water doesn't render. It's just invisible. And the outline is still there!
     
  18. mithrael01

    mithrael01

    Joined:
    May 16, 2017
    Posts:
    9
    Hey there,

    the water is absolutely stunning! It looks just great!

    What I'd really like though would be support for the (e. g. in my case Aura2) volumetric fog/lighting effects like AQUAS does it. Currently in combination with Aura2 it looks weird, because of the volumetric fog not being existent above the water, but everywhere else around it.
    Is there any solution to this already or is it planned? :)
    Maybe it's already in and I just don't know how to get it to work!?

    LUX + Enviro (with Aura2 volumetric fog):


    AQUAS 2020 + Enviro (with Aura2 volumetric fog):


    Just so you know what I'm talking about.
    Not saying AQUAS is better, I actually really like both of those assets!

    Thank you in advance!
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    well, if you remove the script then the water can not sample depth properly (used to calculate edge blending, foam and underwater fog) – and vanishes :)
    so what happens if you deactivate the water plane?
     
  21. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Ok some progress and questions:
    1) You told me to remove the camera script LuxWater_CameraDepthMode, but if I remove it I can't see the water. Do you see water without that script? I don't see it, not even on the editor. And I think it's because it changes the cameras to DepthTextureMode = Depth which probably is not like that by default (can i make it default without the script?)

    2) I found how to stop the outline. The problem is with the camera "clear flags". If it's set to Skybox... you will get the outline. Changing it to solid or anything else, seems ok but then I lose the Skybox. Any idea how to fix that? It's really the main thing stopping me from using it on mobile.

    I'm looking at the code and it seems as if the skybox is not copied into the texture. I see that if it's Deferred and Metal, it will copy to the CommandBuffer but it won't otherwise. Not sure if that would be the cause of it. I'm rendering on Forward mode. I'm talking about the LuxWater_CameraDepthMode.cs script. Right now i'm just guessing because I'm not familiar with all the code yet.

    3) I use opengl 2.0 for mobile. It seems to work just fine for the shader with a minor exception. If you look at the details, the file LuxWater_Core.cging line 941 it will complain about missing LightColor on opengl 2. I've just commented out the Unity Light ATTENUATION but I don't know whether that's correct. It seems to work just fine. What should be the correct way?
     
    Last edited: Oct 30, 2019
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it was to test if turning off the depth texture would fix the outlines.
    never ran into anything like this. use a custom skydome? but how should water effect sky rendering?
    lightcolor is the passed color of the light – which always should be present!?
    ATTENUATION contains shadows (not needed as water does not receive any) and spot and point light attenuation. so these lights types will not work on the water.
    maybe having a look into Autolight.cginc will help you.
     
  23. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I'm looking at the code and it seems as if the skybox is not copied into the texture. I see that if it's Deferred and Metal, it will copy to the CommandBuffer but it won't otherwise. Not sure if that would be the cause of it. I'm rendering on Forward mode. I'm talking about the LuxWater_CameraDepthMode.cs script. Right now i'm just guessing because I'm not familiar with all the code yet.

    I've also checked and clear flags set to "solid color" it also happens. But it's less noticiable because that edge is not black but whatever you set the solid color to. Still, you can see that line.

    What I can guarantee is that it doesn't happen in any other water package, so it has to be a bug of something not set correctly when it's using a skybox or solid color as a clear flag.
     
    Last edited: Oct 30, 2019
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i did a quick test and complied the shader for gles20: no errors or warnings.
    but i did not do a build so only the needed variants got compiled out (1600...).

    i think one of all the possible variants simply needs too many texture sampler (as gles20 is quite limited here) – which then throws an error when it comes to include the ATTENUATION: think of a spot light: this needs an additional texture for the spot cone. the one texture which may simply be too much.

    instead of diving into autolight.cginc i recomment to simply comment the #pragma multi_compile or #pragma shader_feature variants you do not use.
    like:
    • #pragma multi_compile __ USINGWATERPROJECTORS
      (this adds 2 more texture to the shader)
    • #pragma shader_feature GEOM_TYPE_FROND
      (this is caustics adding another texture)
    actually i think you can comment ALL #pragma multi_compile and #pragma shader_feature as you do note use any of the defined features!? this will increase compile and build time tremendously.

    water does not render at the silhouette of the terrain (where you get the border). and all the script does is unity asking to resolve and return the depth buffer. no water asset which does soft edge blending, foam or depth dependend water coloring can do this without accessing the depth texture.
    you may try to get rid of the LuxWater_CameraDepthMode.cs script and ensure that the camera renders into a depth texture by using your own script – at least if you render using metal. openglcore e.g. does not need it at all.
     
  25. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Well, I actually intend to use some of the features. I'm not using almost anything because I was trying to figure out what was causing the outline on the mountains. Now I know it's the camera clear flags set to solid or skybox. Next I have to figure out how to solve it. If it works, I'll then begin adding features.
     
  26. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    248
    @mithrael01 @larsbertram1
    Sorry for not replying sooner - needed my work computer as well as some digging on how I got it to work as well. Since our version has some additional tweaks and changes. I found help on integrating it on the forums or the Aura Discord channel, but I can't recall correctly.

    Anyways to get it to work open LuxWater CG.shader and add (around line 227)
    Code (CSharp):
    1. #define FOG_AURA
    2. #if defined(FOG_AURA)
    3. #include "../../Aura 2/System/Code/Shaders/Aura.cginc"
    4. #endif
    Very important! Only add these lines in the ForwardBase pass (this is the first pass in the SubShader)
    I put this right below the // Fog Mode but after the LuxWater_Setup include.

    Open AuraUseage.cginc and include
    Code (CSharp):
    1. #include "UnityCG.cginc"
    below the #include "Common.cginc" at the top.

    Next open LuxWater_Core.cginc. Here we have to add a couple of things.
    Go to around line 190 and in the struct v2f add
    Code (CSharp):
    1. #if defined(FOG_AURA)
    2. float3 frustumSpacePosition  :  TEXCOORD9;
    3. #endif
    Then go to around line 420-422 and in the v2f vert (vertex shader) add
    Code (CSharp):
    1. #if defined(FOG_AURA)
    2. o.frustumSpacePosition = Aura2_GetFrustumSpaceCoordinates(v.vertex);
    3. #endif
    This will give us enough data for the last part.
    Go to around line 1240 (just below all the other custom fog implementations) and add

    Code (CSharp):
    1. #if defined(FOG_AURA)
    2. Aura2_ApplyFog(c.rgb, i.frustumSpacePosition);
    3. #endif
    And that should be it. I hope I didn't forget something as I said above we have some more adjustments...
    Please drop me a line if you run into any issues.

    Sorry for the code comments - but I thought it would make copy/pasting a bit easier.
     
    Rowlan likes this.
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    @PieterAlbers wow, thanks a lot for the detailed explanation!
     
    PieterAlbers likes this.
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    a slightly simpler aura 2 integration

    open "LuxWater_Setup.cginc" and add this (after Einviro Fog):
    Code (CSharp):
    1. //  Aura 2 Fog --------------------------
    2. #define FOG_AURA
    3. #include "UnityCG.cginc"
    4. #include "Assets/Aura 2/Core/Code/Shaders/Aura.cginc"
    Including "UnityCG.cginc" before including "Aura.cginc" makes it obsolet to edit the AuraUseage.cginc.

    then open "LuxWater_Core.cginc" and add around line 1232:
    Code (CSharp):
    1. #elif defined(FOG_AURA)
    2. #if defined (UNITY_PASS_FORWARDBASE)
    3. if (!backside) {
    4. Aura2_ApplyFog(c.rgb, float3(i.grabUV.xy/i.grabUV.w, surfaceEyeDepth)); // i.frustumSpacePosition);
    5. }
    6. #endif
    7. #endif
    We do not need to add another vertex to fragment interpolator as we can calculate frustumSpacePosition from the already given inputs. Wrapping the call of "Aura2_ApplyFog" with "#if defined (UNITY_PASS_FORWARDBASE)" ensures that fog will only be applied once.
     
    Last edited: Oct 31, 2019
    PieterAlbers and Rowlan like this.
  29. mithrael01

    mithrael01

    Joined:
    May 16, 2017
    Posts:
    9
    Thank you SO much @PieterAlbers !! It works like a charm!
    I just tried your "shorter version" and it works just perfectly. Thank you too! @larsbertram1
     
    PieterAlbers likes this.
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    please note that i added the "if (!backside) {}"
     
  31. mithrael01

    mithrael01

    Joined:
    May 16, 2017
    Posts:
    9
    Added it as well, thanks again!

    I'm guessing you're going to implement the Aura2 support in the next version anyway?
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i guess so, yes.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    Lux Water and Aura 2 – added in upcoming version 1.09.
    In order to make all the underwater rendering work properly it needs a tweaked aura post shader. i sent my one to raph. he has to add it to aura, then you should be ready to go.

     
  34. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Is there a way to have different color for over the water and under water? I've set it to a very dark ocean color but when I go under, although not realistic, i would prefer to see a clearer version of it, otherwise i can't see anything under water
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you would have to change it by script. or change it in the script: the color that gets passed to the underwater post shader.
     
  36. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    where is that?
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    look into the unterwarfen Rendering script
     
  38. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    thanks, now i have a different problem and I can't find on the doc how to solve it.
    I have 2 cameras. One for far and one for close up rendering, since my terrain is pretty big and i either use 2 cameras or I begin to get z-fighting.

    I add the Camera depth render script to both cameras since I'm doing forward rendering. One render fine but the other seems to lose info. I see water, but no colors as you can see on the screenshot. How do we render to both correctly? On deferred rendering for the split screen demo it seems to work, but not on forward which requires the depth rendering script.

    waterissue.jpg
     
    Last edited: Nov 3, 2019
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i do not recommend to use 2 cameras just because it is quite expensive: 2 times the culling and a lot of additional draw commands...
    according to your screen shot the near camera has a very short drawing distance... so i would choose a somehow better balanced split. and maybe completely disable shadows on the far camera? so 0.03 – 150 for the near and 150 – xxx for the far camera? this should eliminate all the work done on shadows regarding the far camera.
    as far as water is concerned: you may try to make water not write to depth (i don't think you need it anyway).

    but using a simple 2 cameras setup (near: 0.3 – 200, depth: -1, clear: depth only / far: 200 – 12000, depth: -2, clear: skybox) just gives me proper results and no missing "color":

    water_farnear.gif
     
  40. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    you get that on forward? i've tried with your clipping distances and i still get the same problem
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it is forward, yes.
     
  42. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    734
    Hey larsbertram1,
    foam and normal projectors are not compatible to VR or maybe i'm doing something wrong in the setup?
    Tested on: PC, Oculus RiftS, SinglePass/MultiPass, Deferred/Forward
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    lux water is not compatible with vr...
     
  44. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    734
    Maybe not at 100% but in my project it's going great;)...exept projection of course:(.
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    water surface rendering should be ok. underwater rendering should give you some glitches. and projectors are not supported at all. unity simply lacks some needed information and it is way too complicated to get them manually – unfortunately. sorry about this.
     
    sjm-tech likes this.
  46. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I generally do not click Use Planar Reflections, since Lux Water looks great without those....but I'm currently setting up a small river that really looks much better with Planar Reflections enabled. I can definitely see a significant performance impact when I have multiple layers selected in the Reflection Mask. But I still mostly get the look I want with Nothing selected there. I have disabled Pixel Lights (though I don't have any), and 0 shadow distance, which gets FPS a lot closer to what it was. What else should I do to minimize the performance impact?

    Also, I will have several rivers, as well as a lake, so I should set them up as described in the manual, but it says:

    Make sure that the parent game object has the same y position as the water tiles using “GameObject” → “Center on Children”. ​

    But my rivers and lake are at different y positions (based on terrain elevation)....so will that not work then?

    thanks
    Dave
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    resolution of the reflection. and as i guess that the terrain will be reflected: make sure you only render the basemap and do not do any heavy splat mapping. also do not use tessellation or any other heavy effect while rendering the terrain. disable grass and force trees to be rendered as billboards.

    planar reflections will not work properly even on a single river... as a river in a rocky environment hardly ever forms a plane or can be abstracted by one.
    in case you have several reflective surfaces at different y levels things get even worse.
    you will have to find the currently most relevant surface and pick up its "plane" when it comes to rendering the reflection.
     
  48. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    248
    Regarding performance. Being able to control the farclip of the camera that renders the reflection would be great.
    This has proven to be a bit difficult but has been possible in other similar reflection scripts I have used. I couldn't get it to work in Lux quickly, but tbh I didn't try too hard and I implemented custom layerCullDistances for the reflection camera instead. This can cause larger objects to pop in/out but it wasnt too noticeable in our project and got me a proper performance gain.

    I also (tried to) exclude all other possible (active) cameras in my scene to trigger the OnWillRenderObject. Sometimes other third party assets (Aura, decal assets) render the scene as well and might trigger this resulting in unwanted overhead.
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    even reflection probes may trigger the reflection rendering! altho the lux script filters them out.
    what does "tried" mean? didn't it work out?
     
  50. no00ob

    no00ob

    Joined:
    Dec 13, 2017
    Posts:
    65
    How would I get the fog of Weather Maker working with lux water? I think I had it working before my project was corrupted and I had to backtrack but cant remember how I made it to work.