Search Unity

[RELEASED] Lux Water

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

  1. lo-94

    lo-94

    Joined:
    Nov 1, 2013
    Posts:
    282
    Hmm... my pivot matches the water planes. I used probuilder to set the pivot to the center of the top and then exported the object as a obj. If I use vertex snapping on the pivots, the two objects align perfectly. Could it be that my water plane is scaled to (1000, 1, 1000) and my water volume matches it exactly when scaled to (1, 1, 1)?
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    ah, yes. when the scripts draws the water volume, it takes the transform's properties from the water plane. so the volume gets scaled to (1000, 1, 1000) as well.

    having a look at your 2nd screen shoot it seems that the water volume is too small along the y axis as it does not cover the entire screen.

    you may visualize the water volume by assigning your water volume mesh to the water plane's mesh filter component.
     
  3. drakekaz

    drakekaz

    Joined:
    Jan 16, 2014
    Posts:
    43
    How does this bad boy hold up in VR?
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i have not tested it yet, sorry.
     
  5. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Hello; bought and would love to use this but when I did a quick iPhone (X) test with the initial release it looked totally unsupported - as in just rendered as a cloud of (large-pixel) static where the water was supposed to be. I didn't investigate further because I just figured you weren't supporting metal - but I saw some mention that you're starting to?

    Would love to take a look again, but wanted to first check if you've done anything that would make a big change on iPhone?
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    the water surface renders fine on metal (mac book pro) when setting "Zwrite" to "Off" in the water material editor – which however leads to artifacts when using gerstner waves.
    i haven't checked it on any ios device tho.
    i am also looking into supporting proper gerstner waves on metal.
     
    mmaclaurin likes this.
  7. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Cool - would love to get this asset to run on the iPhone.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    oh, i like underscores very much :) it helps me to get a nice sorting (folders) and makes script names better readable. files you do not need to work with like the cgincludes do not have it tho.

    but maybe you have a concrete suggestion?
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    these are things i access a lot. so i want them to be on top of the hierarchy.
    actually it is a mistake... but if i change the shader's name now, peoples' materials will break.

    you can use one single plane – or a bunch of planes. if you just use a huge single plane then a lot of vertices might be off screen. so they get displaced by the vertex shader (when using gerstner waves) and then skipped by the gpu – which might be a big waste of computational power.
    so you may consider using a bunch of planes instead. then unity will cull the planes on the cpu and the gpu only renders the planes which are at least partly visible.
    the water planes in the fjord demo are simply taken from unity's water 4 asset.
    but for a lake a single plane or mesh should be feasible.
     
  10. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Lars, I definitely support keeping your code in the style that makes sense to you. Your sources are well-laid out and easy to work with.

    I also really like that I can just put the shader on any mesh.

    Question: It seems like everything is in world space, so is it true that I can just have a single ocean tile attached to my boat to achieve an endless ocean effect?

    Minor gotcha: if you forget to put on the reflection plane modifier, the shader fails entirely. It was pretty easy to figure out but I wonder if this could be more robust in the editor? Not worth any extra work at runtime, tho.

    Thanks!
     
  11. lo-94

    lo-94

    Joined:
    Nov 1, 2013
    Posts:
    282
    Still no luck getting the water volume functioning :( will later updates provide an easier setup method? I may just hold off until then if that's the case. I tried creating the cube in probuilder, setting the pivot point to the center of the top face, aligning exactly to a plane at (1,1,1) scale, assigning the same materials found in the demo water volume scene, then assigning all the necessary scripts and assigning the created mesh to the Lux Water_Water Volume script and I get an effect which basically greys out the whole screen when I go below the surface

    WaterVolume1.PNG WaterVolume2.PNG
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    who are the others? is it you? is it somebody else? there are as many likings as there are users :)
    it looks as if unity meanwhile can handle this. so it will be fixed.
    like some other issues you complained about.
    it is a 9$ water shader. there are water assets for 35$ which mainly do mesh generation. or there used to be water asset for around 100$.
    now one might ask oneself why all 100$ plus water shaders have been deprecated?!
    i guess that if you make things too complicated handling any use case and adding wizards on top of wizards a single publisher simply can not handle it.
    so i will focus on the shader for the next month.
    but e.g. cascades has announced water volumes and in a further update they might work as lux water volumes.
     
    Last edited: Aug 19, 2018
    sjm-tech likes this.
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you can choose between world space and uv mapping.
    and in order to create an endless ocean effect you would have to shift your water plane according to its tessellation - at least if you used gerstner waves. i have not tested this tho.
    what do you mean with "reflection plane modifier"?
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    can you send me the water plane, the generated volume and some simple geometry? then i can take a look into it.
    thanks.
     
  15. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Sorry, forget the reflection bug report, I think I mixed up my water shader tests...
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    gerstner waves are pretty picky and first and foremost need properly tessellated geometry. i guess that your plane has way too few vertices to ever give you a nice result.
    but creating just one highly tessellated mesh should be a rather bad solution when it comes to performance.
    so i would use at least 3x3 tiles in order to benefit from culling done one the cpu (assuming that your game takes place on the islands).
     
    Rowlan likes this.
  17. larsbertram1

    larsbertram1

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

    [edit] sorry for the inconvenience: version 1.03 contains some bugs due to the renaming. version 1.031 which i have submitted right now will fix these.

    in case you do not want for the update:
    the LuxWater_WaterMask.shader still looks for LuxWaterGersterWaves.cginc which now is called: LuxWater_GersterWaves.cginc.
    you can simply use find and replace on the LuxWater_WaterMask.shader.

    version 1.031 is available now.
     
    Last edited: Aug 22, 2018
    Rowlan and sjm-tech like this.
  18. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Ah, this is interesting. Does this performance tip apply even if there is no tesselation? I'm not using Gerstner but I do have a single quad for my ocean that moves with the boat. Should I split it into 3x3 tiles (or more) to gain performance? I thought the z-test would save me enough.
     
  19. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    I really like the look of the water and the reflections :)

    lux.jpg
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    that depends on the number of vertices you use for your plane: more vertices = more wasted work in the vertex shader. i guess it should be ok, but you can always do a simple test and use the profiler to measure performance.
     
  21. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    This asset is really awesome. I do like the results:

     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    fine.

    maybe the specular color of your water is a little bit too bright?
    it looks too reflective IMHO – just like a mirror – so you do not really see any of the muddiness (but only the blue from the sky) unless the camera goes underwater, which then becomes a harsh break.
    if you want a more bluish look of the water/underwater you may tweak the "fog color".

    you may also try to increase the "bump scale" an the planar reflections: right now reflections only get a tiny bit of distortion (if any) – whereas when the camera looks towards the sun the specular highlights are quite wavy. theoretically both should match.

    reflections.jpg
     
    antoripa and Rowlan like this.
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    version 1.031 is available now.
     
    Rowlan and sjm-tech like this.
  24. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    Thank you very much for your feedback. Gotta fiddle around some more with settings, still too reflective, but that's definitely better:

    better.jpg

    If you need ideas for an addition to your asset: A ripple effect when the object moves through the water would be nice.

    Another big plus for me is how the asset integrates with enviro.
     
  25. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    163
    Hey there,
    Does in work in defered ? And what about VR ? Any complications ?
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it works best in deferred – although the water shader of course uses forward rendering.
    regarding vr: i haven't tested it yet. but vr and deferred?
     
  27. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    163
    I know.... But I´m forced to finish a project that was setup that way. But it works quite good surprisingly. But I´m missing some decent water.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you may give it a try. i think almost all should be fine in vr – except maybe for the underwater rendering as the shaders may miss some single pass stereo commands. should be easy to add in case this would be needed.
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    that is what is coming next.
     
    Rowlan and sjm-tech like this.
  30. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    latest build - I'm sure I missed something, but can you help me out? Tried to delete the shader cache, but no joy.

    upload_2018-8-23_16-23-31.png
     
  31. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    I deleted the entire package and reimported it. Quickest solution :)
     
  32. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    That worked - but now I have this one, which I've had before but went away on its own:

    Shader error in 'Lux Water/WaterSurface': variable 'normal' used without having been completely initialized at Assets/LuxWater/Shaders/Includes/LuxWater_Utils.cginc(13) (on metal)

    Compiling Fragment program with UNITY_PASS_FORWARDBASE DIRECTIONAL LIGHTPROBE_SH GEOM_TYPE_LEAF
    Platform defines: UNITY_NO_DXT5nm UNITY_ENABLE_REFLECTION_BUFFERS UNITY_NO_CUBEMAP_ARRAY UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 SHADER_API_DESKTOP UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    line 5 in LuxWater_Utils.cginc should initialize the normal, but it does not as it is missing "normal = ". it should look like the line below:
    normal = normalize( n1 + (n2.xyz * 2 -1) + (n3.xyz * 2 - 1) );​
     
    onefaceoneface and mmaclaurin like this.
  34. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    @larsbertram1


    Your water asset looks very promising! Just want to know how the water effect will look in a 2.5D game. My game needs my character to be partially submerged in water. Its a Diving game.
    When diving from surface, the submerged portion needs to have underwater effects applied (like fog, caustic etc) I can see it in the above example. But does it water when Waves are enabled? Also I need to use effects like Lights, Spot lights , Sun shalfts(God ray) inside the water, will you water shader support underwater lights?

    Let me know and I will buy this right away :)
    Here is a video of my game :
     
    Last edited: Aug 24, 2018
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    underwater rendering is done as image effect. so it does not know about any lights.
    of course lights will effect all objects below the water surface. but underwater fog will only be lit by the main directional light (which is feed in by script).
    so in case you are looking for the most sophisticated underwater lighting with point and spot lights illuminating underwater fog, i would use one of the available volumetric fog assets and use the underwater mask provided by lux water to limit volumetric fog to the parts of the screen which actually are under water.
     
  36. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Should the underwater reflection tint affect my water when seen from above? It does....
     
  37. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Some more testing on metal: I think normals might be backwards? Specular highlights are dark, some unusual results with reflection

    Here is "fjord" on metal - reflections and specular are missing (although I have managed to get planar reflections alright on other scenes using Metal...)

    upload_2018-8-24_22-16-8.png



    And here on GLCore - much nicer:

    upload_2018-8-24_22-16-43.png


    Simpledemo, GLCore:

    upload_2018-8-24_22-19-42.png

    ...annnd Metal:

    upload_2018-8-24_22-20-3.png
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,
    as written in the docs, metal is only partly supported right now. but i will look into metal as soon as i have finished the next feature.
    meanwhile you can set "ZWrite" to "Off" and "Culling" to "Back" to get at least proper front side rendering.
     
  39. lo-94

    lo-94

    Joined:
    Nov 1, 2013
    Posts:
    282
    I'll get you the water plane and volume shortly. Sorry for delay, been a busy week (big release at work)
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it should not. maybe because of metal getting confused about normals and above/under water?
     
    mmaclaurin likes this.
  41. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Cool. Understand that metal is a work-in-progress. Good news is that performance is good on iPhone X, so I can keep going on other parts for now.

    One interesting finding is that setting reflection to 1/8th looks pretty bad on desktop but looks great on iPhone X because the pixel density is so high to begin with. No stair-stepping is visible at all!
     
  42. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    i'm looking forward to it, will definitely add it here, work in progress:



    this asset is really awesome. and the performance is top. gotta check out next how to set up the underwater area
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    this is the first version of getting water overlays or projectors in. these will allow you to e.g. use particles to create foam trails or local waves and distortions.



    locally projected normals distorted by gerstner waves:

    projected_normals.jpg
     
    mmaclaurin, Rowlan and sjm-tech like this.
  44. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    @larsbertram1 will we be able to use the overlays / projectors to perturb the surface normals? interested in doing subtle wakes that are just ripples with minimal foam
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    yes, just like shown in the image above: the water rippels – well: rings – are locally projected on top of the regular water normals. they are created using a standard particle system.
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    version 1.032 is available which fixes non DXT5 normal issues.
     
  47. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    Thanks for your response!

    If you dont mind could you please post an image or video of how volumetric fog will look when combined with your asset?
    I am asking because , I invested in one well known Water asset here and it has so many restriction when it comes to underwater effects! Even underwater Air bubbles are not rendered properly... :'(
    I had to ditch it and look for other alternatives. Your asset is the best one I found so far, with lot of examples and quick response to queries :)
     
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    sorry, but i do not have a project with lux water and any volumetric fog solution right now...
    and actually the proposed solution will need you to hack both: the volumetric lighting and lux water.

    the lux water underwaterrendering script creates a mask according to the water volume and applies underwater rendering later in the frame as image effect where it uses the created mask.
    you will have to get rid of that image effect to be applied and simply keep the mask creation part.

    instead of rendering underwater using the image effect provided by lux water you take the volumetric lighting solution.
    you have to hack this as well and feed the created mask into the shader that finally copies the volumetric fog into screen. use the mask to mask the volumetric fog.

    i hope this brief description helps you to get it up and running. otherwise just come back to me.
     
  49. Zaki_X

    Zaki_X

    Joined:
    Jul 5, 2016
    Posts:
    55
    Hi Lars! We've been using Playway Water (called later Ultimate Water) that has been unfortunately abandoned by two dev teams . This water system was very unstable and kept giving us odd effects when combined with interior scenes and was extremely heavy so we've started to look for a different solution.
    Would you recommend your water system for interior scenes like pools in the buildings with many point lights? (with no directional light nor skybox).
     
    Last edited: Aug 28, 2018
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    the water shader always uses forward – so the number of per pixel point lights is limited by the quality settings.
    and it should be limited anyway to make it not go crazy.
    water is simply not lit in deferred so many point lights are a killer.

    could you share a screen shoot if such an interior scene?

    i would not go with more than 4 point lights. you might exclude certain lights from lighting the water (using layers and layer masks) and mark some lights as important in order to avoid sudden changes in lighting. these changes might occur caused by the fact that lights and/or the camera move which may make unity pick up another set of lights as the most important ones.
    per vertex lighting is disabled in the shader.

    regarding the "missing" skybox: you should provide a reflection probe to make the water shine.
    or do you use planar reflections?