Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    6,899
    nope
     
  2. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    nope? Lol ok then. Maybe it’s a unity bug then. It seems to happen with other assets that have reflections.

    Except reflection probes. Which Work the best but it DESTROYS my Framerate.

    Still can’t get Tessellation to work by the way but I’ll keep digging. I put it on hold for now.

     
  3. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    Okay, is this something you would be interested in exploring? I would be happy to discuss additional donations if it would help, I am already impressed at the quality of this shader for the price
    With deferred lighting I am unfortunately unable to use a directional light that is culled to only the water layer, so I am stuck currently
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i do not even really get what you are doing there... having multiple reflection cameras for different windows?
    this is not supported... and would need you to change the reflection script.
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i am pretty short of time... so basically you have to change the lighting code (core.cginc) starting at line 1002.
    line 1006 / 1008: lightDir
    here the shader takes the light direction into account. so here you feed in your custom light dir.

    line 1012: lightColor
    feed in you custom light color. atten would be 1.0 as you do not have a distance based attenuation nor shadows.

    this is pretty much all.
     
    greengremline likes this.
  6. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    Awesome - so I took a stab at it, and everything seems to work except for the water plane mesh when underneath it, any idea why that might be?

    upload_2020-8-24_14-33-31.png

    Code (CSharp):
    1.           // Custom directional lighting, updated from script at runtime with Shader.SetGlobalX
    2.     float4  _CustomLightDirection;
    3.     fixed4  _CustomLightColor;
    4.  
    5.   #ifndef USING_DIRECTIONAL_LIGHT
    6.             half3 lightDir = normalize(UnityWorldSpaceLightDir( worldPos ));
    7.             UNITY_LIGHT_ATTENUATION(atten, i, worldPos);
    8.             half3 lightColor = _LightColor0.rgb * atten;
    9.         #else
    10.             half3 lightDir = _CustomLightDirection;
    11.             half3 lightColor = _CustomLightColor.rgb * 1.0;
    12.         #endif
    Is this due to some light attenuation function that needs to be written instead of unity's? This is all incredibly new to me so I appreciate the assist!
     
  7. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    285753F3-A2E5-4BFA-BD42-55D713AFE1A3.gif

    Zonor90:How did u get the underwater tessellation/ ripples to work?! I’ve been trying for weeks lol

    Lars: have you ever been to a medicinal office or a gas station that has those really reflective doors? Well that’s I have in my scene. But I’m trying to your Lux water asset as a door reflector. And it’s working just fine when I have it on ONE door. The moment I create another reflective door on a separate building, the reflection glitches out on the second building. But the first is fine. But then if I leave the game and reload the scene, the first building would glitch out and the second building wouldn’t.

    Essentially the question is, why is the water in the bay under the bridge running perfectly and has perfect reflection but when I use the asset to make a reflective door (making the object vertical, removed waves, foam, and movement, basically freezing it) does it glitch out when moving the camera around at certain angles? I know these waters arent meant to be used as flat doors but it’s more of a reflection issue it seems. Plus lux seems highly optimize and doesn’t kill my frame rate like reflection probes do. So i thought I’d find a second used for it. Please see image above to see what I mean. .

    Is still a reflection limitation on the asset or on unity?



     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    the reflection script is not written for multiple mirror like surfaces. several surfaces = multiple camera. but they write to one single global texture... so it is just random which camera actually wins here.
     
    glenneroo and eaque like this.
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    no. just because you do not get any lighting information from unity.

    #ifndef USING_DIRECTIONAL_LIGHT
    here comes the code for point and spot lights​
    #else
    here the code if USING_DIRECTIONAL_LIGHT is defined​
    #endif

    is it the underwater fog being too dark? you may check this lowering fog density.
     
  10. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    Ooh ok. Thanks brother. I’ll keep trynna crack this tesselation. :)

     
  11. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    I can’t seem to get caustics in vertical walls. Only horizontal floors. Is this possible? I noticed that even in your split screen demo, this seems to be the case.

    CC9D423A-7E56-4DC4-AA76-D5AA1EDDAAD0.jpeg
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    caustics are top down projected in world space. so they would be stretched on vertical walls.
    if you want them you would have to edit the shader.
     
  13. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    I understand. Ok then. But I did edit the shader. I can make the caustics thick and bright. Fast. Slow. Small or big. But that’s about it. Or do you mean via script?

     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    Caustics = causticsSample.r * saturate(gNormal.y - 0.15) * saturate( (gNormal.y - 0.15) * 2);
    get rid of the * gNormal.y here:
    Caustics = causticsSample.r;
     
  15. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    Great I’ll mess with this a bit. Also I just lost my caustics. Not sure what happened but I’ll figure it out. At first I had to disable the “normals from gBuffer” in order to get them to work but now it’s not working. I haven’t made any changes.

    Either way this asset gets better and better the more I use it :)

    I got everything working except foams on object movement which I saw on your demo it’s actually just particles So that should be easy to do. (The one with the two spheres) and the displacements.

    I have the underwater Blur going well. The caustics (which I lost and will fix), the waves and foams, and it’s been great playing with the colors and speed/movement settings. You can make water, clay, mud, lava. Even ice or one mirror lol. It’s all about perspective. :)


    but I can’t seem to get the displacement working. I copied what you did on your demo with the cylinders but cant replicate it. The water displacement around the cylinder is something I want my player to have while he walks on the water. What’s the key to get this working ?

     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    tessellation and a displacement projector.
     
  17. Mattabat

    Mattabat

    Joined:
    Aug 23, 2017
    Posts:
    2
    Unless i missed it somewhere when you go deep enough and it gets dark enough, it gets kind of pixelated looking is there any way to fix this?
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i haven't seen this so far. deep water rendering just fades out the directional light. that's all.
     
  19. Gigglez13

    Gigglez13

    Joined:
    Aug 30, 2020
    Posts:
    1
    Find much of those lovely pictures here
     
  20. mithrael01

    mithrael01

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

    I just updated to Unity 2020 from Unity 2019 LTS and also updated the packages used in my game. I updated Enviro, Aura2 as well as Lux and adjusted the Lux setup file to use the Aura2 fog (like I had it before the update process).

    Now, with the updates and Unity 2020 the Aura2 fog once again doesn't seem to get applied correctly.
    Before (Unity 2019):


    ... or with a less drastic fog:



    After (Unity 2020 incl. package updates of Aura2 and Lux Water):


    You can clearly see the "outline" and the fact that the water doesn't really render correctly consindering the fog.

    Any ideas?

    Thanks in advance!

    Edit:
    Here's my LuxWater_Setup.cginc (the asset path was adjusted and is correct):

    Code (CSharp):
    1.  
    2. //  Define Fog Mode
    3. //    Make sure only one fog mode is defined.
    4.  
    5. //  Built in fog modes ------------------
    6.   // #define FOG_LINEAR
    7.   // #define FOG_EXP
    8.     // #define FOG_EXP2
    9.  
    10. //  Azure Fog ---------------------------
    11. //  #define FOG_AZUR
    12. //    #include "Assets/Azure[Sky] Dynamic Skybox/Shaders/Transparent/AzureFogCore.cginc"
    13.      
    14. //  Enviro Fog --------------------------
    15. //  #define FOG_ENVIRO
    16. //    #include "Assets/Enviro - Sky and Weather/Core/Resources/Shaders/Core/EnviroFogCore.cginc"
    17.  
    18. //  Aura 2 Fog --------------------------
    19.       #define FOG_AURA
    20.       #include "UnityCG.cginc"
    21.     #include "Assets/ThirdPartyAssets/Aura 2/Core/Code/Shaders/Aura.cginc"
    22.  
    23.  
    24. //  Other features --------------------------
    25.  
    26. //    Uncomment to make the shader use disney diffuse lighting on foam. Otherwise it uses simple NdotL
    27. //    #define DISNEYDIFFUSE
     
    Last edited: Aug 31, 2020
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    unfortunately: no. have you asked in the aura2 forum if anything has changed in the fog calculation?
     
  22. mithrael01

    mithrael01

    Joined:
    May 16, 2017
    Posts:
    9
    Not yet, will do that next I guess, thanks!
     
  23. mithrael01

    mithrael01

    Joined:
    May 16, 2017
    Posts:
    9
    Seems like it's somehow connected to Enviro as well.. When I deactivate Enviro and simply increase the volumetric density/fog via the aura light it pretty much looks like it should.. When Enviro is active.. not so much..
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i never had both systems running in parallel... but the water should receive fog only from aura 2. so does enviro add fog to your opaque objects? although aura is running?
     
  25. mithrael01

    mithrael01

    Joined:
    May 16, 2017
    Posts:
    9
    That was indeed the problem! I deactivated all of Enviro's different fog options and it seems to work "again". Thanks!
     
  26. Juneav

    Juneav

    Joined:
    Feb 18, 2017
    Posts:
    27
    Hello! Im having a weird issue with the ocean water, Im using Enviro, it was imported first in the project, then the standard assets, then Lux, Im adding lux water to the sample scene of Enviro, copied all the lux camera scripts to the Enviro camera, but my ocean water always looks yellow, any idea how to solve this?

    Edit: Blue water is the lux lake water, seems to work ok.
    Also, the underwater effects do not work, despite I've added all scripts.
     

    Attached Files:

  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    might be caused by refraction or the under water fog. i guess latter. so check the underwater fog color and density.
    most likely not :) your first screenshot shows that 2 volumes are registered but none is active. maybe you have forget to add the trigger.
     
  28. ryschawy

    ryschawy

    Joined:
    Jul 28, 2012
    Posts:
    65
    Hi, I'd like to fade out the reflection strength by view distance, so that water close to the horizon shows no reflection. For artistic reasons I'd like this to be independent from the fog I use (Aura2). How would I do that? (I tried to lerp the _ReflectionStrength using a saturated viewLength, but that messes up geometry that is under the water)
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    the correct value should be in: surfaceEyeDepth
     
    ryschawy likes this.
  30. Juneav

    Juneav

    Joined:
    Feb 18, 2017
    Posts:
    27
    Thanks!
    I've changed the Underwater Fog Color and it looks like it did the trick! Take a Look.
    However, I'm still not being able to get he underwater effects, these are my camera settings:
     

    Attached Files:

  31. Juneav

    Juneav

    Joined:
    Feb 18, 2017
    Posts:
    27
    It was my bad, checking the documentation it was due to the Trigger script that should be attached to the game object that has the colliders. Its fixed now!

    ITS BEAUTIFUL.
     

    Attached Files:

  32. Juneav

    Juneav

    Joined:
    Feb 18, 2017
    Posts:
    27
    Im running in the same problem, did you manage to solve it?
     
  33. ryschawy

    ryschawy

    Joined:
    Jul 28, 2012
    Posts:
    65
    It works and looks nice, thank you
     
  34. DMCH

    DMCH

    Joined:
    Nov 6, 2012
    Posts:
    88
    Hi. I'm using lux water and it looks good, but the particle effects in the scene are not being reflected. The particles are on the default layer, and the default layer is included in the reflection mask of the Lux Water_Planar_Reflecton. Any ideas?
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    please read the last 3 pages of this thread to finfd the answers.
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    Particles using the new standard lit and unlit particle shaders do not show up at all as they use back face culling which – in conjunction with the oblique projection matrix of the reflection camera – make them being culled by the gpu.

    Legacy particle shaders most likely will show particles. But most of them incorporate "soft particles" which are based on the depth buffer and the clip space position. This does not work in case you have an oblique projection matrix like in case of the reflection camera.

    In order to be safe you should use a legacy particle shader which does not support soft particles like the particles/vertexlit blended shader.

    You can also write your own particle shader but you have to make sure that the shader 1) uses “Cull Off” and 2) does not use the soft particle feature – at least not when the reflection camera renders.
     
    camta005 likes this.
  37. id55503

    id55503

    Joined:
    Dec 23, 2017
    Posts:
    4
    I build the ps4 package use example in luxWater plugins. The water is pink when working on ps4.
    The output console:

    Initialize engine version: 2019.4.9f1 (50fe8a171dd9)
    Profiler enabled
    WARNING: Shader Unsupported: 'Lux Water/WaterSurface' - All passes removed
    WARNING: Shader Did you use #pragma only_renderers and omit this platform?
    ERROR: Shader Lux Water/WaterSurface shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
    WARNING: Shader Unsupported: 'Hidden/Nature/Terrain/Utilities' - All passes removed
    WARNING: Shader Did you use #pragma only_renderers and omit this platform?
    ERROR: Shader Hidden/Nature/Terrain/Utilities shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
    ERROR: Shader Hidden/Lux Water/UnderWaterPost shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
    ERROR: Shader Lux Water/Particles/UnderwaterParticles Alpha Blended shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
    WARNING: Shader Unsupported: 'Lux Water/WaterSurface Tessellation' - All passes removed
    WARNING: Shader Did you use #pragma only_renderers and omit this platform?
    UnloadTime: 0.503238 ms
    Setting up 1 worker threads for Enlighten.
    Thread -> id: 880f5b840 -> priority: 1
    Invalid pass number (1) for Graphics.Blit (Material "Hidden/Lux Water/UnderWaterPost" with 1 passes)
    UnityEngine.Graphics:Internal_BlitMaterial5(Texture, RenderTexture, Material, Int32, Boolean)
    UnityEngine.Graphics:Blit(Texture, RenderTexture, Material, Int32)
    LuxWater.LuxWater_UnderWaterBlur:OnRenderImage(RenderTexture, RenderTexture)

    [.\Runtime/Camera/ImageFilters.cpp line 934]
    (Filename: .\Runtime/Camera/ImageFilters.cpp Line: 934)
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    the shader itself does not include any "#pragma only_renderers". but unity's shader lab might have added it automatically due to any compilation issues.
    so in the first first you will have to search for "only_renderers" in the shader files. if unity changes anything usually you will a comment there as well why this has happened.

    most likely however shader compilation on export produced an error as ps4 is very picky regarding lerps.
     
  39. TaylorCaudle

    TaylorCaudle

    Joined:
    Feb 8, 2018
    Posts:
    154
    Best way to get ripples whenever a player collides with water mesh?
    Would I need a Projector as a child of the main player gameobject, that turns on maybe OnColliderEnter when the player touches the water mesh? I was hoping to use the Deferred tessellation for it, but im getting some weird screenspace issues trying to get the ripples to just sort of stay on the water mesh. Trying to copy some setups from the demo scenes but cant quite figure it out
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you need a projector. but using collision here is not feasible - at least not if you use gerstner waves. cou should get the height of the waves in this case and colpare it with the player position.
     
  41. TaylorCaudle

    TaylorCaudle

    Joined:
    Feb 8, 2018
    Posts:
    154

    Ah, so the ripples only work for static objects?
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    no, just have a look at the demos...
     
  43. TaylorCaudle

    TaylorCaudle

    Joined:
    Feb 8, 2018
    Posts:
    154

    Yeah I see some projectors parented to static objects, was hoping to just sort of effect the water as an object moves through it, but you're saying it can't be on the player yes? just something thats locked to the surface of the water?

    The demo only has the example of the cyllinder standing still in the small pond, and the foam projectors which only work on flat plane, etc.
     
  44. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    Why do Caustics ALWAYS work above water but Rarely works underwater for me? I fix it and save my file, i close and open my project and it wont work underwater. same exact settings. Is this a bug? I can't get it to work underwater for some reason. and if i do fix it after hours of trying and and save the project it won't work when i reopen.. what are the steps to get underwater caustics working?
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    it is absolutely possible to attach any projector to a moving object.



    foam projectors also work on water surfaces using gerstner waves.
     
    Bartolomeus755 likes this.
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i have no idea what you are talking about. screen shots?
     
  47. jimmygladfelter

    jimmygladfelter

    Joined:
    May 3, 2020
    Posts:
    83
    Hello!

    Im using Enviro with Lux and I have enabled the Enviro fog shader, but when I go underwater, I can see way too far. Ive tried messing with the Shader properties (im using infinite ocean water material) but I cannot seem to make this better. Is this controlled by Enviro possibly?

    Any ideas on how to make it more foggy in the background so I dont see miles underwater?
    I have assigned the Enviro Directional Light in the Lux Underwater Fog component too.
    upload_2020-9-16_23-2-17.png

    Here are my shader properties for reference as well:
    upload_2020-9-16_23-5-41.png

    EDIT: If I disable the Enviro Manager, it looks as expected:
    upload_2020-9-16_23-56-29.png

    Anyone know how to fix this?


    EDIT 2:
    I fixed it by adjusting the order of components on the main camera. The enviro effects must come before LUX:
    upload_2020-9-17_0-34-20.png
     
    Last edited: Sep 17, 2020
    camta005 likes this.
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i am glad you fixed it!
     
  49. TaylorCaudle

    TaylorCaudle

    Joined:
    Feb 8, 2018
    Posts:
    154
    Hey there- I managed to get the projector working for the player, but i do have a question about Azure Sky- im having trouble getting the Azure fog to work with distant water, is there something I'm missing somewhere?

    I've enabled the Azure shader options, but just not the fog. Everything else reflects properly in demo scenes!
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    not that i am aware off...