Stylized Water 3 – Documentation

Stylized Water 3

Stylized Water 3
Version: 3.0.4
Review

5.1.Height Query System #

Being able to read out the water surface height at a given position in the world is crucial for implementing physics-based buoyancy, or aligning positions to the water surface.

This system facilitates such functionality, through 2 different methods.

By large this functionality is for use with custom scripts and buoyancy physics implementations.

It is otherwise only used by the Align Transform To Water component.

No API documentation is found on this page, instead refer to the Align To Water class, which is fully commented and uses this system

CPU (Wave pattern replication)

This method is identical to that featured in Stylized Water 2

Whilst the wave animations takes place entirely in the shader, the exact same wave pattern can be reproduce in C#. Because the algorithm is a mathematical construct.

Pro’s
 Performance efficient
✅ Values are returned instantaneously

Cons
 Limited to flat water surfaces (requires a specific water level)
❌ Only returns the wave animation height, never any Dynamic Effects

Caveats
⚠️ Vertex color wave flattening cannot be taken into account

GPU (Async height readback)

The height of the water surface, as it is animated through Waves and Dynamic Effects, is entirely determined by shader-based effects (GPU). These live in a different domain from C# scripts (CPU), so aren’t readily accessible.

This method renders the water’s height values into an off-screen render texture and reads from it in select locations. It does so through an advanced query system that optimizes the actual readback operation (the slowest part).

Pro’s
Returns the water’s height exactly as it appears, including curved geometry (eg. rivers)
✅ Supports Dynamic Effects

Cons
 Consumes more resources (additional rendering pass and processing of queries)
Not compatible with split-screen multiplayer scenarios. GPU processing is strictly based on the main camera.

Caveats
⚠️ 
Waves with a high steepness value can produces slightly inaccurate results
⚠️ You cannot have hundreds of individual scripts each requesting just 1 sample, this is highly inefficient
⚠️ Positions not visible to the camera will not get a valid height value result.
⚠️ This functionality requires (async) Compute Shader support. Therefor WebGPU is not supported.

 

Yes No Suggest edit
Last updated on January 13, 2025
0 of 0 users found this section helpful
Suggest Edit