Search Unity

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

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

  1. Qilbby

    Qilbby

    Joined:
    Nov 7, 2017
    Posts:
    5
    Thank you very much for the example package, I had managed to get a good result a little before your answer, but I was still in doubt if I had configured it correctly because I understood that the trigger script would only be added in 1 gameobject, and that's what I I was wrong lol.
    With your example, I made a comparison and the problem was the same, only one water had the script. Now it's perfect, thank you very much.

    Had gotten a red error in console from InvalidCastException: Specified cast is not valid.
    StylizedWater2.UnderwaterRendererInspector.OnEnable() (at Assets/StylizedWater2/Editor/Underwater/UnderwaterRendererInspector.cs:55), but on restarting Unity the problem is gone for now.

    About Surface Modifiers (extension asset), any news about? I found it amazing.
     

    Attached Files:

  2. makaolachsiungca

    makaolachsiungca

    Joined:
    Sep 27, 2019
    Posts:
    31
    Hi,
    I got some error in edit mode when inspect under water example scene(after looking around for a few seconds).
    Unity 2022.1.10f1
    URP 13.1.8
    螢幕擷取畫面 2022-08-26 003924.png
    螢幕擷取畫面 2022-08-26 003952.png
     
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Can't say I've ever seen this before. Most of those texture names are native to URP. Safe to assume it's a bug in either versions (or the combination of). I expect it'll go away as easily as it came, after restarting the editor.
     
  4. bena-nogami

    bena-nogami

    Joined:
    Apr 26, 2021
    Posts:
    1
    Create an object that extracts the water flowing in the pipe,
    I want to add a flow texture to side.

    If there are waves on the surface of the water, river mode can't be used to side.
    Without river mode, Surface Foam textures appear to flow in both way.

    With waves on the surface of water, I want to flow the texture to one side like in river mode. (pseudo is fine)
    Is there a way to make this Surface Foam texture flow only one way?
    I tried customizing the script, but it didn't give me any results.
     

    Attached Files:

  5. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    That is indeed the case, when the River Mode checkbox is on, everything flows in a single direction. It's however not possible (more by design) to control this per feature.

    You can however modify the StylizedWater2/Shaders/Libraries/Features.hlsl file and make the surface foam pan in a single direction by adding this line:
    upload_2022-9-27_14-39-2.png

    For copy/paste: uvs.zw = (uv.xy * 0.5) + (time.xy * _FoamSpeed);
     
    bena-nogami likes this.
  6. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Yes! The geometry it creates is indeed properly set up for rivers. Though the tools flowmap painting functionality will not have any effect on this water shader.
     
    baumxyz likes this.
  8. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Cool, thank you!
     
  9. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    @StaggartCreations Hi, sorry, one more quick question. Is or will the asset be compatible with Enviro 3's fog? Or will the water be rendered in front of the fog?
     
  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Enviro 3? That's news to me :p

    I've just checked it out and the existing Enviro fog integration for the water will not work. Technically it's a different asset altogether so Enviro 3 will needs its own integration option.

    I'll have to investigate, but after a quick glance it looks like it should be possible to integrate it as well :)
     
    baumxyz likes this.
  11. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Oh cool, that sounds very good! Your shader is way ahead, also because of all the integrations. :)
     
  12. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Version 1.2.0 is now available. Changelog:

    Added:
    - Fog integration for Enviro 3*
    - Planar Reflection Renderer, option to move the rendering bounds with the Transform

    Fixed:
    - Refraction not affecting the skybox on sloped water surfaces
    - 'Assets/Create/Water mesh' action not directly creating the asset, unless the asset database was refreshed.
    - Planar Reflections, realtime changes to the Field of View or Orthographic camera properties not being applied.
    - Pre-emptive fixes for Unity 2022.2 beta

    * There's a minor bug in Enviro 3's fog shading in URP, the author has already been made aware of it. I assume a fix for this will land eventually. It doesn't however change anything about the fog integration for the water. The water will end up appearing a little less fogged than the rest of the environment for now.

    Underwater Rendering in Unity 2022.2+
    This is currently still not supported unfortunately. This has everything to do with a large amount of rendering API changes introduced by Unity, with the seemingly usual "go figure it out" mentality. Meanwhile the SC Post Effects asset is being reworked pretty much entirely because of this. Once that update is out and proves stable, the same framework for doing post processing (with VR support) can be ported over.
     
    Last edited: Nov 8, 2022
    makaolachsiungca and baumxyz like this.
  13. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    209
    Hey Staggart, would you be able to take a look at the fog integration for the newest COZY version?
    There's been some changes and seems that after turning the integration on, the default render queue for water (3000) doesn't work anymore and the water disappears from the top, only rendering the bottom part.

    From the bottom:


    The only way to get the water to render correctly seems to be to set the queue to 3002 manually on the water shaders (so same as the fog rendering on 3002), but not sure if that's going to have any bad repercussions in the long term.
     
  14. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    As I understood it, COZY's skybox renders on 3000, the clouds on 3001 and the fog on 3002. Water materials should be on 3001, so that they render on top of all of it, but before the fog :)
     
  15. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    209
    By default:
    The Sky renders at 2900.
    The Clouds at 2950.
    The Fog at 3002.

    With the water at 3001, it renders transparent as in the screenshots I sent above, with 3002 it renders properly but I get the feeling the fog gets ignored.
     
  16. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Curious, the render queue values are as I listed them by default (to clarify, COZY 2).

    I actually get 95% transparent water only if the COZY integration isn't active (does render correctly if I set the water to render at 3002).

    If the water material is on the same render queue as the fog sphere material it will only render behind it if the GameObject's pivot point is further away from the camera. So it should always be 1 step lower, to ensure this is always the case (regardless of position-based sorting).

    Should end looking something like this (water on render queue 3001):
    upload_2022-11-19_11-59-54.png
     
  17. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    209
    Had a small chat with Keller and you might be on an outdated version of COZY 2, or just on Cozy 1 shaders.
    The shader render queue's changed to what I listed above and the shaders got re-written a while ago :)

    I also checked and after enabling the integration, the water shaders remain unchanged with the RQ and stay at 3000, so seems the integration doesn't modify the water shaders anymore and the shaders remain at 3000. This is all in a clean project with just COZY 2, URP, 2021.3 LTS and SWS2 + the underwater rendering addon.

    Could that all be due to me using the underwater integration with SWS2?
    I now know the underwater fog effects aren't working when Cozy's Fog exists in the scene, so that's something new I noticed only today :D
     
  18. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Strange, I've downloaded a fresh install of COZY 2 v2.0.8b, and those are the render queue values on the materials. But no matter, sky and clouds render before the fog does either way :)

    Underwater rendering should be left out of the equation actually, this will unfortunately not work with the COZY or Atmospheric Height Fog asset. It would involve a fundamental redesign on either end.
     
  19. Guanomancer

    Guanomancer

    Joined:
    Feb 16, 2021
    Posts:
    6
    Hi, excellent asset. Looks so good.

    I have a question about the buoyancy demo scene and wave sampling. When I load up the demo scene and scale the ocean XZ to 75 by 75, the sampling gets really inaccurate and out of sync (often showing opposite wave height values compared to the rendered visuals / boat goes up as waves go down).
    I've tried writing a script that samples the waves at a point with XZ divided by the scale to counter this, but that doesn't seem to work either.

    What am I missing? :)
     
  20. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    That's quite normal and expected! When you scale up a mesh, the vertices becomes more spaced out as well. It's similar to scaling a texture way up, eventually you start to see the individual pixels. The water shader animates the vertices using an algorithm, so how much detail you see, ends up being correlated to the vertex density. Under the "Advanced" tab on the water material, you can enable Tessellation, that is a great way to keep a high vertex density near the camera, without the rest of the mesh needing to be very high poly.

    The buoyancy API uses the same algorithm, but it will be at near infinite accuracy, so there will always be some discretion between the position read from it, and how the water geometry is rendered.
     
  21. Guanomancer

    Guanomancer

    Joined:
    Feb 16, 2021
    Posts:
    6
    Thank you! I didn't think about vertex count.
    I tested with tessellation and everything worked as expected. I might test if a smaller high poly mesh near the camera, and multiple (4) low poly meshes in the distance gives ok performance and visuals, just so that I can disable tessellation, but either way I am very pleased with this asset.
     
  22. ryannotfound

    ryannotfound

    Joined:
    May 5, 2016
    Posts:
    6
    Absolutely love this asset, just wondering, does anyone have an example using it for a low-poly world for VR (Specifically oculus Quest 2). I'm struggling a little to achieve the best results, or knowing what is possible/not possible, such as intersection foam, or translucency, even what is considered the best one to use for the (mobile, low poly or cartoon). Any advice really appreciated.
     
  23. AticAtac

    AticAtac

    Joined:
    Feb 26, 2014
    Posts:
    25
    Hi, which assets/tools would you recommend to create meshes for the river mode? An yspline tool will do?
     
  24. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Glad to hear it! If you haven't seen this already, I'd recommend reading the Performance Guidelines section in the documentation. There are no hard limits, since every project is unique, but if the game runs faster with the water disabled, it'll be worthwhile to scale down some aspects.

    Basically yes! The requirements a tool must meet are outlined here, by mere exception will a spline mesh not meet them.
     
    ryannotfound likes this.
  25. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Underwater Rendering version 1.0.6 is now live! This update address some new API changes, and ensure it works across Unity 2020.3 -> 2023.1, and in VR for each version as well.

    Unity 2022.2/2023.1 are in beta/alpha, so it's possible these fixes may fall through once they are actually released.
     
    the_unity_saga likes this.
  26. Moona-Unity

    Moona-Unity

    Joined:
    Dec 12, 2019
    Posts:
    5
    Hello @StaggartCreations just having some issues here on the Underwater Rendering.. how do I resolve this? its like slicing the object underwater. my unity Version is 2022.1.23f1 and updated my stylized water 2 and Underwater rendering to the latest update.Thank you in advance
     

    Attached Files:

    • 7.gif
      7.gif
      File size:
      5.9 MB
      Views:
      112
  27. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Thanks for the GIF! I checked it out and this is indeed a bug, unfortunately something that was caused by last update but went completely unnoticed. Thanks for the headsup!

    I've uploaded a hotfix (v1.0.6b) to the asset store to address this, you can reel this in from the Package Manager.
     
  28. Moona-Unity

    Moona-Unity

    Joined:
    Dec 12, 2019
    Posts:
    5
    Thanks it Fixed it
     
  29. Wurstautomat

    Wurstautomat

    Joined:
    Feb 19, 2019
    Posts:
    3
    I have a question to river mode: I made a River with RAM River Auto Material but the direction of the river is wrong (90 degrees to the side of the river). I can change the Y direction of the river but the X direction (wich I need) doesnt change anything. Maybe I'm blind and I miss something :)

    However thanks for this great Asset!
     
  30. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    On the RAM component there should be a "Rotate UV" checkbox, which rotates the direction by 90 degrees ;)

    upload_2022-12-6_11-30-8.png
     
  31. Wurstautomat

    Wurstautomat

    Joined:
    Feb 19, 2019
    Posts:
    3
    omg I'm blind. Thank you so much! :)
     
  32. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Hey, this asset doesn't seem to support the forward+ rendering path.
    Everything starts to flicker when using forward+.
    upload_2022-12-15_19-31-10.png
    upload_2022-12-15_19-31-24.png
    upload_2022-12-15_19-31-41.png
     
  33. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    That's correct, this was introduced in 2022.2, and the shader hasn't been fully updated yet to support all the new features. Support for Forward+ is already part of next update, which I intend to publish before Christmas.
     
    Ruchir likes this.
  34. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Version 1.3.0 will be available in a moment. Due to the nature of the changes the Underwater Rendering extension has also been updated to 1.0.7

    Both assets must be updated, as using an older version of one or the other will not work error free!

    They are coincidentally now 50% off during the New Year Sale. Last chance to get Stylized Water 2 for at this price point (including the 1.3.0 update!).

    In February the price will be set at $35,-


    Stylized Water 2 changelog
    Underwater Rendering extension changelog:
    Unity 2022.2 support is now complete, and the Forward+ rendering path is now compatible. This makes the use of a great number of point lights possible:



    Happy holidays and happy creating! :)
     
    Ruchir and the_unity_saga like this.
  35. AustinMclEctro

    AustinMclEctro

    Joined:
    May 3, 2017
    Posts:
    16
    Hello @StaggartCreations. Fantastic water asset!

    I see above that you have acknowledged the Enviro 3 fog compatibility issue. Below is what it looks like.


    I'd also like to point out one other incompatibility with Enviro 3, in particular the Underwater Renderer Directional Caustics functionality. Directional Caustics move with the camera instead of being fixed to the ground when using Enviro 3, vs. a standard directional light.

    1. Working (with standard directional light):


    2. Broken (with Enviro 3):
    Note that caustics work correctly with Directional Caustics disabled when using Enviro 3.

    Hoping work can be done with Enviro's developer(s) for a compatibility fix!
     
  36. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Ha, good catch! This behaviour is technically correct, since the caustics will project from the sun light's point of view, much like a light cookie does. It's moving, because Enviro is moving the light with the camera, whilst only the direction of the light is important.

    You can correct this by forcing the sun transform to stay centered by adding this to the EnviroLightingModule class at line 252:
    Code (CSharp):
    1. //Set light to sun              
    2. EnviroManager.instance.Objects.directionalLight.transform.position = Vector3.zero;
    You can also simply unparent the "Sun/Moon Directional Light" object to the same effect.
     
    AustinMclEctro likes this.
  37. AustinMclEctro

    AustinMclEctro

    Joined:
    May 3, 2017
    Posts:
    16
    Nice, I just tried both and confirmed that both of these are successful workarounds (with no unintended side-effects as far as I can see). Thank you!
     
  38. Guanomancer

    Guanomancer

    Joined:
    Feb 16, 2021
    Posts:
    6
    I'm trying to build but I keep getting this error:
    Shader error in 'Universal Render Pipeline/FX/Stylized Water 2': Couldn't open include file 'Underwater/UnderwaterFog.hlsl'. at line 286

    When I check that line and the next, it references two files that are not present, in a folder which is also missing.
     
  39. analogupstudios

    analogupstudios

    Joined:
    Jul 3, 2019
    Posts:
    14
    Having issues with underwater rendering in URP 1.3.0 receiving this error:

    Shader error in 'Universal Render Pipeline/FX/Stylized Water 2': 'ShadeUnderwaterSurface': no matching 14 parameter function at Assets/StylizedWater2/Shaders/Libraries/ForwardPass.hlsl(747) (on d3d11)

    Any Ideas?
     
  40. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Hello there just installed your asset to use with Cozy, but it does look very strange, when there is fog, the water gets somewhat transparent and the underwater effect renders behind the sky. Is that intended behavior? Also I did the renquer queue thing to 3001, but it looks the same as 3000
    Thanks!
     
  41. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Question- Is DWP2 able to make river physics work?

    I love the asset so much by the way, thank you for making it available!
     
    Last edited: Dec 31, 2022
  42. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    As of 2022.1 Unity changed the behaviour of their shader compiler, which causes this false-positive error to be thrown. That part of the shader code is not supposed to be activated normally, and it'll be stripped during the build processes. So ultimately it's harmless, and doesn't actually mean anything is actually wrong. I have yet to find a way around this inconvenience!

    Make sure both assets are updated to the latest version. Version 1.0.7 of the Underwater Rendering extension should be paired with 1.3.0+ of the water shader. On the Underwater Renderer component there will be an error message in case of a version mismatch.

    The Underwater Rendering extension and COZY are unfortunately not compatible with eachother, so be sure to remove that from the equation first.

    I believe DWP2 only works with a flat water level!
     
    homemacai and ml785 like this.
  43. Kreshi

    Kreshi

    Joined:
    Jan 12, 2015
    Posts:
    446
    I know a workaround to integrate the underwater effects with cozy 2.
    Open the Stylized Fog shader and scroll down to line ~400.

    Add these lines of code above the fragment function (half4 frag ( VertexOutput IN ) : SV_Target):
    Code (CSharp):
    1.             sampler2D _UnderwaterMask;
    2.             bool _FullySubmerged;


    Now inside the fragment function, add these lines of code just before the last line (return half4( Color, Alpha ); ):

    Code (CSharp):
    1.                 //Stylized Water 2 underwater support for Cozy Weather 2
    2.                 float4 underwaterMask = tex2D(_UnderwaterMask, ase_grabScreenPosNorm.xy);
    3.                 if(underwaterMask.r > 0.99f) return half4( Color, 0);
    4.                 if(_FullySubmerged) return half4(Color, 0);
    Hope this helps :).

    Expected result:
    underwaterwithcozy.png
     
    ml785 likes this.
  44. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    That is indeed a perfectly valid way to go about it! Thanks for sharing!

    I'd recommend moved the line with "_FullySubmerged" right below the comment, for better performance when the camera is above the water.
     
    homemacai, ml785 and Kreshi like this.
  45. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Hi, is there a way to make fully Underwater view appear brighter (or darker)? Fiddled with a few Material settings and managed to change brightness for Surface of water, but not underneath. Thanks! (Maybe the function I'm looking for is "clearer" -adjusting how easy or hard it is to see underwater)
     
    Last edited: Jan 2, 2023
  46. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Certainly, the "Fog Brightness" parameter will do that. It acts as a multiplier for the fog color (which is derived from the water's deep/shallow colors). So setting it to 0 will result in completely black fog:
    upload_2023-1-3_11-45-27.png

    When you're talking about "clear" you may want to adjust the fog density settings, particularly the two under "Distance from camera".

    You could actually give the Start Distance parameter a negative value, so that it's never 100% clear right in front of the camera.
     
    ml785 likes this.
  47. Leonidas85

    Leonidas85

    Joined:
    Mar 11, 2015
    Posts:
    14
    Hi StaggartCreations,
    I've been much enjoying your excellent water shader, however I think I've found a bug.
    I'm using the toon shader with waves enabled and at certain angles the waves do not seem to render correctly, see screenshots.
    Screenshot 2023-01-06 202730.jpg Screenshot 2023-01-06 202736.jpg Screenshot 2023-01-06 202746.jpg Screenshot 2023-01-06 202800.jpg Screenshot 2023-01-06 202837.jpg
    I'm using Cozy Stylized Weather 2 (not sure if related), installed the fog integration from the hub window and have tried the render queue settings at 3000 / 3001 / 3002 and tried playing with many of the settings, but to no avail.
    Can you help?

    Also, a question: Is there a way to make the toon shader look a bit less repetitive over longer distances? I am using it to simulate and ocean and the tiled white pattern is very noticeable.
     
  48. lusho_games

    lusho_games

    Joined:
    Jun 4, 2011
    Posts:
    63
    Hello, I'm running a Windows build with Unity 2022.2.1f1, water package to the latest 1.30. I'm seeing different results in editor(left) and in build(right):
    upload_2023-1-7_2-3-28.png

    Also getting this error that you mentioned being harmless:
    Shader error in 'Universal Render Pipeline/FX/Stylized Water 2': Couldn't open include file 'Underwater/UnderwaterFog.hlsl'. at line 286


    Edit: If I disable lighting then it looks the same in both editor and build, of course I loose lighting properties and shadows.

    Any clues? thanks.
     
    Last edited: Jan 7, 2023
  49. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    In this case, where triangles are overlapping, you can enable Depth Writing to ensure triangles sort based on distance. You can find this option under the Advanced tab:
    upload_2023-1-7_11-42-9.png

    There's no distance resampling for foam, I'd recommend to use the wave mask parameter to break up the pattern and have waves fade out towards the far distance, making the foam fade out as well.

    Thanks for the screenshots! I'm unfortunately not able to reproduce the same issue, no matter which combination of rendering settings I try. Anything in particular that's divergent in your project from a fresh URP project?
     
  50. Leonidas85

    Leonidas85

    Joined:
    Mar 11, 2015
    Posts:
    14
    Thanks @StaggartCreations, the depth write flag fixed the problem.

    As for the repetitive foam pattern fix; the wave mask parameter helps a little, but not much.
    Unfortunately I can't fade out the waves over distance as that would have gameplay implications, with other ships in the distance not being affected by waves.
    I guess I will need to look into some custom alternatives for the repeating pattern at a later point.

    Thanks for the help!
     
    Last edited: Jan 8, 2023