Stylized Water 2 - Underwater Rendering (Extension)
As far as scripting is concerned, underwater rendering is fairly straightforward. The Underwater Renderer component is always set up with a specific water material and water level. This is in turn required for its functionality.
Public static functions
These functions are primarily in place to accommodate worlds with more than one water body, and varying water levels.
They must be used, since they also trigger functionality that updates shader properties.
StylizedWater2.UnderwaterRenderer.SetCurrentWaterLevel (Transform or Float input)
You could, for example, use these functions to alter the water- material and level, based on Box Collider triggers. An example script can be viewed here.
- The component is a faux-Singleton, and can be accessed through
UnderwaterRenderer.Instance(it can be null if not present!).
- You can change any public fields on the component directly (eg. water level or fog). Though this must be followed up by calling
UpdateProperties()to ensure the values are also passed on to shaderland.
- The static
UnderwaterRenderer.EnableRenderingboolean can be freely toggled (true by default).