Stylized Water 3 – Documentation

Stylized Water 3

Stylized Water 3
Version: 3.0.0
Review

5.Scripting #

By large this is a shader asset. Though because aspects revolving around Height Sampling are related to scripting, there are a couple of C# functions in place that can aid development.

Familiarity with C# and OOP programming is assumed. Support cannot be extended to coding help. Some specific functionality and use cases really need to be handled on a project-specific basis with some creative thinking.

If you are using an assembly definition, ensure you add a reference to the sc.stylizedwater3.runtime assembly, otherwise you won’t be able to access the StylizedWater3 namespace and classes.

All these functions have IntelliSense summaries, which can be viewed in your IDE, next to any overload variations. If necessary, each parameter is described there.

StylizedWater3.WaterObject.Find

Using the Height Query System‘s CPU method requires a reference to a Water Object component. This is so the Y-position (water level) and material (wave settings) can be accessed.

This function is a quick way to find a Water Object below or above a given position. It won’t be efficient to rely entirely on this, especially not every frame. Its performance impact scales up by the number of Water Objects in the scene.

Floating Origins systems

To offset the water’s world-position coordinates in the shader, you can set the offset value through StylizedWater3.WaterObject.PositionOffset = <a Vector3>. This also affects the Height Query System correctly.

The “Water Position Offset” component may also be used

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 is possible by overriding the time index used by the shader.

Through script, pass your time value every frame through StylizedWater3.WaterObject.CustomTime = <a float>. This function will pass the time value to the shader and buoyancy calculations, and keeps them in sync.

To disable this behaviour, pass in a value lower than 0.

The “Set Custom Water Time” component may also be used, or consulted as an example script.

Yes No Suggest edit
Last updated on October 15, 2024
0 of 0 users found this section helpful
Suggest Edit