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

Ahhh nice, that’s cool. Thank you

Submitted v1.0.5. Changelog

Added:

  • Particle effects, composed out of flipbooks with normal maps:
  • Big splash
  • Stationary ripples
  • Trail
  • Collision effect (eg. boat bows)
  • Splash ring (eg. footsteps)
  • Waterfall mist
  • Splash upwards
  • Water Grid component, can create a grid of water objects and follow a specific transform.

Fixed:

  • Material turning black if normal map was enabled, yet no normal map was assigned.
  • Intersection texture was using mesh UV, even when UV source was set to “World XZ Projected”.

Changed:

  • Waves no longer displace along the mesh’s normal when “World XZ projected” UV is used, which was incorrect behaviour
  • Sparkles are no longer based on sun direction, this way they stay a consistent size in dynamically lit scenes. Instead they fade out when the sun approaches the horizon.
  • When using Flat Shading, refraction and caustics still use the normal map, instead of the flat face normals.
  • Planar Reflections render scale now takes render scale configured in URP settings into account
  • Improved Rough Waves and Sea Foam textures
4 Likes

Hi, I was playing with the last update.

I have to say that distortion and caustic look much nicer in low poly mode now.

Also sparkles are better and more useful in that mode.
If I had to add something to the sparkles, probably it would be some kind of randomness (or noise) to the effect,
so there is no hint of a “repeating tile” look over large areas (when looking at the sea from afar for example).

Something else that I noticed recently, is that when using refraction with any other shader option, always there seems to be a border of the real object (of white color in my case), that is visible underwater alongside the refraction distorted image.
Also, when using intersection foam, the effect doesn’t seem to follow the refraction, but the real shape of the object under the water.
Don’t know if this is expected.

Regards.

I just upgraded to version 1.0.5, I am very satisfied with the result. Do you have any predictions about when you will work in the under water environment?

Glad to hear hear the changes are working out for you!

The sparkles are based off the normal map, so at some point tiling becomes noticeable. I have a tiling reduction feature for the normal map in my backlog (SW1 had this) so that’ll likely circumvent this.

As for the refraction, this is unfortunately a side effect. The depth color is not being refracted, I had dabbled with this before, but it brought forth different discrepancies in the shading, so picked the lesser of two evils so to speak. Still a point for improvement I may revisit later.

I’ve actually been putting more work into this the past few days. The underwater shading is pretty straightforward, but determining what’s above and under water is a challenge I’m still picking away at. What I’m going for is support for partially submerged camera’s much like you’ll see in AAA games. In many games the camera only snaps to either fully above the water, or under it, but it’s 2020 so that’s not going to cut it :stuck_out_tongue:

Here is a mockup:
6622993--754639--upload_2020-12-15_11-40-58.png

Everything disappears when the camera goes below the water right now. And I’ve added the blurred separation line in Photoshop. It looks way better with it, so I consider it a requirement to make that actually work!

The underwater rendering will be an extension asset though, given its complexity. As it would drive the price up otherwise, which isn’t ideal for people that don’t care for underwater rendering.

2 Likes

Underwater rendering, extension or not, would be awesome. Put me in the pre-order list for that :slight_smile:

I don’t understand completely the problem with the refraction, but would it be possible to specify some objects/materials to not render “under” water?, and see just the refraction?. Just forget about this if it doesn’t make sense.

1 Like

Put me in the pre-order list too :wink:

Small bug: The hole shader for cutting out a water area (e.g. in a boat) is not used by the Curved World integration. If the world is then curved, the clipping area remains in the normal position.

Would be super cool if this will be fixed in the next update. Until then, I wish you a Merry Christmas and a Happy New Year!

You’re right, this flew under my rader, but can be easily remedied. I’ll DM you the modified shader and will include the changes in next update :slight_smile:

1 Like

As already mentioned in my Assetstore Review, the support is outstanding! Thanks a million for the superfast fix!:slight_smile:

1 Like

Is there any way to prohibit the FloatingTransform component from overwriting the Y axis? the floating system is really helpful and simple for some things. For more complex things I use DWP, but now I have objects where DWP would be too complex and there the FloatingTransform component would be ideal, if it left the Y axis untouched.

private void ApplyTransform()
        {
            //this.transform.up = normal;
            this.transform.position = new Vector3(this.transform.position.x, height, this.transform.position.z);
        }

Of course this is successful, but then no rotation is applied to X and Z, which is a pity and makes the buoyancy effect look less beautiful.

Hi, I have been having some issues with the water reflections.
Normally all seems good in the scene view, but the problems are in the game view (and also builds).

