WATER RENDERING

The water effect is achieved through a custom shader combined with a Renderer Feature. Below is a breakdown of the rendering process.

The water shader ASE Top Down Pixel Water is made using Amplify Shader Editor. If you own this asset, you can open the shader as a graph to see how it is made.

Water Color

Render terrain and water-touching objects defined in Terrain Layer Mask into a texture named Terrain Tex.

Apply a gaussian blur to the alpha channel of Terrain Tex using parameters from Water Color Blur Setting, creating Terrain Blurred Tex.

Terrain Tex
Terrain Blurred Tex Overlayed by Terrain Tex

Then we can use the grayscale of Terrain Blurred Tex to lerp between Shallow Color and Deep Color to create a gradient from shallow water near the shore to deep water far from the shore.

Water Color

Shore Line

Shift the alpha of Terrain Texture down by one pixel size (1/32 in world space as this asset is 32x32 per unit), color it with Foam Color and blend it with the base water color.

Water Color with Shore Line

Refraction

First we need to create a mask texture Under Water Mask Tex in the same way as we create the Terrain Blurred Tex in the Water Color step, but with parameters from Under Water Mask Blur Setting.

For the content to be refracted, we use the Terrain Tex and move it down twice, each by 0.4 tile size, mix them together and color it with Under Water Color.

Under Water Mask Tex
Under Water Content

For the distortion effect, apply time-animated Voronoi noise to UV coordinates when sampling from Terrain Tex.

Then we can mask the result with Under Water Mask Tex to create a fading effect and blend it to the base water color.

Under Water Content with Noice Distortion
Masked by Under Water Mask Tex
Blended with Water Color and Shore line

Foam

We use a foam texure TX FX Water Foam from this asset, sample it with the UV multiplied by 2.0 in the vertical direction to match the perspective of the top down scene, and disturb it with a time-animated noise.

For the mask, we use the maske value from Under Water Mask Tex, but move it down by 0.5 tile size and power the value by 2.5 (make the white part wider).

Foam Texture with Modified UV
Disturb Noise
Mask for the Foam
Final Result

Highlight

The highlight pattern is made by multiplying two noise with different size and moving direction, then powered with 6.5 to extract the most light color, and stepped by 0.3 to make it flat.

The UV of the noise is multiplied by 20 in the vertical direction to make it much wider horizontally.

Noise 1
Noise 2
Two Noise Multiplied Together and Powered by 6.5
Stepped by 0.3

Then we can use this as a mask to add Highlight Color to the water to create the final water effect.

Final Water Effect
With Other Scene Objects

Last updated