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,900
    fixed in upcoming 1.073.
     
  2. FreezerJohn

    FreezerJohn

    Joined:
    Nov 14, 2018
    Posts:
    6
    flicker_touchcollide.jpg
    Thanks! Yea you are right, it only occurs with tesselation.

    I just tested the updated script:
    - Works perfect with scene view :)
    - VS issue is almost gone, but a flicker occurs with distance to the shore line
    - I think it broke the underwater blur, it's just solid gray now
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    fine!
    only almost? actually i did not test vs – but added an orthographic camera which renders the scene top down at depth -2, which should somehow match what vs does.
    do you mean these small white pixels in the screen shot? i always thought these were caused by micro cracks due to tessellation. in the end however it turned out that most of them were caused by the way underwater rendering was combined with the screen buffer. in 1.073 most of these should have gone.
    hmm, i can not confirm this – but i am looking at 1.073 right now.
     
  4. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Whoops. I think I could be using a modified version of the UnityDeferredLibrary via the awesome NGSS shadows asset. Maybe that's where the issue lies? @tatoforever ?
     
  5. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I find this bit of the manual a little bit confusing...

    This of course might interfere with other deferred lighting shaders you may already use provided by e.g. ATG, AFS, Lux Plus or Uber. The tweaks however are rather minor, well documented and should be easy to add to the custom deferred lighting shader you are currently using. It is just three lines of code you will have to change. Look for: 
 (add)#pragma multi_compile __ LUXWATER_DEEPWATERLIGHTING
    (add)#include "LuxWater_DeferredLibrary.cginc" 
 (replace)// UnityDeferredCalculateLightParams (i, wpos, uv, light.dir, atten, fadeDist);
    LuxWater_DeferredCalculateLightParams (i, wpos, uv, light.dir, atten, fadeDist, dirLightAtten); 
