โ† All examples

godot shaders

Gerstner wave ocean surface

Displace a subdivided plane with three summed Gerstner waves computed in world space, with analytic normals, sharp crests, crest foam colour and a view-dependent deep to shallow tint.

Recorded render of Gerstner wave ocean surface

What this component contains

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

How it works

Shader type
spatial
Parameters
deep_color (vec4 = 0.02, 0.1, 0.18, 1), shallow_color (vec4 = 0.06, 0.38, 0.45, 1), crest_color (vec4 = 0.8, 0.92, 0.95, 1), amplitude (float = 0.22), wavelength (float = 3.5), steepness (float = 0.65), speed (float = 1), direction_degrees (float = 25) and 2 more
Use it on
A subdivided PlaneMesh (or other flat grid); the demo uses 120 x 120 subdivisions.
Result
A rolling sea with sharp crests, light foam on top and sun glints.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/gerstner_wave_water/

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

The plane must be dense enough for the shortest wave or the shape aliases. No transparency, refraction or depth fade (see `toon_water_foam` for depth-based shading). The CPU does not know the wave height, so floating objects need the same formula in a script.