Stylized Water 2 documentation

Stylized Water 2

Stylized Water 2
Author: jonathan
Version: 1.0.6
Dated: 22 Sep 2020

4.1.Shader #

The shader is set to a material, which in turn can be applied to a mesh. The shader will always render in Forward rendering, due to its transparent nature.

All the shader parameters have tooltips, if you’re unsure what something is for, mouse over to view a description.

Shading modes

The advanced shading mode takes more liberty and focuses on high-end rendering. If water in your game is only something  that’s viewed in the background, or viewed from a top-down perspective it will offer little benefit. Compared to the “Simple” shading mode it does:

  • Chromatic refractions, color channels are split one pixel apart
  • Caustics/sun reflection masking, even if the water does not receive shadows, the shadow map is read to avoid these effects being visible in shadows.

Transparency mask

It’s possible to hide the water behind another mesh in order to create visible holes in the water. This can be used to hide the water inside boats. Note that this hides every transparent material behind it, not just the water.

In order to do so, assign the “WaterTransparencyMask” material to a mesh, found in the StylizedWater2/Materials folder.

Network synchronized waves

All the shader effects, including the waves use the global _TimeParameters shader value set by Unity as a time index. This translates to UnityEngine.Time.time.

If you’re running a networked application, it may be important to ensure the waves are identical for all players (especially when using buoyancy). This requires a minor modification to the shader, to have it use a time value defined by your server.

Open the StylizedWater2/Shaders/Libraries/Common.hlsl file and uncomment the line that reads #define USE_CUSTOM_TIME.

Next, through script, set StylizedWater2.Buoyancy.UseCustomTime to true. Then pass your time value every frame through StylizedWater2.Buoyancy.SetCustomTime(float value). This function will pass the value to the shader and buoyancy calculations, and keeps them in sync.

Yes No Suggest edit
Last updated on November 29, 2020
0 of 0 users found this section helpful
Suggest Edit