in the included “LuxWater_DeferredShading” shader.

    Can you clarify what I should do to what files? I'm not finding that "UnityDeferredCalculateLightParams" anywhere.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you can find it in "LuxWater_DeferredShading.shader" -> line 59. it is commented as instead of calling the original function we call (line 60):
    LuxWater_DeferredCalculateLightParams (i, wpos, uv, light.dir, atten, fadeDist, dirLightAtten);

    but ngss only hacks the "UnityShadowLibrary.cginc" – not the "Unity_DeferredLibrary.cginc"?!
     
  7. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    ok cool. cheers. seems like I had already done those changes. confusing. I think some of the code changes I had made were overwritten by a re-import while others weren't.

    As for NGSS I'm using the beta of v2. I believe it hacks UnityDeferred as well but @tatoforever would be able to confirm.
     
  8. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Also now I'm getting this error on LuxWater_DeferredShading:

    Code (CSharp):
    1. [Error] This custom render path shader needs to have at least 2 passes.
    2. UnityEditor.Experimental.Rendering.ScriptableBakedReflectionSystemWrapper:Internal_ScriptableBakedReflectionSystemWrapper_Tick(SceneStateHash)
    And some random glitching that only stops when I disable the water plane...

     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    which experimental feature do you use? lux water only supports the "legacy" rendering pipeline.
     
  10. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I'm using the legacy pipeline. Nothing experimental that I know of.
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hmm, i just tested currently pending version 1.073 in unity 2018.3.1: no errors. maybe you just have to try to import lux water to a new project. you may also try to use the attached non optimized cginc file (you have to rename it to: LuxWater_DeferredLibrary.cginc)
     

    Attached Files:

  12. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    OK. So even without that non-optimised version, everything seems to work in a new project. There are a couple of missing prefabs in scenes and some scenes need the camera depth component added to show the water but everything seems ok... provided I set the Shadows to disabled in the Settings. I'm assuming that NGSS's custom Library still resides in Unity across projects so there must be an incompatibility between your assets.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i will look into this.
     
    transat likes this.
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    version 1.073 is available.
     
  15. FreezerJohn

    FreezerJohn

    Joined:
    Nov 14, 2018
    Posts:
    6
    Nice! That was quick :)

    Yea exactly, but they are now gone in 1.073 like you said, doesn't matter if VS is active or not. Also blur works again for me after the update!
    Thanks for your work!

    Hate to be that guy, but I already got another problem:
    When Enviro fog support is setup, I get foggy boxes around the light sources, scaling with the light range. (See picture)

    fog_artifact.png
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i do not think that enviro is already updated to support lux water. this should be fixed with the next enviro update.
    maybe you can ask hendrik for a preview.
     
  17. FreezerJohn

    FreezerJohn

    Joined:
    Nov 14, 2018
    Posts:
    6
    Alright will check!
     
  18. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,366
    As of version 2.0 we use a custom UnityDeferredLibrary, a custom AutoLight on top of the custom UnityShadowLibrary. They are built to work with any asset independently from each library (you can install only local NGSS shadows, only directional or both). However If you call your own deferred library it shouldn't give any error, it will compile fine, you would not have NGSS denoiser, only NGSS directional shadows though.
    @larsbertram1
    I sent you a package of v2 through PM. We can always workout a middle ground to support your assets.
     
    transat likes this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    thanks a lot. i will look into this as soon as i find some time!
     
    transat and tatoforever like this.
  20. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,904
    I created a quick video showing how to setup Volumetric Fog & Mist to work with Lux Water. I've not tested all the water options but it's a start and looks quite good :)

     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    incredible!
     
    Kronnect likes this.
  22. Acissathar

    Acissathar

    Joined:
    Jun 24, 2011
    Posts:
    677
    Does Lux have any "built in" water effects or a related API to create splashes or ripples around a moving player for example?

    Thought I would double check before hacking together a solution. Thanks!
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    no, not really.

    water by default is just some geometry and the shader. there is no "the surface" or "the ocean" object and you can have dozens of water objects in your scene.

    in case you use "flat" geometry you can simply use colliders or check the y position to detect collisions.
    if you displace the water surface using gerstner waves you can use the public class LuxWaterUtils to calculate the water displacement at a given location and manually check for collision.

    regarding vfx: lux water comes with normal and foam projectors which let you add ripples and foam. splashes would be simple particles i guess.
    lux water does not ship with advanced particle effects.

     
    Last edited: Jan 22, 2019
    Acissathar, Rowlan and Kronnect like this.
  24. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    32
    Hello,

    I'm building for IOS, metal/deferred, in unity 2018.2, testing the deep water demo, and I'm getting that warning:
    "Trying to access pass 3, but material 'Hidden/Lux Water/WaterMask' subshader (0) has only 3 valid passes."

    Is there something to adjust?
    please let me know,
    Pascal
     
  25. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    32
    @larsbertram1

    Hello again,
    I'm still testing for IOS, metal/deferred, in unity 2018.2, using the deep water demo and I have other issues you could maybe help with.

    When starting the app, it's staying about 10s loading without shader, like visible here in screen1, then it's starting fine.
    Is there something to better start the app?

    screen1.jpg

    I have then another question about the water material. There are pixels on the surface in the IOS version but not in the editor.

    surface1.jpg surface2.jpg

    Is there some adjustment to make?

    Thanks for your help,
    Pascal
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi pascal,
    unfortunately i have no chance to test the shader on iOS.
    i only tested it on OS X 10.11.6.
    but you really use deferred on iOS? how about forward?
     
  27. Pascal-

    Pascal-

    Joined:
    Mar 23, 2013
    Posts:
    32
    Thank you Lars,
    I tested in forward but it's the same. The loading problem was about the tessellation. By using the watersurface shader there is no problem anymore on start, but the pixelation problem when camera is close to the surface is still the same
     
    Last edited: Jan 23, 2019
  28. Acissathar

    Acissathar

    Joined:
    Jun 24, 2011
    Posts:
    677
    That is what I meant, perfect, thanks!
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    fine :)
     
  30. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    @larsbertram1 - I upgraded to the latest version and now my ocean volume is not working. I imported into the existing scene without deleting the previous version and everything else seems to be fine. I've set the debug option and the water plane collider is getting triggered. I'm wondering if the ocean volume is not the same size as my water plane and I'm just not inside it. Any suggestions?
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    if you enable debug and "click" "Gizmos" in the upper right corner of the game view you should see how the rendered water mask looks like. it should show the water surface (red gradient from above, green gradient from below).
    the volume would be a solid green color.
    and in order to check you volume's size (and pivot): simply assign it as water mesh. it should render at exact the same position as your water plane.

    the latest update should not have changed your water meshes and volumes. but maybe you check the import settings of the used models?
     
  32. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Switching the shader's render queue to Geometry (2000) seems to make Enviro's fog play well with Lux Water on my Mac. Is there more to it than this? Is changing the order from 2999 to 2000 a bad idea?
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it might work on metal and deferred as lux water uses it own depth grab there. but it won't work using other api's.
    and it should not work on metal either?!
     
    transat likes this.
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    official support should come very soon. lux water already contains all it needs. maybe you can ask hendrik for a preview of the updated fog function.
     
  35. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    Hi @larsbertram1
    All the gizmo options are checked, but I don't see any red or green gradients (see image).
    lux6.png

    I'm using the OceanPlane and OceanVolume (see inspector image).
    lux5.png

    I tested the demos and water volume works. I made a prefab from the water volume demo and added to my scene...the underwater volume still doesn't work.

    It was working before the LuxWater update and now it's not, but I'm probably doing something stupid.
     
    Last edited: Jan 23, 2019
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    maybe because no volume is active?
    btw. i meant gizmos in the game view. there you will get a feedback which tells you if and which water volume is active.

    does you camera/player have a rigidbody, collider and the water volume trigger script attached to it? all these components are needed to trigger underwater rendering.
     
  37. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    @larsbertram1 - sorry for misunderstanding...I've enabled gizmos in game view. The player has a rigid body and volume trigger script. The debug message in the images shows the active water volume is triggered (in this test case it's Water_Plane). When I'm underwater it shows green gradient above and when out of the water is shows red below.

    lux7.png
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    from what i can see: the water surface is rendered properly into the water mask.
    but the volume is entirely missing: the lower part of the overlaid mask texture should be fully green. and of course the final image on screen should show underwater rendering.

    i will check OceanPlane and OceanVolume.
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    both OceanPlane and OceanVolume as well as OceanPlane01 and OceanVolume01 just match.
    just drag both into a new scene to check.
    maybe you have to reimport them.

    oceanplanes.PNG
     
  40. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    In case anyone else has the same issue... I was having trouble figuring out why I wasn't able to trigger the underwater volumes as all my settings seemed to match the ones in the demo scene. Turns out the issue was with the layer collision matrix un Unity's Physics settings. A couple of checkboxes needed to be ticked.
     
  41. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    @larsbertram1
    I deleted and re-imported LuxWater, but the volumes still don't work in my scene.

    Here is what I know:
    1. Ocean volume worked before the water update (using the ocean volume you provided in here in the forum).
    2. Volume works in the demo scenes.
    3. Volume doesn't work when I make a prefab from the demo scene water and place in my existing scene.
    4. Making a prefab from my water plane and placing it into the demo scene does work, but the volume has a huge gap in it - until I decrease the scale of the water mesh.

    In the previous version my water plane and volume worked well at large scales. It seems that is no longer the case in the new version. In one of the demos I increased the OceanPlane01 to 400,1,400 and I get a gap in the volume (see image).
    lux8.png
     
    Last edited: Jan 24, 2019
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you have to use the "OceanPlaneVertexColors" mesh for the water. only this contains vertex colors which dampen displacement at the outer edges to fit with the volume mesh.

    do not go crazy about scale. oceanplane01 is 100x100 meters. scaling it by 400 would make it 40000 x 40000 meters in size which is way beyond floating point precision.
    at the same time the volume would be scaled to 40000 x 40000 x 40000 – so it gets simply clipped by the far clipping plane of your camera = no underwater rendering.

    if you need an "endless" ocean, you will have to move the water plane/volume.
    lets say you have a far clipping plane set to 2000. than scale the water surface so it is 1800 x 1800. well, already this is way beyond any reasonable size, but at least it works.
    OceanPlane is dived into 50x50 quads. so if you scale it to 1800x1800m every quad fills 36x36m.
    so you could shift the water plane in steps of 36m according to the camera's position.
     
  43. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    @larsbertram -
    • The main issue is still that the volumes don't work in my scene anymore. Even if when I use planes at their native scale. I may very well be doing something stupid or missing some new setting, but they did work previously. The demos do work, so it must be something in my scene...perhaps a conflict with another shader?
    • In the previous version I was able to use large plane scales without any issues. Currently, I'm scaling the ocean mesh to 200x1X200 and then I use another rounded mesh beyond that to blend into the horizon. My camera clipping plane is 16000. It looks good and works well (except for the volume).
    I'll contact you via PM so other people don't have to read through my issues :)
     
  44. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    @larsbertram1, and anyone using UFPS with Lux Water.

    I finally got it working by moving the trigger script and rigid body to the FPSCamera AND adding a sphere collider. When I first setup Lux Water with UFPS I tried this configuration (minus the sphere collider) and it didn't work and that's why I placed the volume trigger and rigid body on the player parent object.

    I seems that something related to the location/hierarchy of the trigger script, rigid body, etc, was changed in the latest version (1.073).

    [EDIT] Colliders on the camera can cause problems with UFPS (and other character controllers), so check the Lux camera sphere collider "Is Trigger" option.
     
    Last edited: Jan 28, 2019
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    version 1.074 now is available

    ### Fixed
    - LuxWater_ProjectorRenderer script: Fixed wrong "cb_Normals.ClearRenderTarget" leading to an always displaced watersurface and breaking underwater rendering.

    ### Changed
    - LuxWater_WaterVolumeTrigger script: Does not need to be added to a camera anymore as now you can assign one.
    - LuxWater_WaterVolume script: Tries to register to the LuxWater_UnderWaterRendering instance until it has finally found it.
    - LuxWater_UnderWaterRendering script: Option to search for the sun OnEnable added.
    - Water Surface shader: Phong tessellation has been disabled - as it did not do anything anyway.
     
    transat and Rowlan like this.
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    dear customers,

    this is not really related to Lux Water but as it also may increase the immersion of your scene/game i would like to introduce you to Lux Lit Particles which give you rather cheap and real time lit particles receiving real time shadow and proper ambient lighting to make particles fit with the rest of your scene.



    As i always wanted particles to be more grounded i added support for directional light shadow. You will see the difference it makes int the screen shots below.


     
  47. Kooshy

    Kooshy

    Joined:
    Apr 13, 2015
    Posts:
    15
    So! I saw in the description of the asset on the store: • Water projectors which allow you to add local foam as well as local normals (and displacement)

    ..emphasis mine. Does that mean that a projector could be used to displace the water's surface (ie: have an object float in the water but not have any water inside?)
     
  48. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,257
    Awesome, instant purchase for me. I'm imagining your Lux Water underwater demo and a subway shining light on underwater particles. Gotta try that soon. If you already have something like that, please do share a video :)
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    yes – and no: you can use projectors to displace the water surface like shown in the "Lux Water – Tessellation and projected Displacement" video. unfortunately this lets you only raise the water surface.

    but in order to prevent water from being rendered inside your object you could use a simple "write to depth only" shader:
    http://wiki.unity3d.com/index.php/DepthMask


    [Edit] in order to make the water being displaced up and downwards you would have to:
    • remap the projected height from (0 to 1) to (-1 to 1): LuxWater_NormalProjector.shader, line 137: col.b = (col.a - 0.5) * 2;
    • adjust the height map (in the alpha channel). black: fully downwards, gray: no displacement, white: fully upwards.
    • adjust the normal texture - but do not ask me how :)
     
    Last edited: Jan 31, 2019
    Rowlan likes this.
  50. Kooshy

    Kooshy

    Joined:
    Apr 13, 2015
    Posts:
    15
    Fair enough - thanks!