For example:


Versus:

Basically some objects are rendered in the incorrect order, and others seems to render the back faces. The big blue and green “floors” are not reflected in either view, but that is because I forgot to add the custom layer to the culling mask in the reflection renderer.

Another example, scene:

Versus game:

6670216--763537--game view2.png

Two simple boxes with simple materials.

I tested with most of the options of the water shader, with different materials and setting up my scene with only one camera, but the problems persist.

Regards.

Hello! I am facing a strange issue with the asset when built to my android device. In editor, it works splendidly. However, when running the water in my android device, I notice that the surface foam starts out okay, but very quickly start to slow down. I have attached a GIF showing this issue:

ornatesingleindianabat

So here you can see that the fps isn’t tanking, the waves are operating normally as well. It is just the surface foam that seems to be incredibly laggy and jittery?

I have also attached my water’s material settings below. Reflection, underwater, and normal settings have been disabled. Would you be able to help me with this surface foam issue? Have I missed setting up the water correctly? Thank you for your help!

This is unfortunately inherent to how transforms work. Setting the orientation of a transform involves modifying the XYZ axis. If the Y-axis would be left untouched the object would exhibit unwanted behaviour and would appear to wobble around, rather than aligning to the wave surface. Though I can simply add a toggle to disable setting the orientation.

The faces will appear inverted if the camera goes below the virtual reflection plane. Normally this isn’t noticeable, because the camera would already be underwater.

With the Planar Reflection Renderer component selected, you’ll notice a white box around the affected water objects. This box should appear as a flat rectangle, rather than a cube, meaning all the water objects must have the same height on the Y-axis.

If you’ve moved the water up or down, you can press the “Recalculate bounds” button to update the bounds around all the water, which under the hood determines the height of the reflection plane. After which, the you shouldn’t be seeing any incorrect culling on the reflected objects.
6674494--764500--upload_2020-12-31_11-8-4.png

Thanks for taking the time to record a video, shows it clearly! Off the bat the cause doesn’t seem apparent to me, all the animations use the same time index, so if something is wrong there, in theory everything should appear moving in a stepped fashion.

Do you have the possibility to test on another device? Mobile can be particularly finicky, where specific devices have specific issues, with no indication as to why (could be hardware, or the graphics driver)

Ok, I tried a lot of things but couldn’t make the reflections work correctly.

I then went and created a new template URP project with Unity 2019.4.
I installed the stylized water asset and URP was upgraded to 7.5.2.
Then I added a water object, the plane reflection renderer, reused the StylizedWater2_Lowpoly material (I added shadows and increased the reflection strength to see it more clearly), and added two scaled cubes with simple materials.


And the game view seems to be wrong (with the correct bounds).
So any hint would be appreciated :slight_smile:

6675970--764719--test2.png

Hello! I have managed to test on another device (a really old Samsung tablet) and it was running fine, and yet a newer device wasn’t. I suspected that it might have something to do with the graphics API being vulkan causing this issue, and it appears I might be right.

So I have decided to test both Vulkan and OpenGLES3 on the same device. Here is the gif for vulkan, showing the lag on surface foam:

blondlastinggrub

And here is the same device running on opengles3:

caringrelievedhuemul

So it appears there is something weird going on with Vulkan?

A little puzzling, since the reflected objects appear to be rendered with incorrect sorting. Bounds do seem to check out! I can’t reproduce the same result, unless I bring the “Offset” value on the Planar Reflections script way down.

What works for there is replacing line 322 in the PlanarReflectionRenderer script from

oldCamPos = source.transform.position - new Vector3(0, position.y * 2f, 0);

to

oldCamPos = source.transform.position - new Vector3(0, position.y, 0);

Would you mind checking if this works for you as well?

Yes, it certainly seems like an idiosyncrasy related to a specific device, at least with the Vulkan API. On a OnePlus One and Galaxy S10 using Vulkan the issue doesn’t seem to appear. The related shader code is pretty straightforward and doesn’t do anything that need platform or API specific treatment, so I don’t think it’s anything I can fix.

1 Like

These types of issues often occur when using fixed/half data-types in my experience. Desktop uses float always, that’s probably why it works in the editor. You could test if that’s the case if you change everything to float instead.

1 Like

Good point, that may be the case! I’ll have to check if I’m using half precision on any time related.

Hey hey! I just made another discovery! It appears if I disable the wave module, the surface foam jitter disappears. Also, I don’t think I mentioned this earlier, but the surface foam jitter issue takes about 1 minute or 2 before it appears on my HTC 10. Mayhaps you would be able to take a look into this. :slight_smile: