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

Hi! seems that the integration with Atmospheric Height Fog is currently broken, as when I imported AHF (latest available version) and set the integration to AHF, the water turns pink and throwing an error message: Shader error in ‘Stylized Water 2/Standard’: redefinition of ‘AHF_Enabled’ at Assets/StylizedWater2/Shaders/Libraries/Fog.hlsl(18) (on d3d11)

Any help will be greatly appreciated.

That’s certainly possible. The integration required incorporating “AHF_Enabled”, the error suggests this is now already done elsewhere in the AHF asset and thus must be removed from the SW2 shader library. I’ve submitted an update with a quick fix (v1.6.1), which should be available soon.

Version 1.6.1 was submitted!

Fixed:

  • DWP2 integration, water level being fixed to a value of 0 in some cases.
  • Atmospheric Height Fog integration, shader error when using latest version (v3.2.0+)

When I add the StylizedWater2_River material to my water plane nothing shows up. Everything appears to be transparent. The river demo scene everything works fine so I know that the issue is on my end but I am having a difficult time figuring it out. Any ideas on what I can check?

** EDIT ** I unchecked the vertex color depth (G) under the Color section and finally the shader appeared to be working somewhat. I think I just need to massage the UVs and play with other settings now

Hi! Thanks for the quick fix, seems that the shader can compile without errors now, but it does seem that it doesn’t work as intended.

With Unity Fog integration (and unity fog on, AHF off) - this looks correct where the water is opaque:

With AHF on + Stylized Water integration on, unity fog off:

With AHF on, stylized water integration set to none, unity fog off:

Here’s a comparison between unity fog and AHF, as you can see, the water doesn’t look as intended and became see through completely with AHF on, which looks the same if I turn off the AHF integration. Any idea?

That is indeed what causes this typically. A mesh, especially one imported, may be filled with a White vertex color. This fills the opacity channel, making the mesh appear completely transparent.

What may be necessary is to adjust the render queue of the water material (+1 or +2). AHF’s fog sphere is probably on 3000, which other transparent materials are as well (including water). You’d effectively want the water to render on top of the fog at all times.

For Underwater Rendering, is there a way to make the waterline follow Mesh Deformations rather than shader waves? I’m experimenting with creating waves by deforming the mesh (CPU deformations) rather than using the Waves shader feature, and was just curious if there was actually some way to make the waterline line up with the mesh deformations on the water plane instead. If that makes sense.

I’m afraid not. The water line geometry is entirely GPU based, both the positioning and displacement of the vertices is done through a vertex shader. On the CPU side it is merely a static mesh.

1 Like

Hi, as soon as you install the Underwater Renderer I have steps in the colors. Is there a way to smooth this out? It looks a bit like artifacts.

Color banding can be a normal result of low-precision rendering. Enabling HDR in URP, and/or Dithering on the Camera can be used to resolve or elevate these sort of artefacts.

Hi, just got this resource and in the most basic test there is a super strange visual artifact where it intersects my terrain. I tried searching his thread and I noticed some other people complaining of artifacts in a top-down view while moving the camera around (it happens when I raise or lower the camera too). Is this something that you can help me with? See attached video.liiW9KLxDPYKV7uc0n

It appears that the depth texture that is being bound (and thus also read by shaders, including the water) is one frame behind. This is either has to be caused by a third-party rendering effect mucking it up, or a bug in URP. Why and how I can’t be certain of I’m afraid.

Hello, is there any suggested way to handle transition between materials and wave params so that I can switch to a stormy waves from a calm ocean?

I believe it should be possible to blend between two materials completely through Material.Lerp in a script. But you can always modify a material parameter at runtime through Material.SetFloat("_ParamName", value). You can find the name of all the parameters by selecting the shader file, or opening it in your IDE. They all start with an underscore (_).

Hey,

love the style of the water and also the underwater effect and the overall easy setup.
My goal is to make some kind of underwater submarine game (first person view) where there is a submarine with a window. I want to be able to look outside that window from inside and the other way around. Is that possible with this water / underwater system? I tried with the “WaterTransparencyMask” material but it doesn´t seem to fulfill my needs.It doesn´t cutout the underwater effect inside the submarine and also it doesn´t work when i´m inside the cutout object / submarine. Any tips how to achieve that effect i´m looking for?

Regards
Philipp

9630446--1368158--upload_2024-2-7_23-12-9.png

This is a particular use case that’s not technically possible I’m afraid (also noted on the store page).

Thank you for your swift reply. Unfortunately, Material.Lerp did mess up both of the materials paramaters. I will try modifying the parameters in runtime.

Apart from that, I am using Netcode for Gameobjects as my networking solution. I am trying to sync the waves using the following method:

private void Update()
{
    WaterObject.CustomTime = NetworkManager.Singleton.LocalTime.TimeAsFloat;
}

This works above the water but underwater acts weird. Caustics and distortion goes crazy fast like as it is fast forwarded. Am I doing something wrong?

I suppose I could have figured that wouldn’t work entirely as expected. Some parameters such as speed/tiling don’t lend themselves to realtime adjustments, so lerping would induce some unwanted side effects. It’s probably best to lerp specific parameters, namely the wave height (and normal strength to match).

What you’re encountering with the CustomTime API is definitly a bug, I can see the same thing happening. I had previously tested this using a fixed value, animated by hand, if I plug in Time.time I can see how this went belly up.

Apparently the configurable animation speed for the distortion and caustics isn’t factored in when a custom time is used, that’s a straightforward fix. I’ll be sure to submit a hotfix early next week!

That was quite fast! Thank you for the clarification, I will be looking forward to it.

I’ve submitted the update (v1.2.2) that includes the necessary corrections. Using a custom animation time, such as for networked applications will now work as expected. Thanks for bringing this to my attention, I would have likely not noticed for a long time otherwise.