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
    Lux Water combines a lot of rendering features... and has grown from a shader for small ponds and lakes to an ocean shader. URP on the other hand is still evolving – just think about the upcoming deferred shader.
    so when it is a bit more feature pair i will have a look into this.
     
    Deleted User and Noogy like this.
  2. ramnath76

    ramnath76

    Joined:
    Apr 15, 2019
    Posts:
    4
    Hi,
    Is Lux Water package supported with 2019.3.0f1 release with Universal Render Pipeline ?

    Regards,
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    sorry, it only supports built in RP.
     
  4. ramnath76

    ramnath76

    Joined:
    Apr 15, 2019
    Posts:
    4
    Thanks so much for the prompt reply. I want to use shader graph for effects along with Lux Water. What option do I have I am wondering . I'm sure that I am not the first one to encounter this. Anyone ?
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you do not have any options to do so, sorry.
     
  6. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Hi, any suggestion to how to change waveheight or sea states at runtime with one slider or presets?
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    the water material offers final multiplier parameter xyz for the displacement. you may try to use this.
     
  8. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Okay, so then the speed and frequency also gets updated to believable results?
    A script example would have been really nice :) ..
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    nope... only the height. unfortunately you can't change frequency without getting jumps but you should be able to adjust the speed.
     
  10. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    When will see Lux Water supporting LWRP ?
     
    Last edited: Dec 15, 2019
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    no eta.
     
  12. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    I have been waiting LWRP for long time man. We see what you did on Lux LWRP, and you know how to upgrade Lux Water to LWRP in short time. I don't know what stopping you from taking this step since LWRP on stable level.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i wish it was like this. but it is not.
    talking about lwrp we are talking about urp. and urp means: no custom post prcessing.
    yet another example: urp (or 2019.3) broke offscreen rendering of particle systems and it took me a while to bring at least basic support back. so lux water urp right now would neither sipport projectors nor underwater rendering.
     
    hopeful and doarp like this.
  14. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    147
    BoatAttack demo project has decent water and it’s in URP so you can also use shader graph. but it’s not plug and play, you’ll need to fiddle with it to get everything working in your project and it’s a DEMO, so don’t expect any support from anyone.
     
  15. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    If you keep updating the asset, when you will find time take it to the new level ? One of the greats game engine in the world have in his store around 2-3 water shader support HDRP/URP !! Lux Water will not take from you a year to make it support URP. If 2019.3 broke PS, what will do on next update 20/21. Unity developers should provide some tools to help you guys to fix your asset.
     
  16. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    I'm a little surprised to see some of the responses here, making the assumption that these updates are trivial. Lars you take as long as necessary, I deeply appreciate your support with your various assets and am confident Lux Water will get there once URP functionality is matured.
     
    hopeful, Pvt_Hudson and doarp like this.
  17. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    147
    That needed to be said. Thanks Noogy.
     
    Noogy likes this.
  18. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23
    Agreed with Noogy. Take your time on URP / HDRP support. They are not production ready yet anyway.

    That being said, I am having issues trying to figure out how to do the sliding water volume for a large, non-contiguous ocean with world streamer loading in tiles and assets as I move around. I can't have the water volume on a single ocean tile or it won't even be loaded into the game when I'm on the other side of the land mass. Also, I can't have the water go underneath the entire land mass as I'll be building caves and dungeons under it. So, I have 59 of those 500x500 ocean tiles surrounding the island, but none beneath it. I also have the skirt ocean tiles surrounding those. I will need the water volume on the player object or on the player's camera object so that it is always loaded. I tried putting it in a child gameobject with a layer of WaterVolume and setting that layer to only collide with Ocean and Water layers to enable the volume. Each of the ocean tiles also has a collider on it which is 500 x 1250 x 500 (max ocean depth is 1,250m). I just can't seem to get it to work. It will also have to eventually work with floating origin, though that can wait for another day.

    I'm also getting errors about not being able to create a compute buffer (0x887c0003) and also getting errors about a missing render texture or something (same error code). However, the demos all work fine from within the same project. Do you have a Discord channel I can ping you on interactively? Troubleshooting would go a lot faster, I imagine.
     
    Noogy likes this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i have not.
    its been a while i have been deeply into lux water – but it does not use any compute buffers?!
    do you have any further info regarding the error?
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i guess you will have to add additional colliders which will disable under water rendering if the camera is beneath your terrain. or add some other logic to your code. i guess you already know when the player is in a cave (to drive image effects, adjust lighting ...) so simply disbale under water rendering.
     
  21. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23



    Failed to create Compute Buffer UAV, HRESULT: 0x887c0003
    Failed to create Compute Buffer SRV, HRESULT: 0x887c0003

    I just get a bunch of these errors. They started appearing after I added all the ocean tiles into the scene and the Lux scripts onto the camera. I also get this:

    D3D11: Failed to create render texture primary RTV (error 0x887c0003)
    Graphics.CopyTexture could not find destination D3D11 texture object. Maybe it is a RenderTexture that is not created yet?

    Is it possible Lux could be interfering with another asset? Though I don't know what else might be using a compute buffer. The only assets in the scene right now are Weather Maker, Vegetation Studio Pro, Rewired, UMA, MicroSplat, a Unity Terrain, and Lux. Everything was working until I added Lux.

    If you want to chat with me in real-time, you can join my Discord and message me. It's quicker and easier to send you screenshots that way.

    https ://discord.gg/ xuYUGZw
     
    Last edited: Dec 19, 2019
  22. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23


    I think the errors are related to Vegetation Studio Pro. Not sure how/why they started after bringing in Lux though.

    Anyway, the water volume is attached to my character, but I'm not sure how to get the movement to line up correctly. In the screenshot, you can see how the normal ocean tiles are misaligned with the one attached to my character. Also, the underwater effect is not rendering beneath the tile attached to my character. What would cause that?
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    that makes way more sense.
    altho the object is called "water volume" it is not a water volume: it is a water plane with a mesh and a regular water material – nothing you want to move with your character. it may also contain a collider (as i can see on your screen shot) and the water volume script – but it still is water tile you move with your character which also contains the volume.
    just take the collider: it does not make any sense to move the collider (not to mention that it is fairly expensive to move a collider which does not have any rigid body component): the camera/character will always be inside the collider...
    the water volume actually is only the "water volume script" which holds a reference to the volume mesh matching the mesh you use on the water surface tiles regarding grid size).
    it is controlled by the "underwater rendering script" which "virtually" moves it around in fixed steps matching the specified grid size (size of quads the water volume and surface mesh is made out of). "virtually" means: there is no game object, transform or renderer handled by unity which represents the volume. the volume is simply drawn by the "underwater rendering script" into the water mask render texture based on the position of the camera, the referenced volume mesh and the grabbed y position.

    in fact the provided "water volume script" contains more dependencies than it really needs: it is written to be attached to a water surface tile and relies on a transform (which it gets the y position from) and also controls the collision with the box collider defining the entire water volume. the real meat however is in the function "register".
    the "underwater rendering script" also handles volumes as if they where parented under one of the actual water surface tiles as it grabs and controls:
    - WaterMaterials
    - WaterTransforms
    - WaterIsOnScreen

    the easiest way is to keep all this and exclude the ocean from being handled by world streamer. just have a look at the infinite ocean demo where the ocean is made out of 5x5 tiles and a skirt and smoothly follows the camera.
    you will waste some performance as tiles would be drawn even if thy were entirely hidden by the terrain but...
    in order to exclude the water volume when the camera is under the terrain you might add "exclude colliders".
    they would have to register to the "underwater rendering script" just like the volumes. and before drawing the volume and the under water image effects you would have to check if your camera is inside any of the registered exclude volumes and simply return if so.

    if you want to parent one tile containing the water volume script under your camera you would have to get rid of the collider and the collider related code. you also would have to make sure that the tile has a constant y position which defines the ocean height.
     
  24. cineruss

    cineruss

    Joined:
    Mar 20, 2019
    Posts:
    27
    Does ANYONE have any tutorials on how to use this? I have the manual but basically not getting anything but a water surface with no waves at all even though I make adjustments to the wave settings. I have gone over every setting without any wave results. I must be missing something major. Does anyone have any tutorials on how to set this up?
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    just start with the content provided in the demos.
    for a simple plane (and no tessellation) take a look at the fjord demo.
    the used water mesh is highly subdivided to give you enough vertices which can be displaced. if you only have a simple quad displacement will look odd.
    if you need more details you would have to use tessellation.
    so simple copy the water material used in the fjord demo and assign it to your mesh. then start and tweak the values.
    doing it from scratch will most likely be a pain...
     
    cineruss likes this.
  26. cineruss

    cineruss

    Joined:
    Mar 20, 2019
    Posts:
    27
    Should have known it would be that easy as compared to doing it all from scratch..great demos and work well in my project..thanks a bunch
     
  27. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23
    I parented the water volume object under my Avatar as I can't put a rigidbody and trigger on my camera or it messes up the camera's movement (due to the way the character controller interacts with the camera).

    I've tried keeping the water tile surface properties on water volume object and making it align with the nearest real water tile (the intent being that I will disable the real water tile it replaces as I move around), and then added triggers to my Avatar so when it collides with an ocean tile, it enables the water volume.

    Unfortunately, while I can verify that the game code to enable the water volume is executing (and the tile is correctly aligning precisely with the ocean tile it will replace), I cannot get any under water effects to show up. I even tried adding code to the triggers to have it enable the USINGWATERVOLUME keyword on the water volume's renderer.

    No matter what I try, I cannot seem to get the water volume to actually render at all. All I get is the water surface with its waves and caustics.

    I have no idea what I'm missing. Any thoughts?
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    enable debug to see if the manager registers any active volume.
    if not your trigger is not set properly.
     
  29. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23
    Not sure what debugging you are wanting enabled. I added a Debug.Log to the under water rendering script and it shows that the water volume is being registered. What else should I check?
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    if it is activated.
     
  31. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    17
    @larsbertram1 The ability to mask out fog underwater (like unity3d exponent squared and enviro fog) is awesome.

    I'm trying to add support for "Dynamic Fog and Mist" to LuxWater_Setup.cginc and LuxWater_Core.cginc. Would you have any pointers for what "Dynamic Fog and Mist" functions I should be looking for (like Enviro's TransparentFog() function)? Thanks.
     
  32. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23



    I got it working, but the underwater caustics are a bit over-driven. You can't even see the ground texture. Also, the performance is tanking while the underwater rendering is occurring. If you can see the upper left corner of the second image, there are green, yellow, and red frame timings. The red frame timings are rendered at about 2 fps, the yellow around 20 - 30 fps, and the green at around 60 fps. You can see I get a handful at 60+ fps, then a couple at 20 - 30 fps, then one or two at 2 fps, then another handful at 60+ fps, a couple more at 20 - 30, then back to 2 fps again. As soon as I disable the under water rendering, everything clears up and I get a pretty solid 50 - 70 fps. The stats counter from Unity doesn't seem to be very accurate in my testing.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    great.
    looking at your specs (gtx 2080) i am pretty sure that your are doing something wrong. as underwater rendering even on my gtx 750M does not really cost much. so just check out the ocean demo e.g. and have a look at the performance impact of the underwater rendering there.
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    actually you should ask kronnect about this. but i would look into the provided shaders like the "DFMUnlit" shader.
    it includes "DFMVertexFragmentShaderCommon.cginc" and calls: fogColor(IN, c);
    unfortunately it uses an input structure IN (declared as v2f), which does not fit the input structure used by lux water...
    so you will have to rewrite the function like this:

    replace:
    void fogColor(v2f IN, inout fixed4 c) {
    float3 worldPos = IN.worldPos;
    with this:

    void fogColor(float3 worldPos, inout fixed4 c) {
    //float3 worldPos = IN.worldPos; // <---get rid of this

     
  35. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23
    I figured out the frame rate thing, too. Here is a quick demo. Note that when my character was displaced by the gerstner waves, it went above the collider which deactivated the under water rendering in this video. I've since fixed that issue by increasing the height of the collider to compensate for the waves.

     
  36. ramnath76

    ramnath76

    Joined:
    Apr 15, 2019
    Posts:
    4
    I am planning to show a raft swaying up and down in the lux ocean water. Swaying should be in unison with the ocean waves. Can you please provide me some pointers on how I can achieve this ?

    Regards,
    Ram
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    in the ocean demo you will find spheres and particle projector which follow the gerstner displacement.
    these and the used script should be a good starting point for your undertaking.
    but please keep in mind that the resolution of the ocean is limited (by geometry and tessellation) whereas the script has an infinit resolution so that the results from script will not 100% match the visual displacement shown at the ocean's surface.
     
  38. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23
    I'm still having an underwater rendering issue where I get a white band at the horizon. I would expect it to be the standard underwater ocean blue. Basically, the underwater view of the surface should meet up with the underwater view of the ocean floor at the horizon. Any idea why I'm getting this white band? I have my camera far plane at 10k and I've tried setting it as high as 24k with no effect. I also have a skirt around my terrain and around my ocean which go out about 260,000+ units.

     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    not really, it could be anything. use the frame debugger and disable enable certain features of the water material.
    enable debug view and see how the generated mask looks like: do surface ans volume meet at that line?
    i would recommend to not using such crazy values...
    floating point values loose accuracy the higher they get (regarding number of digits).
    the range between -9999.999/+9999.999 should be fine (precision is in milimeters).
    using >= 10000.00 will steal one digit behind the period (precision is in centimeters).
     
  40. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23
    The main playable scene is -4096 to 4096. The diagonal of the playable area though is 11,585, so I really should have my view distance set to 11,600 or so. I'll be using LODs with baked lower poly meshes for the distant terrain tiles. The white is part of the skybox. When sunset comes, that band turns orange. So, I am seeing the horizon between the ocean floor and the ocean surface. I suspect that the below-ocean surface rendering is somehow falling short in the distance. The water volume is making it look slightly more blue than it would otherwise be, so I'm pretty confident the water volume is rendering in that area properly.
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i would recommend to disable underwater blur to get a better picture.
    and if there really is a gap between water surface and water volume then:
    a) the water surface is too small
    b) the water volume gets clipped due to distance
    c) water volume and water surface do not match as far as their positions are concerned.
     
  42. egable

    egable

    Joined:
    May 21, 2014
    Posts:
    23
    I'm still troubleshooting that gap, but on another note, do you have it on your roadmap to add better shoreline support? For example, rolling waves which gather themselves as the water depth decreases and then come crashing onto the shore pushing foamy and muddier water up the shore a long ways, which then drains back down into the ocean? Something like this:


    I'd really love to see this type of shoreline effect added to the water system. Also, the stuff that Crest Ocean does with the flow maps would be wicked awesome, too. If you had both of those, I think it would easily cement your water system as the top option.
     
    Vincent454 likes this.
  43. cineruss

    cineruss

    Joined:
    Mar 20, 2019
    Posts:
    27
    OKay I have my lux water the way I want it but when I switch to an Android build, my water disappears. Any idea what is happening? Or is Lux water supported for mobile devices?
     
    Last edited: Jan 1, 2020
  44. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    im also hoping u will make urp version, but no rush ;)
     
  45. hoodoo

    hoodoo

    Joined:
    Oct 19, 2012
    Posts:
    154
    Hi @larsbertram1 - I'm having trouble with a couple things setting up Lux Water.
    1. Using the Ocean_5X5 prefab in a simple scene. The water color appears dull brown with a white directional light. It looks a bit better if I change the light color to cyan, but in the ocean demo changing the light color does not seem to be necessary. Any hints on what I'm doing wrong?
    2. Underwater I don't see any caustics and other effects. I added the same scripts to the camera that I saw on the camera in the demo scene.
    Any hints on what I'm not setting up right? Or are there any step by step instructions for this or tutorial videos?
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    1. if you switch from a scene where underwater rendering is active to a new one and just pull in the prefab underwater renderung may still be active so instead of rendering correct front face lighting the water shader is stimm in underwater rendering mode. adding the lux underwater rendering script to the new scene should fix this. please have a look into the demos: each scene contains this script although only a few actually need it.

    2. you have to make sure that all needed components are in place like the volume script, a collider for the volume, a rigidbody and collider for the camera/player and the underwater rendering script.
    you find a step by step instruction in the documentation under watervolume [>]
     
    hoodoo likes this.
  47. hoodoo

    hoodoo

    Joined:
    Oct 19, 2012
    Posts:
    154
    Thanks @larsbertram1 -- I think I have the right scripts on the camera (see attached screenshot). In the screenshot this is what it looks like with a all white directional light. It only changes to a nicer green color if I make the light green. I haven't done what you said for question 2 yet though with water volume setup, so maybe that's why? I will read the watervolume part next and do what you suggest.
     
  48. hoodoo

    hoodoo

    Joined:
    Oct 19, 2012
    Posts:
    154
    upload_2020-1-5_13-27-58.png
    Screenshot
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i think i misses reflection. have you already updated gi or baked the overall reflection probe?
     
  50. hoodoo

    hoodoo

    Joined:
    Oct 19, 2012
    Posts:
    154
    I did bake the lighting, but it didn't seem to help. Also, I tried to set up the water place as described in the documentation for water volumes, but noticed that the Ocean_5X5 prefab does not do any of this, and it isn't set up that way in the ocean demo scene. Underwater effects still did not work, but I copied the camera, directional light and Ocean_5X5 as prefabs and that made the underwater work. However, the water color still looks fairly brown.