Baltor Get started

Gallery / Godot shaders

Gerstner wave ocean surface

In your harnessGodot shaderMIT

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.

Render of Gerstner wave ocean surface
The render its check recorded in Godot 4.7.2, 256 by 256 pixels.

What it takes and gives

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/

Limits. 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.

Details

Kind
Godot shader
Engine
Godot 4.3 or later
Files
11 files, 102.5 KB
Licence
MIT
Declared effects
reads files, runs commands
Checked with
Godot 4.7.2, opengl3 compatibility (Mesa llvmpipe, Xvfb)
Checks
contract static, engine run, engine log clean, shader in scene, capture written, render not uniform, shader changes pixels
Techniques
Gerstner (trochoidal) waves with deep-water dispersion, Analytic tangent and binormal sums for normals, World-space wave phase for seamless tiling
Tags
godot shader, spatial, water, ocean, gerstner waves, vertex displacement, waves
Identity
library.supply.creative_originals.294f9837adc66a480ace3d7a.bcdd0b746333a6cd
Version
bcdd0b746333a6cdf5af3958f0cccad6fa86097ff58c7758f91adcb1846005de

The version is the SHA-256 of the item your harness downloads; every file in it names its own checksum.

Something wrong with this item, its rights or its safety? Report it on the support page, or from your harness after a download.