โ† All examples

godot shaders

Toon water with depth bands and contact foam

Flat-shaded stylized water: colour steps from shallow to deep by the water depth read from the depth buffer, a foam band with a noisy edge around anything that touches the surface, and drifting ripple lines.

Recorded render of Toon water with depth bands and contact foam

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • component.json
  • demo.tscn
  • inspect_shader.py
  • material.tres
  • preview.png
  • test_package.py
  • toon_water_foam.gdshader
  • verification/native.json

How it works

Shader type
spatial
Render modes
unshaded, cull_back, depth_draw_never, shadows_disabled
Parameters
depth_texture (sampler2D), shallow_color (vec4 = 0.38, 0.86, 0.85, 0.7), deep_color (vec4 = 0.05, 0.32, 0.55, 0.95), depth_range (float = 1), color_steps (int = 3), foam_color (vec4 = 1, 1, 1, 1), foam_distance (float = 0.18), foam_noise_scale (float = 9) and 3 more
Use it on
Opaque terrain or objects below and through the water surface.
Result
Banded turquoise water with white foam rings around rocks and along the shallows.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/toon_water_foam/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • contract_static
  • engine_run
  • engine_log_clean
  • shader_in_scene
  • capture_written
  • render_not_uniform
  • shader_changes_pixels

Limits to consider

Thickness is measured along the view ray, not vertically, so it grows at grazing angles. Transparent objects are not in the depth buffer and get no foam. Unshaded: the sun does not light the water. Flat surface; combine with a vertex wave shader for motion.