Stylized Water 3 – Documentation

Stylized Water 3

Stylized Water 3
Version: 3.0.0
Review

4.7.Reflection rendering #

Reflections are a vital part of what makes water looks believable. In nature, when standing on the shoreline of a lake, most of the water’s appearance is attributed to its reflection alone.

In Unity, reflections are captured using Reflection Probes, which in turn are used for indirect lighting and reflections in glossy/metallic surfaces. The water shader is able to do the same, but this technique is never really suitable for real-time reflections. Two additional methods of reflection rendering are featured to resolve this.

This documentation section is new, and attempts to cover the intricacies of reflection rendering.

If something remains unclear please let me know on Discord so I may clarify and improve this section 🙂

Overview of techniques

Reflection Probes

This is a native Unity feature, so won’t be covered in detail here. You can refer to the Unity manual page on setup and configuration details. Instead, this section will outline their usage in relation to water.

Probes capture a spherical view of the scene at their center, and store the result in a cubemap. The cubemap of the probe that’s nearest to a water surface will end up being used in the shader.

By default, a scene contains no reflection probes, resulting in a black reflection

Pro’s
✅ Performance efficient when baked
✅ Omni-directional, can reflect geometry behind the camera
✅ Accurately reflects the skybox 1:1
✅ Already part of a complete lighting setup (influences all materials)

Cons
Not suitable for real-time reflections (eg. time of day systems)
Approximates reflections. Gets less accurate the further the camera moves away from its center.

Caveats
⚠️
Best suitable for localized reflections, for instance a cave. It is difficult to capture a large environment with just a single probe.
⚠️ Updating a probe will almost always be met with a spike in CPU usage, as the process involves rendering the scene from 6 different perspectives, where each time a new render loop is being run in full. Therefore Reflection Probes need to be considered a method for static reflections

Planar Reflections

With planar reflections, mirror-like reflections are possible, because this technique involves re-rendered the scene from a mirrored perspective.

Reflections will be blended with reflection probes (based on the scene’s alpha channel), so you get best of both worlds. Visually, waves and normals will distort the reflection to create the illusion of a true reflection.

A reflection renderer can be set up through GameObject->3D Object->Water->Planar Reflection Renderer

Pro’s
✅ Real-time reflections
✅ Highly accurate

Cons
Limited to flat “planar” water surfaces only
Not VR/XR compatible
Computationally expensive, requires an additional render loop. Complex scenes will be stressing.
Third-party fog effects often don’t support this (eg. Enviro)

Caveats
⚠️
Water objects should not be moved in height! The RecalculateBounds() function should be called on the Planar Reflection Renderer instance if this is done.

Screen-space Reflections (SSR)

This technique analyses the camera’s depth texture along a ray that travels in a water pixel’s normal direction, at regular intervals a check if performed to see if the ray hits valid geometry. If so, the color at that point is reflected back in the water. If not the reflection falls back to the Reflection Probe

Basically, a form of raytracing is employed (not RTX though)

This option can be enabled on a water material, under the “Environment Reflections” tab

Pro’s
✅ Real-time reflections
✅ Performance efficient (compared to Planar Reflections)
✅ Works for curved water surfaces (eg. rivers)

Cons
❌ Limited to flat “planar” water surfaces only
❌ Can only reflect geometry that is currently visible in the camera’s view (on-screen)
❌ Can be more computationally expensive than Planar Reflections. Requires multiple depth textures samples, which can become heavy on the GPU, especially when a lot of water pixels are on screen and running high resolutions.

Caveats
⚠️
Must be combined with reflection probes (at least one that captures the skybox)
⚠️ Transparent materials can create incorrect reflections, because they have no depth information.
⚠️ Can produce visible artifacts, such as gaps. Especially for small or thin geometry.

Third party SSR technique (and Unity native version, if it ever comes) can never work with transparent materials.

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