Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    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,353
    never checked this.
    it is pretty much optimized.
    yes, of course.
    depth of filed and mobile? are you kidding? but water (which includes foam as it is only one singe surface) should render prperly to depth. so it should be just fine.
     
  2. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    I’ve played some iOS games with depth of field and bump mapping etc.

    Thanks for Answering everything man. As soon as I get home I’m buying this sucker. You won’t be abandoning It soon right?! Lmao!

    And adding buoyancy has to be a separate asset or does this do it already?

     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
  4. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    Sounds good. What are the limitations to this script? I just want to drive a boat over a relatively calm bay/beach And some light swimming.


     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    oh, this is out of my scope. but i think it gives you everything you need to get physics up and running nicely.
     
  6. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    Gotcha, sounds good man. Yea I saw the video on YouTube by NWH Coding:


    Thanks again.I’ll report back with some screen shots.

    I’m Cuban and live in miami/Miami Beach, grew up around water and beaches and I love them so I’m very particular about it lol! It was a hard choice between your asset And this one:
    https://assetstore.unity.com/packages/vfx/shaders/stylized-water-shader-71207

    But even though that one has mobile support, it don’t think it has underwater features and displacement like your asset does (for/blurs, etc) And I’m sure if I tint the water blue with your asset, and use my own foams, I can replicate that beautiful blue look that this one is showing off. Plus your assets has reflections, I don’t think that one does. And if your is optimized and faster the AQUAS I’m sure it’ll run fun on iOS. My aim is for xbox, windows, switch and ps4 anyways. iOS is secondary.

     
    Last edited: Aug 4, 2020
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    in order to be fair, i do not comment much on other people's assets. but @StaggartCreations for sure are top notch as well. lux water is just simply outperforming in most cases :)
     
  8. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    Ok so I bought the asset. Made a cool looking pool. I calmed the waves and removed the foams (good for jacuzzis though). And it’s looking sexy.

    how do I get the bottom side to (underwater looking UP to the surface) to ripple like the top part of the water? I can only achieve this if I insert a cube and flatten it, but the underside waves intersect with the surface waves and you can see it cutting through.
    So I used a flat square but if I go under it, and look up, there’s not see through ripples.

    I try adding the underwater fog but I just can’t get it to work. I have to add scripts to the camera for this? And how do i get the automatic displacement and foam to appear when colliding with objects/player?

    Is there a how to or video for this?
    I’ll keep digging.

     
    Last edited: Aug 5, 2020
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    please have a look into the provided demos :)
     
  10. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    Will do. I also saw you have a google docs online explaining many things. I stayed up late last night studying. Gonna tinker with it some more tonight after work and the whole weekend too lol.

     
  11. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    571134DB-E0EA-4E92-A19A-1A9E4E829886.jpeg Ok very good. I’m learning how to use the foam and waves. Frequencies, tiling, speed, etc

    I set the foam alpha to 100% and it looks cel shaded which is what I want for this particular game. :) I wonder if there’s official cel shades/cartoon foams I can use.

    still not sure what rotation does.
    it seems to rotate the texture? How do I randomize the foam? If you see my photo it looks like a pattern. Rows of 3.
    Check out the foam on this bay to see what I mean. I’ve attached the photo. Came out sideways for some reason. Maybe it’s a forum glitch but you can see how the patterns of the foam are not randomized.


     
    Last edited: Aug 6, 2020
  12. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    So far so good! Everything looks great! Got the under water volume working. Still don’t know how to do the tessellation reflections underwater but I’m working on it. i also need to figure out the displacement and foam trails for any objects colliding with water.

    But if you see the photo attached, i have a weird bug where the water is black but the moment my player collides with it, It turns to the designated color. This only happens in game however. Not in the scene. Any ideas?

     

    Attached Files:

  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    black may mean: infinite depth. you might use the frame debugger to find out how the depth buffer looks like.
     
  14. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    inteesting. But why does it turn back to normal when player collides with it? Almost like collision activates the color.


     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    i have no idea. also it could not be depth but something else:i never heard of something like this before.
     
  16. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    B7C6DD5F-7DA9-44DC-915A-E4BECEBE072F.gif


    here I made a gif.
    notice when i zoomed in and out on the scene view, it goes from light to dark. And in the game view, when I dropped my player, the moment I hit the water or turn the camera the color instantly comes up.

    And here the real weird part. It ONLY happens after I press play. If I zoom in and out in the scene view, while not in play, This doesnt happen.


     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    is this just the water shader? or do you have attached any lux water scripts? like underwater rendering?
     
  18. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    just copied and paste over the the ocean prefab you had on the demos. And it was fine for a few days up until two days ago.

     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    what happened?
     
  20. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    not sure. Was hoping you give me some pointers. It’s your asset not mine lol!
    you did have a point with the depth scale. I messed with it and whenever the water is dark, it’ll brighten it up. But that still doesn’t explain the reasoning for the actual problem.

    I’m gonna remove it and re add it to see what happens. It seems to be affected by the shadowing.

     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    it is your project and scene, not mine :)
    this sounds as if you are using "deep water lighting"...

    from the docs:

    As version 1.07 introduced deep water rendering which may set some global overwrites each demo has a UnderWaterRendering script assigned to the camera which resets these overwrites in case you switch between the scenes and use deferred rendering.

    This script usually is only needed in case you actually use water volumes and deep water rendering.

    In case you get strange lighting on the water simply activate, then deactivate “Deep Water Lighting”.​
     
  22. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    I’ll give that a try today. I’m currently dealing with an issue where cinemachine appears to have issues due to the collider I need to have with the camera for lux. If I disable the collider on the camera, cinemachine stops going crazy zooming in and out of my player but I lose the under water camera effects. I’m playing with the camera tags to see if I can work around it.


     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    you coul place the collider somewhere near the camera, so it does not collide with the camera itslf but still triggers underwater.
     
  24. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    EDIT: disregard, your method fixed it!! Disabling deep water lighting fixed it. However if i turn it back on, the water turns black again.

    What is deep water lighting for? My underwater still looks good and blurry like I wanted. Is this for very deep waters?
    ——————————————
    original message:
    That is what I was trying but the camera itself appear to be the collider. Speaking of witch, I just confirmed that the camera collide is definitely the issue with my water turning from black to green. It starts black and the moment I look up and the camera touches the water (using free look camera that orbits around the player), it changes the water to green. I’m not sure how or why this happened. I tried playing with the camera radius to confirm this.but if I remove the water volume script this issue goes away too.

    When I first started using the asset the water never had issues no mater if the camera was touching the water or not. So somewhere I messed up. I tried adding a different prefab and same issue. Maybe my problem is with the camera

     
    Last edited: Aug 9, 2020
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    it is for very deep waters.
    it basically reduces the strength of any directional light according to a specified y coordinate but keeps local spot and point lights untouched. the package includes a demo showing this feature.

    this video does it as well:


    so if you do not need it just do not assign the otherwise needed custum deferred lighting shader.
    if you need it, make sure you set it up properly :)
     
  26. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    Yes I agree. Well I took it down and that solves that issue.

    for the record, I love this asset. Don’t think I’m knocking it cause I am not. I’m just learning how it works is all :)

    I will now try to add tessellation. Still haven’t figured that out. The body of eater I am using has tessellation on your demo but not on my level. I will dig in and see if it has all the scripts required and such. Nothing like some pretty ripples on underwater surfaces :)


     
  27. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    2 good things happened

    Looks like disabling the deep water lighting fixed the cinemachine issue. AND I now added the reflections to the surface. Looks beautiful. But two questions:

    how can I adjust the intensity of the reflections (mirror like , dull, etc)

    how do I add tessellation/underwater ripples on surfaces? I tried copying them over from one of the demos and it’s not reproducing.

    the more and more I use your asset the more I love it. Thank you again. Please advise on the above :)


     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    lux water does not blur planar reflections, if this is what you are looking for. so all you can do to them can be found under the headline "reflections" in the material inspector. intensity here would be strength.
    you have to change the shader and use the tessellation version.
     
    Last edited: Aug 11, 2020
  29. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    Actually I want to make the reflections stronger. But i will get this a try tonight.

    I’ll report back on the tessellation As well. thanks bro. :)

     
  30. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    I see i can now edit the reflections to mirror like if i wanted. even FLAT as if it were ice. so cool.

    I still can't add tessellation. I can edit the power and remove it on the demo#8 but i apply the same things to my project and it's not working. i'll keep trying.

    I've made sure camera is deferred, turns on msaa, added the scripts to camera and set the sun to directional light... still nothing.

     
  31. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    464
    can anyone tell me why my particles are rendering behind meshes in the reflection when they should be infront of meshes?

    thank you
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    i haven't faced anything like this yet. So can you post a screen shot showing the issue?
     
  33. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    464
    hi , here is screenshot, as you can see i have a unity cube bigger on 2 sides to make oblong, i have basic particle system in front of the block but in the reflection the particles are hidden by the block?

    particles hidden by mesh in reflection1.jpg
     
  34. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    464
    just worked it out by turning things on and off, it is caused by the LUX WATER PLANAR REFLECTION script, the render shadows box was ticked, when untick it all is working as it should? any fix for this problem?

    thank you
     
    neoshaman likes this.
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    might be a corner case regarding the oblique projection of the reflection camera and particles?
     
  36. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    I still can't add tessellation. I can edit the power and remove it on the demo#8 but i apply the same things to my project and it's not working. i'll keep trying.

    I've made sure camera is deferred, turned off msaa, added the scripts to camera and set the sun to directional light... still nothing.
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    tessellation only needs the proper shader assigned to the water. and of course hardware and traget profile to support it.
     
  38. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    464
    so how do i get this fixed?, is it only happening to me!!!
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    well, the newer standard lit and unlit particles do not show up at all (due to back face culling).
    the legacy show up 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.
    get rid of the soft particle and use particles/vertexlit blended e.g. and you will see you particles in front of the opaque geometry like you would expect.
    you can also write your own particle shader but make sure you do not use the soft particle feature - at least not when the reflection camera renders.
     
  40. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    464
    i see, thank you, i will give it a try
     
  41. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    487
    Hi larsbertram,
    i'm trying to setup the shader to be integrated with curvedWorld shader.

    Following the documentation, it seems to be not difficult, but the exemple doesn't correspond to anything similar in your shader...

    there is 3 steps:
    the first one is to integrate properties, nothing difficult here:
    Code (CSharp):
    1. [CurvedWorldBendSettings] _CurvedWorldBendSettings("5|1|1", Vector) = (0, 0, 0, 0)
    the second one is to add some definitions: "Paste copied string into the shader below Unity’s default #includes, but before the vertex stage:" seems ok to me i think, before ENDCG line...
    Code (CSharp):
    1. #define CURVEDWORLD_BEND_TYPE_LITTLEPLANET_Y
    2.             #define CURVEDWORLD_BEND_ID_1
    3.             #pragma shader_feature_local CURVEDWORLD_DISABLED_ON
    4.             #pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
    5.             #include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
    and the last one totally lost me because the example doesn't fit were it ask: to "Paste copied string into a vertex stage before calculating pixels screen space position.", in the
    v2f vert()
    {
    v2f=0;​
    Code (CSharp):
    1. #if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON)
    2.    #ifdef CURVEDWORLD_NORMAL_TRANSFORMATION_ON
    3.       CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL(v.vertex, v.normal, v.tangent)
    4.    #else
    5.       CURVEDWORLD_TRANSFORM_VERTEX(v.vertex)
    6.    #endif
    7. #endif
    o.vertex = etc...
    }


    and there is no v2f part in the luxwater shaders witch doesn't help to understand how it works.

    also i'm wondering if it will work with underwater parameter.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    oh, there is. you will find it in LuxWater_Core.cginc
    but unfortunately the vertex shader( v2f vert() ) works in worldspace (needed by gerstner waves and the texture projection).
    so you will have to add a lof of changes starting at line 422: here the shader calculates o.pos (clip space position).
    it uses worldPos to do so. so in case you want curved world to take over you first have to go back from worldspace to object space as curved world expects v.vertex which is in object space.
    do so by: v.vertex = mul(unity_WorldToObject, float4(worldPos, 1));
    then you should able to call:
    CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL(v.vertex, v.normal, v.tangent)
    the following lines 427 - 452 have to be updated as well as you will get back a normal in ws from curved world and the old worldPos is not valid anymore.

    projectors will not work properly. for these you will have to call CURVEDWORLD_TRANSFORM_VERTEX(v.vertex) to get the curved worldPos before you can calculate o.projectorScreenPos (around line 299).

    and underwater will not work at all :( even if you tweak the underwater mask shader accordingly i am not sure if the image effect finally creating the underwater image will work properly...
     
  43. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    487
    ok i understand the problematic, but sorry i'm not skilled enough in shader coding to get any reaction after modifying it...
    on 422 :
    Code (CSharp):
    1.     //  Projector Displacment
    2.         #if defined(USINGWATERPROJECTORS)
    3.             if(_LuxWater_Extrusion > 0) {
    4.                 v.vertex = mul(unity_WorldToObject, float4(worldPos, 1));
    5.                 float2 projectionUVs = o.projectorScreenPos.xy / o.projectorScreenPos.w;
    6.                 fixed4 projectedNormal = tex2Dlod(_LuxWater_NormalOverlay, float4(projectionUVs, 0, 0));
    7.                 v.verytex += v.normal * (projectedNormal.b) * _LuxWater_Extrusion;
    8.             }
    9.         #endif
    witch result as the exact same thing as if don't change anything...

    and forget the projector i will not use it at all in this project, i only need the waves to follow the earth bending style on this screen
    Screenshot at 2020-08-17 08 41 40.png
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    hmm, my line 422 looks totally different?!
    so look for "o.pos" this stores the clip space position which is what curved wold has to modify.
    1. bring worldPos back to object space and write it to v.vertex
    2. call the curved world macro CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL

    i have no idea what CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL will write into... hopefully it is o.pos.

    then make sure the vertex shader does not overwrite o.pos later on.
     
  45. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    Is directional lighting required for water volumes? Trying to setup some underground / indoor water, and having a directional light on everything would unfortunately not work. If this is a requirement, would it be possible to create a fake directional light and inject it directly into the shader?
     
    Last edited: Aug 22, 2020
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    under water rendering only supports one directional light...
    that is what the script already does :) it send light dir and intensity to the shader. so you can easily hook in here.
    maybe you do not even have to as i do not think that the script checks if the lght component is enabled or not.
     
    greengremline likes this.
  47. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    D96870AB-518A-473D-9A17-503E65323DB5.gif

    Hey guys. So I “hacked” 2 mirrors into my scene with this fantastic asset.
    Basically removed foams, waves and speed. Made it still and frozen. Turned on reflections.
    IT WORKS FLAWLESSLY however here is my issue.

    First set of reflections is on the bay area in my level. Works perfect.

    Second is on the “mirror” door on a building. Works perfect.

    Third is another mirror door but on a different building. The settings are identical to the first mirror door in the first building but it’s glitching up at CERTAIN angles. If I’m far with the camera it’s ok. But if I get close and turn, the reflection clips/cuts the reflections geometry and kinda shows the same reflection the OTHER building I’d mirrored door is reflecting. It’s kinda like cloning the same reflections.

    So I tried Duplicating the first building’s mirror’s shader so that there are two separarte shaders. But it still happens.

    Please see photo attached.

    Reflections were absolutely perfect on the first building.
     
  48. greengremline

    greengremline

    Joined:
    Sep 16, 2015
    Posts:
    183
    Thanks so much! I was able to override the underwater rendering part, however without a directional light on the water it doesn't look realistic. Would it be possible to override the water surface shader to take a fake directional light?
     
  49. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    141
    Any idea on the below ?

     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,353
    it would. but this is a completely different story tho.
     
    greengremline likes this.
unityunity