Search Unity

Stylized Water 2 [URP] ☑️ Desktop/Mobile/Consoles/VR

Discussion in 'Assets and Asset Store' started by StaggartCreations, Nov 3, 2020.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    No problem! It's developed by NWH Coding so I can't say :p
     
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Version 1.1.3 is now available! Particularly the vertical depth is something I needed to churn out with regards to underwater rendering. The extension is now up to snug and will be available next Monday at a 50% launch discount for 7 days ($10).

    Added:
    - Vertical depth parameter, controls the density of the water based on viewing angle
    - Realistic water material (ocean-esque)

    Changed:
    - Water meshes created through the utility or Water Grid component now have some height. Avoids premature culling when using high waves.
    - Water Mesh utility can now automatically apply changes when parameters are modified.
    - Setup actions under the Window menu now support Undo/redo actions
    - Improved blending of normal maps for the Advanced shading mode
    - Wave normals now distort caustics, creating a more believable effect
    - Translucency shading now takes the surface curvature into account (controllable through new parameter)
    - UI: translucency moved to the Lighting/Shading tab

    Fixed:
    - Water depth not rendering correctly when using an orthographic camera and OpenGL
    - WaterMesh.Create function not taking the chosen shape into account, always creating a rectangle
    - Integration for Dynamic Water Physics 2 no longer working since v2.4.2 (now the minimum required version)
    - Refraction and reflection distortion appearing much stronger for orthographic camera's
     
    Acissathar and Lars-Steenhoff like this.
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    The Underwater Rendering extension asset is now available! Until next Monday, there's a 50% release discount.



    The online documentation is available here: http://staggart.xyz/unity/stylized-water-2/sw2-underwater-rendering-docs/. It should at least be consulted for the initial set up.

    This is the initial version, so hopefully there aren't any unforeseen issues. But if there are, please let me know!

    A review would be immensely appreciated, especially since it's a new asset!

    Some future work:
    • Directional caustics support for versions older than 2020.2
    • Refraction masking for objects between the camera and water, when viewed from below
     
    Last edited: Aug 9, 2021
    Bwacky and ikemen_blueD like this.
  4. MakINz

    MakINz

    Joined:
    Aug 16, 2020
    Posts:
    1
    The underwater render is awesome!
     

    Attached Files:

    StaggartCreations likes this.
  5. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    31

    The underwater renderer is insane, I absolutely love it!

    Now that you marked it off the to-do list, any chance for water interactions like players running through waves leaving a trail behind? I handle it via spawning VFX in the middle of player bodies right now but it just isn't... good, compared to anything you'd be able to print out :rolleyes::rolleyes::rolleyes::rolleyes::rolleyes::rolleyes::rolleyes:
     
  6. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    31
    Additionally got a question -
    Right now I use it as globally with height set to a certain level. Obviously that cuts it off of being used for smaller areas like ponds/rivers, which is to be expected.

    Is there no way to set up a box collider and trigger the post processing effect of the shader inside of it?
    If that's a no-go, maybe some way to translate the post processing, or at least the color scheme, to a post process volume and trigger it once the camera enters?
     
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Happy to hear it!

    Interactive water is definitely on my personal wishlist, coincidentally working on it right now. I've made a prototype some time ago which makes up the starting point for further work


    The end goal would be an effect similar to what you'd see in RDR2, Fortnite or Assassin's Creed. This sounds like a tall order, it seems achievable as long as time and motivation permits it :p The roadmap page has some more details https://staggart.xyz/unity/stylized-water-2/sws-2-docs/?section=roadmap

    Multiple water bodies with varying water levels/materials is not something that's taken into account.

    What you can do is to attach a script to a Box Collider trigger that sets the Transform of that object to
    StylizedWater2.UnderwaterRenderer.Instance.waterLevelTransform once something specific enters it. That'll make the Transform the current water level. Similarly the waterMaterial field could be changed if it uses a different material. But UnderwaterRenderer.Instance.UpdateMaterialParameters() would also need to be called in this case.

    I'll look into adding some front end functions to make this more straightforward. Or just add a component that can be added to a trigger to handle this.
     
    Acissathar and Bwacky like this.
  8. Rademanc123

    Rademanc123

    Joined:
    Aug 1, 2018
    Posts:
    2
    Hi there. I just bought this asset and it looks amazing. Unfortunately I am having issues with the light shafts not rendering. Any ideas? Unity 2021.1.16f1
    upload_2021-8-11_9-6-20.png
     
  9. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    In the StylizedWater2\Prefabs\Effects\Underwater folder you'll find a Lightshafts prefab, which you can modify to fit the scene, likely just the Shape size, Start Rotation and Start Color alpha channel. It's not to be confused with true volumetric light shafts (eg. as seen in Subnautica), which the asset doesn't feature.

    Just noticed the prefab has a -90 degree rotation by default, which isn't correct. I'll be sure to correct this!
     
  10. MuntyMcFly

    MuntyMcFly

    Joined:
    Sep 29, 2016
    Posts:
    27
    Does this work with webgl builds?
     
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    WebGL 2.0 yes, 1.0 uses an older graphics API which isn't supported
     
    MuntyMcFly likes this.
  12. armleghead

    armleghead

    Joined:
    Feb 2, 2015
    Posts:
    2
    Hello, using wavemaker on the underwater renderer seems to disconnect the surface from the waterline render. Is this possible to fix? Or is it a limitation of the water line and stylized water while using the wavemaker plugin together with it? Either way, thank you for the great assets!

     
  13. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    i f u could help me fix my refraction setup ill buy your underwater extension.
     
  14. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    31
    Not just wave-maker, it happens with just underwater rendering by itself if you make the waves go whoop. The rendering seems to be a fully straight horizontal line cutting at a point through the screen. All I was able to do to mitigate the issue was making waves "smaller" so its less noticable.
     
    armleghead likes this.
  15. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Granted, a bit of an unforeseen combination. Wavemaker modifies the vertices of the water mesh through scripting. Because it's not GPU/shader based, there isn't any way to incorporate it into the water line. So the difference in wave height Wavemaker adds is going to create cracks.

    Setting up URP rendering goes beyond the kind of support I provide for this asset I'm afraid. You can follow this guide: https://github.com/Unity-Technologies/UniversalRenderingExamples/wiki/FPS-Demo

    It may be that your water mesh has a low vertex density, causing the waterline to appear more detailed than the water itself, this can result in visible cracks. Upping the vertex density of the mesh, or enabling tessellation will mitigate this.
     
    armleghead likes this.
  16. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    ok i understand.no problem
    ive tried about every setup allready, nothing works, so no caustics for my game.

    im having weird reflections behavior though
    heres' a short vid
     
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    It seems objects are prematurely culled from the reflection. On the Planar Reflection Renderer component there may this message if something is wrong


    Otherwise, static batching may be the cause. This combines meshes, meaning their pivot point may end up being much further away than the actual object. Upping the Render Range can mitigate this.
     
  18. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    no water objects are fine. im just using a unity plane thats not static.
    tried setting render range to max, didnt help with the culling. same result
     
  19. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    I see! There's possibly a render feature interfering. If you were to disable each one as a test, and it renders correctly then, you can set up a "clean" renderer specifically for the reflection as outlined here.
     
  20. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    31
    Thanks!
    Can you give some advice regarding optimizing it in a big open world map?
    Should I go for more rows/columns if I want to otpimize the water more or the contrary?

    My water is scaled up to 8096 to cover the map size, max vertex distance and I have it cut into 4 Rows Colums.
    I used Crest in the past and it created a massive grid with dozens upon dozens of tiles automatically, but if I increase the amount when using SW2 it gets really laggy. I assume Crest was billboarding the water tiles in the distance to have it run a bit smoother?

    Generally not sure how to handle it in an open world. Any advice would be welcome :)
     
  21. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Ideally, what you'd want to avoid is rendering micro-triangles (smaller than 2x2 pixels on screen). Which unfortunately is pretty unavoidable when using a grid-like mesh. This tends to hammer the GPU and increases the shading cost.
    upload_2021-8-17_16-9-33.png

    Increasing the vertex distance on the Water Grid component can mitigate this, while enabling Tessellation so the vertex density is still high enough where it matters: near the camera
    upload_2021-8-17_16-11-34.png

    There are some techniques for generating a view-dependent mesh, but that's way over my head for now and becomes quite a project on its own. I believe Uncharted 4 used something similar.

    Perhaps the best option (yet not the most flexible) is to create a manually authored mesh, with a relatively high vertex density in important areas but using a few large triangles for off in the distance.
     
  22. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    ive tried setting every render feature on or off and the water relection still culls to early.
    im not shure what do
     
  23. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    My guess is that occlusion culling may be kicking up some dirt, though this doesn't appear to cause any issues when I test this. There's likely something specific interfering, but find out what this is unfortunately comes down to a process of elimination. A way to check if it's project-specific is to test in the demo scene. If so, a minimal repo-project would be most helpful for me to dig around.
     
  24. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Underwater Rendering version 1.0.1 is now up!

    Added:
    - Static SetCurrentWaterLevel and SetCurrentMaterial functions to the UnderwaterRenderer class.
    * This can be used to switch to other water bodies via triggers or other game logic
    - UnderwaterRenderer.EnableRendering static boolean. Can be toggled to disable rendering in specific cases.
    - Directional Caustics support for versions older than Unity 2020.2
    - Option to enable high accuracy directional caustics (using either the Depth Normals prepass, or reconstructing it from the depth texture)

    Fixed:
    - Underwater surface not matching up perfectly if ambient skybox lighting is used with an intensity higher than x1
    - Corrected default settings for particle system prefabs
    - Enabling volume settings blending, requiring to toggle the component for it to take effect.
    - Rendering also taking effect when editing a prefab

    Changed:
    - Render feature can longer be auto-added when in playmode

    Documentation now has a new section regarding scripting: https://staggart.xyz/unity/stylized-water-2/sw2-underwater-rendering-docs/?section=scripting-4
     
  25. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    did some tests in a clean scene.
    turns out its fog in the lighting settings thats causing the culling.
    no fog> no culling, reflections render fine
    fog on > weird culling on reflections.

    can u fix this? as i need fog in my scenes
     
  26. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Ah, that makes sense! The built-in fog doesn't work with reflected projections due to its design, which planar reflections always hinge on.

    Since it's applied on a per-vertex basis, large low poly objects tend to get flooded with fog. Worst case scenario is with a simple large quad: upload_2021-8-21_10-48-41.png

    I can simply disable fog temporarily right before rendering the reflection. Fog already gets applied to the water directly, so this tends to look the same anyway.
     
    Mister-D likes this.
  27. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Version 1.1.4 is now available:

    Added:
    - WaterObject.Find function. Attempts to find the WaterObject above or below the given position.
    * Floating Transform component now has an "Auto-find" option
    - Buoyancy.Raycast function. Given a position and direction, finds the intersection point with the water
    - Planar Reflections, maximum LOD quality setting. Can be used to limit reflected objects to LOD1 or LOD2
    - Caustics distortion parameter. Offsets the caustics based on the normal map.

    Changed:
    - Planar Reflections, standard fog no longer renders into to the reflection. This can cause artifacts where it "bleeds" over partially culled geometry

    Fixed:
    - Azure fog library file not being found (GUID was changed)

    Scripting section was added to the documentation.

    Underwater rendering v1.0.2:

    Fixed:
    - Rendering not taking any effect in URP 7.5.2 and 7.5.3
    - Waterline/meniscus rendering behind the camera on OpenGL in Unity 2020.2+
     
  28. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    tnx for the update
    reflections work fine now
     
    StaggartCreations likes this.
  29. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    162
    Hi!

    Is there any way I can rotate the water prefab up without stretching out the material? My scene has a Tilemap and is mostly 2D but I'd love to place this water behind it. However, when I rotate the water up, it stretches out.

    upload_2021-8-25_22-10-21.png

    upload_2021-8-25_22-10-31.png

    Also, for some reason the water prefab is showing in front of my tileset in the scene, but fine in the Game. the z axis places it behind the tilemap, so I'm not sure why it's showing up like that. How could I show it properly behind the tilemap in scene view?

    Please see the image in next post.
     
  30. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    162
    upload_2021-8-25_22-13-50.png

    Sorry, one more thing, how come I cannot change the Material of the Water Object?
     
  31. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    im having wrong reflection behaviour on my trees when using a custom reflection map

    trees use CTI shaders. so i dont know if its the water or the tree shader
    screen.jpg
     
  32. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    162
    I played around more with the settings and got something quite pretty.

    But I still have an issue with the z-axis sorting. Even though the z-axis places it behind my Tilemap, depending on where the camera is, the water still appears over the Tilemap. How could I fix this?

    See here...

    upload_2021-8-25_22-50-56.png

    All good... But then I scroll to the right...

    upload_2021-8-25_22-51-7.png

    Some more...

    upload_2021-8-25_22-51-15.png

    Aaand my tilemap is gone. :/ Please help.
     
  33. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    What you're seeing is transparency sorting at work, I'd recommend checking the first section on the troubleshooting page here.

    For the stretching, you can set the UV Source to "Mesh UV" under the General tab in the material. By default it's configured to project the UV's horizontally on the XZ axis (for position and scale independent tiling), but this will cause stretching on vertical surfaces.

    You can change the material on the Mesh Renderer as you would normally. I now see this can be confusing, the Water Object component fetches the material/mesh from the object it's on, so its a one-way street. But I can effectively just hide them, since they can't be changed directly anyway.

    Not sure why this would appear this way, seems to be specific to the trunk material since the branches come out a different color.
     
    roseportalgames likes this.
  34. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    the creator of "CustomTreeImporter" says the bark uses the standard lighting method for urp and says its probably the reflection script of the water shader
    he wonders why the normal camera, renders fine, and the reflection camera fails to render properly
     
    Last edited: Aug 26, 2021
  35. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    162
    Thank you very much for taking the time to write this detailed response! It helped a lot.
     
  36. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    just bought the extension
    the fog underwater isnt the same as waterline or watercolor , i find no way to change this(screenshot)
    is there a way to disable the underwater caustics?
    underwater rendering doesnt render correct to waterline(culling) screenshot left

    screen1.jpg
     
  37. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    162
    @StaggartCreations

    I have a question regarding lag.

    The game with my Stylized Water Map runs amazing on my Huawei P30, but on my Huawei Y6 2019 with lower CPU speed, my scene with the water goes quite slow and laggy.

    I did use the Mobile prefab and edited that but I did add in and change some effects. I never checked the lag before so I'm not sure if my changes made it more performance heavy or if also the Mobile prefab is just too performance heavy for the Huawei Y6.

    It's hard for me to test because I don't own that phone or any old Android phone, I'm asking friends to download and test and I can't keep doing that with every change.

    So I'd love to ask: what are the features that I need to cut down the most to make it really light on performance?

    From what I could tell, it was really like 10x slower than on my phone, so I think I need to remove a lot of stuff. Please give me advice or list out the stuff I should remove to make it really really light on performance. I would appreciate it greatly.
     
  38. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    I'm not sure what I'm looking at here to be honest! With such a small pond, you'd likely need to increase the fog density dramatically to see it taking effect.

    The fog color is based on the color of the water material itself, as are the caustics. You can adjust the brightness of the fog on the Underwater Rendering component. At this point there is no modifier for the caustics brightness, but this is slated to be added next update.

    If you have seen this already, this page is worthwhile checking https://staggart.xyz/unity/stylized-water-2/sws-2-docs/?section=performance-guidelines-3

    There is unfortunately no silver bullet seeing there are so many mobile devices out there, with varying GPU vendors and drivers. Disabling Normals on the material tends to have a positive effect on performance. But generally how much screen-space the water takes up is also an important factor.
     
  39. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    heres a video

    as u can see the vegetation reflections are not working correctly.
    the caustics are some kind of weird chromatic aberation colors and they also make the vegetation strange when underwater.

    the waterline is indeed the color of the water but there is a clearly visible gap(it does seem to refract though) between the waterline and the underwater rendering.
     
  40. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Thanks for the video! Gamma color-space isn't supported, I'm assuming that's what you're using. Hence the caustics appear darker and the fog color doesn't match 100%. This is largely attributed to combining Tonemapping and HDR, which are intended to be used with Linear color space. I can correct for the caustics color though, I'll make a note of this.

    Regarding the reflections, I encountered this in an asset pack by TriForge, which uses shaders built on the Amplify Shader Editor template. It's not the case for any built-in URP shaders (right)
    upload_2021-8-31_16-10-12.png

    The output alpha value has to be set to 1 to fix this. Why this happens specifically for objects rendered with a reflected projection, I don't know, that requires a deeper dive into URP's rendering. If CTI's shaders are also built using ASE, it will succumb to the same issue.
     
  41. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    setting to linear does fix the fog color. but there still is a visible gap. maybe because im using it in a small pond, i dont know. fog should be applied directly under the water horizon line no?
    ill talk to the creator of CTI , he writes the shaders himself not made with ASE.
     

    Attached Files:

  42. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    CTI creator confirmed the shader issue and fixed it. reflections are working perfect now. tnx
     
  43. gamextar

    gamextar

    Joined:
    Jul 4, 2021
    Posts:
    7
    Any chance of supporting VR? Have you tested it on Oculus Quest headset? I don't see what the problem might be as its URP? Thanks.
     
  44. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    If you already have VR working, then the water will also render correctly. Best to check the compatibility page for complete details.
     
  45. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    some requests
    fix the caustics color / maybe add option to disable them
    fix the water horizon fog line gap
    add option to do underwater rendering based on waterplane transform Y pos. i know its allready there but i have multiple water zones at different height levels. so maybe detect the waterobject and base underwater rendering on the current waterobject.
     
  46. gamextar

    gamextar

    Joined:
    Jul 4, 2021
    Posts:
    7
    Sorry I mean if the underwater extension would work on oculus quest 2, the stylized water assets works great on VR.
     
  47. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    im getting this error sometimes
    screen.jpg
     
  48. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    31
    Hey, got a question as I can't really get rid of these:

    You can see the outline on objects (using standard lit shader) and the terrain. I am not sure how to make them disappear other than using massive amounts of fog, any ideas how to cover that up?
     
  49. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Changing the water level can already be achieved through the API: https://staggart.xyz/unity/stylized-water-2/sw2-underwater-rendering-docs/?section=scripting-4

    This is likely caused by having MSAA enabled, which doesn't perform anti-aliasing for the depth texture Unity renders, causing this 1px wide artifacts

    ------

    PS: I'll be away until early next month for a long overdue vacation, so won't be able to reply to any messages. I'll be hiking in the pacific north-west and will finally have access to rural creeks and rivers to try out some audio recordings for gameplay/ambient SFX.
     
  50. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,685
    tnx!
    what about the fog line gap?
     
unityunity