An awakewithai.com production

The Math
Behind It

The physical specification behind Just a Tropical Beach — a beach that is not drawn but solved. Three documents, one system: the ocean that arrives, the instability that breaks it, the shore that absorbs it, and the light that makes any of it visible.

IThe premise

A beach is not a picture of a beach. It is a coupled dynamic system that happens to be visible.

Almost every synthetic ocean is built the wrong way round. Someone decides what the water should look like — blue here, white there, a wave-shaped object that plays a crashing animation — and then spends enormous effort making the decision look convincing. It never quite does, because the eye is extraordinarily good at detecting an effect that has no cause.

The alternative is to specify the rules and let the appearance be a consequence. Water moves because of pressure and gravity. Waves change because the depth changes. Waves break because they become unstable. Swash runs up because it has momentum and runs back because of gravity. Water vanishes into the sand because sand is porous. Foam is white because a dense cloud of air–water interfaces scatters light many times before any wavelength is preferentially absorbed. Sand darkens because water displaces the air between its grains.

None of those are visual decisions. All of them have visual consequences. The whole specification below is an attempt to state the rules precisely enough that the picture has no choice but to emerge.

Oceanspectrumshoalingrefractionbreakingturbulenceairfoamboreswashinfiltrationbackwashsedimentwetnesslightcamera

Read left to right, nothing in that chain is a rendering trick. Each stage is the input to the next, and the last one is the only one you actually see.

IIThe ocean that arrives

One sine wave is a swimming pool. A sea is a sum.

CoordinatesWhere everything lives

Use a right-handed frame: x across the shore, y along it, z up. Still water is z = 0, the ocean occupies x < 0, and the bed is a surface z_b(x,y). The instantaneous water depth is the difference between the free surface and the bed, and the shoreline is simply the contour where that difference vanishes.

h(x,y,t) = η(x,y,t) − z_b(x,y) shoreline: η(x,y,t) = z_b(x,y) This is the single most important equation in the whole system. The shoreline is not a texture, not a decal and not a line to be drawn — it is the moving solution to a wet/dry condition, extracted from the depth field every frame.

SpectrumMany waves, not one

The offshore surface is a superposition of components, each with its own amplitude, direction, frequency and — critically — a random phase:

η₀(x,y,t) = Σᵢ Aᵢ cos(kᵢx + lᵢy − ωᵢt + φᵢ) At minimum three bands: long swell (T = 10–18 s), medium swell (6–10 s) and locally generated wind sea (2–6 s). The interference between bands is what produces sets, lulls and the sense that no two waves are quite the same.

DispersionWhy shallow water changes everything

Gravity waves obey a dispersion relation that depends on depth:

ω² = g k tanh(k h) deep (kh ≫ 1): ω² ≈ g k shallow (kh ≪ 1): c ≈ √(g h) In shallow water the phase speed depends only on depth. As h falls the wave slows — but the water inside it keeps its momentum. That mismatch is the seed of everything that follows.

ShoalingEnergy squeezed into less depth

As the wave slows, its energy is compressed into a shorter wavelength and a taller crest. Height and steepness both rise:

H = H₀ · K_s · K_r K_s = √(C_g,₀ / C_g) steepness: ε_w = H / λ energy: E = ⅛ ρ g H² K_s is the shoaling coefficient and K_r the refraction coefficient. As H rises and λ falls, H/λ rises twice as fast — which is why breaking arrives suddenly rather than gradually.

RefractionWhy waves turn toward the beach

Because speed depends on depth, a wave arriving at an angle travels faster in its deeper part and pivots. It is Snell's law with the same structure as optics:

sin θ₁ / c₁ = sin θ₂ / c₂ Wave crests therefore bend to face the shore, but never completely — the residual angle is what drives the alongshore current and the slow drift of foam down the beach.

GroupingSets and lulls

Real waves do not arrive as identical soldiers. They arrive in groups, and a wave inside a strong group breaks harder than an isolated wave of the same nominal height:

A(t) = A₀ · exp[ G(t) ] G = correlated noise, f_g ≪ f_wave The exponential form matters: it keeps amplitudes positive and makes the big sets rarer than the small ones, which is the observed statistics. Successive waves should be correlated — Xₙ = ρXₙ₋₁ + √(1−ρ²) εₙ — so the sequence reads small, small, medium, large, small rather than a coin flip each time.

IIIThe break

The crash is not an object. It is an instability propagating through a fluid.

A breaking wave is usually animated as a shape that turns white and falls over. Physically it is a continuous loss of stability with a definite cause: the water near the crest begins to move faster than the shape that is carrying it, and at that point the crest can no longer stay attached.

CriterionWhen a wave must break

The classical index compares wave height to local depth. The more fundamental criterion compares the crest's particle velocity to the wave's phase velocity — a Froude number:

depth index: γ_b = H_b / h_b ≈ 0.78 (use 0.70 – 0.83, varying slowly) Froude: Fr_c = U_c / c → 1 probability: P_break = 1 / [ 1 + exp(−a(B − 1)) ] B = H / (γ_b h) A sigmoid rather than a hard threshold, so that two nearly identical waves do not break at exactly the same place. The breaking point is then wherever H(x_b) ≈ γ_b h(x_b) — an emergent location, never a fixed distance from shore.

Breaker typeWhat the slope decides

The same incoming wave produces a completely different break on a different beach. The surf similarity parameter predicts which:

ξ₀ = tan β / √(H₀ / L₀)
ξ₀TypeCharacter
lowSpillingcrest aerates and tumbles; no hollow; long turbulent face
moderatePlunginglip throws forward, encloses air, impacts the face
highCollapsingface collapses without a clean overturn
very highSurgingwave surges up the face with little breaking at all

The jetBallistics, briefly

Once the crest detaches it is a projectile. It leaves with the crest's own velocity plus a throw that scales with √(gH), and from then until impact it is under gravity alone:

U_j ≈ U_c + C_j √(g H) W_j ≈ C_w √(g H) x_j(t) = x₀ + U_j t z_j(t) = z₀ + W_j t − ½ g t² impact when: z_j(t_i) = η_face(x_j, t_i) The forward-and-downward pairing is the whole visual signature of a plunging lip. The critical event is not the throw but the impact.

ImpactWhere the organised wave dies

At impact the jet's kinetic energy is redistributed, and none of it goes back into the wave:

p_imp ≈ ½ ρ U_j² E_total → E_turbulence + E_air + E_foam + E_sediment + E_remaining air entrained: Q_air = C_a A_i U_i A harder crash traps more air, and the trapped air is what makes the water white. The cavity should fragment immediately — a clean geometric air pocket that persists is one of the most obvious tells of a fake.

BubblesA cascade, not a texture

Large cavities are unstable and break down through a size cascade that conserves volume, then dissolve at a rate that depends on radius:

R_parent³ ≈ Σ R_child³ dr/dt = −K_d / r ⟹ r²(t) = r₀² − 2 K_d t Because the dissolution rate goes as 1/r, small bubbles vanish quickly and large ones persist. Foam therefore changes texture as it ages rather than simply fading out — the fine sparkle goes first.

FoamGenerated, advected, decayed

Foam is a field with its own transport equation, not paint applied to the surface:

∂F/∂t + u·∇F = D_F ∇²F + C_F G − λ_F F with breaking source: G = max(0, H/h − γ_b)ᵖ Because foam is advected by the flow it forms streaks that follow real currents. Because it decays exponentially it survives longest where it was thickest. Because it is generated only where H/h exceeds the threshold, it appears exactly where the water is actually breaking.

BoreWhat survives the crash

After the crest collapses the remaining momentum travels shoreward as a turbulent hydraulic transition, and its leading edge is where the whitewater concentrates:

c_b ≈ √(g h_b) foam generation ∝ S = |∂u/∂x|
A realistic wave should never simply turn white and fall. The bottom slows it; the crest keeps going; the upper water outruns the shape beneath it; a sheet becomes a jet; gravity takes the jet; the jet hits the face; the impact traps air; the air becomes bubbles; the bubbles become foam; the remaining momentum becomes a bore; the bore becomes swash. The crash is one event inside a much longer process

IVThe shore

The beach is the only part of the system with a memory.

Governing equationsNonlinear shallow water

Everything from the surf line to the top of the swash is one solver — mass and momentum over a moving wet/dry boundary:

∂h/∂t + ∇·(h u) = 0 ∂(hu)/∂t + ∂(hu² + ½gh²)/∂x + ∂(huv)/∂y = −gh ∂z_b/∂x − τ_x/ρ + F_x Solved numerically, this alone produces a convincing swash zone. The wet/dry front is not interpolated as a line; it is extracted as the contour where depth crosses a small threshold.

UprushMomentum against a slope

To first order the swash front is a projectile running up a ramp, which gives a surprisingly useful estimate of runup:

u₀ = C_u √(g H_b) x(t) = x₀ + u₀t − ½ g β t² t_max = u₀ / (gβ) R_u ≈ u₀² / (2gβ)

But real swash loses energy in several ways at once, and the deceleration is strongly nonlinear:

du/dt = −g β − C_f u|u|/h − C_p u − C_t u³ gravity friction percolation turbulence

InfiltrationWhere the water actually goes

Sand is porous, and a great deal of every wave simply disappears downward rather than flowing back:

q_p = K_p h ⁿ n ≈ 0.5 – 1.5 ∂h/∂t = … − q_p This is the reason a runup can end without a matching backwash, and the reason foam is left stranded in a line rather than dragged back down. It is one of the strongest and most commonly omitted cues on a real beach.

AsymmetryBackwash is not uprush reversed

Uprush and backwash have different durations, different distances and different velocities. A simulation that mirrors them looks mechanical:

A_s = R_u / R_bw allow 0.5 < A_s < 2.0 u_bw = −U_bw · F_r · F_p · F_s (roughness, permeability, saturation)

MemoryWhy the sand stays dark

The beach remembers the last wave, and the one before it. Wetness is a field with a decaying memory, and the whole visual character of the swash zone comes from its overlap with the next wave:

∂W_b/∂t = I(x,y,t) − λ_d W_b W_b(t) = W_b(0)e^(−λt) + ∫ I(τ) e^[−λ(t−τ)] dτ Drying is not uniform: λ_d depends on sun, wind and permeability, so the beach dries in patches rather than as a retreating line.

Two wetnessesDark and shining are not the same thing

It is tempting to drive brightness, roughness and specular response from that one field. It is also wrong, and the error is worth stating plainly because it is easy to make and hard to see. Two different mechanisms darken sand, and they run on timescales a hundred apart.

PORE SATURATION water filling the space BETWEEN grains index step at each boundary falls 1.00→1.55 to 1.33→1.55 light penetrates further, is absorbed before scattering back out → the sand goes DARK. Drains over MINUTES. SURFACE FILM water lying ON TOP, in excess of pore capacity, continuous, held by surface tension against the grain roughness a continuous water surface is a dielectric interface → the sand becomes a MIRROR. Soaks away in SECONDS.

Collapse them into one scalar and the mirror becomes tied to the drying rate. With a specular threshold at W_b ≈ 0.53 and λ_d = 0.011 s⁻¹, the beach keeps a sheen for fifty-eight seconds after the water has gone. The whole shallow zone then ages at one rate, and the wide matte-dark band — pores full, film gone, which is the state a real beach spends most of its time in — cannot exist at all.

saturation: darkens, and slightly smooths B = B_dry − ΔB·S_p film: mirrors, and only mirrors F = F(θ) gated on film film drain: d(film)/dt = −K_p (1 − c·S_p) − E_evap The film soaks in more slowly where the pores are already full, because there is nowhere for it to go — about 1.8 s at the water's edge against 0.4 s on dry sand up the beach. That gradient is why the shine lingers along the waterline and vanishes almost at once further up, and a single scalar cannot produce it.

DewettingThe last water does not retreat

Below roughly a grain diameter a film cannot stay continuous over a rough surface. It pins on the high grains, drains into the hollows, and breaks into patches and rivulets with dry islands between them. This is why the last water on a beach does not slide back with the wave — it stays where it is and disappears in place, which is a different motion entirely and one of the clearest signatures of real swash.

SedimentSand that moves

Grains mobilise when bed shear passes a threshold, and the bed evolves to conserve sediment:

τ_b = ρ C_f u² θ = τ_b / [(ρ_s − ρ) g d] mobile when θ > θ_c ≈ 0.03–0.06 (1 − p) ∂z_b/∂t + ∇·q_s = 0 Run slowly (τ_morph ≫ T_wave) this produces berms, bars, rip channels and scour — the beach shaping itself rather than being shaped by hand.

Long periodsThe slow shove

Two motions much slower than the waves keep the shoreline from looking periodic: bound long waves, and the tide.

η_IG = A_IG sin(2π f_IG t + φ) f_IG < 0.05 Hz, A_IG ≈ 0.01–0.30 m η_tide = A_tide sin(2π t / T_tide + φ) T_tide ≈ 12.42 h x_s(t) = x_mean + x_swash(t) + x_IG(t)

NumericsWhat the timestep is allowed to be

CFL = c Δt / Δx < 1, preferably ≤ 0.5 ⟹ Δt ≤ C Δx / √(g h) Resolution should be nested rather than uniform: metres offshore, tens of centimetres through the surf, and a few centimetres in the swash where the interesting geometry is.

VThe light

The sun does not colour the beach. It illuminates a continuously changing optical system.

Light leaves the sun, is filtered and scattered by the atmosphere, meets a surface whose orientation is changing everywhere at once, splits into a reflected and a transmitted part, travels through water that absorbs it unevenly by wavelength, bounces off pale sand, comes back out, and only then reaches a camera that has to compress an enormous dynamic range into an image. Every one of those steps is a place where a shortcut becomes visible.

AtmosphereWhat actually arrives

I_surface = I₀ e^(−τ m) I₀ ≈ 1361 W/m² air mass: m = 1 / [ sin α_s + 0.50572 (α_s + 6.07995°)^(−1.6364) ] Rayleigh: σ_R(λ) ∝ 1 / λ⁴ The 1/λ⁴ dependence does two jobs at once: it makes the sky blue, and it reddens the direct beam at low sun, because the short wavelengths have been scattered out of it. The sky is then a second light source in its own right — E_total = E_sun + E_sky + E_indirect — which is why shadows on a beach are blue rather than black.

SurfaceA million tiny mirrors

The water surface has a normal that varies continuously in space and time. Every ripple is an independently oriented mirror:

n = (−η_x, −η_y, 1) / √(η_x² + η_y² + 1)

FresnelThe 2 % that becomes 100 %

F(θ) = (F_s + F_p) / 2 at normal incidence: F₀ = [(1.00 − 1.33)/(1.00 + 1.33)]² ≈ 0.02 at grazing: F(θ) → 1 Water reflects only about two per cent of light arriving head-on, and nearly all of it at a glancing angle. This single curve is why you can see the bottom at your feet and only sky at the horizon — and it is why the ocean brightens toward the horizon without anyone painting it brighter.

GlitterWhy the sun path shimmers

A glint occurs where the local normal happens to bisect the sun and view directions. Because the surface carries an enormous population of normals, a sparse and constantly changing subset satisfies the condition at any instant:

H = normalize(L_s + V) glint where n·H → 1 G ∝ F(θ) · D(n,H) · I_sun D_GGX = α² / [ π ( (n·h)²(α² − 1) + 1 )² ] The roughness α is set by the wind, so a fresh breeze widens and fragments the glitter path while calm water narrows it into a coherent column. Scintillation is free: as the waves move, dn/dt ≠ 0, so dG/dt ≠ 0.

Water columnColour by subtraction

I(z,λ) = I(0,λ) e^[−K_d(λ) z] with a_red > a_green > a_blue bottom seen through depth h: T_total = e^(−2 K_d h) The factor of two is the light going down and coming back. Tropical turquoise is not a colour choice: it is what remains of white sunlight after red has been removed by a metre of water, reflected off pale carbonate sand, and filtered again on the way back up.

CausticsLiquid sunlight

The moving surface acts as a lens, focusing light into bright moving networks on the bed. Their brightness is the inverse of how much a bundle of rays has spread:

J = ∂(x′,y′) / ∂(x,y) I_caustic ∝ 1 / |J| Because η changes, J changes, so the pattern is never static. Calm water gives coherent, high-contrast caustics; chop breaks them into something broader and fainter.

Foam and bubblesWhy white is white

Foam is not white because it is painted white. It is a dense population of air–water interfaces; light entering it refracts, reflects internally, meets another interface and scatters again, and after enough of those events wavelength-dependent absorption has barely had a chance to act:

L_foam ≈ L_in [ 1 − e^(−μ_s L) ] μ_s,b = N_b σ_s The exponential does all the work. Where the bubble path is long, L_foam → L_in and the core saturates to opaque white. Where the patch thins at its edges, μ_s falls and the water, sand and shadow underneath show through. Translucent edges around an opaque core are the signature of real foam.

SprayThousands of small lenses

τ_d = ∫ σ_d N_d ds I = I₀ e^(−τ_d) G_total = Σᵢ Fᵢ Dᵢ I_sun Each droplet is a curved lens that can reflect, refract and focus. Backlit, a spray cloud becomes far brighter than the wave that threw it — L_rim ∝ T_water + S_bubble + S_spray — which is the single strongest cue in a sunlit tropical breaker.

Wet sandA temporary mirror

A retreating swash leaves a film one to ten millimetres deep. For a few seconds the beach is a water surface with its own normals and its own glints, and then it is not:

R_wet = R_dry + ΔR · W_b roughness_wet = roughness_dry − Δr · W_b

CameraCompressing the range

Direct sun, bright foam, mid-water and shadow span something like nine orders of magnitude. The renderer must carry that range and only compress it at the very end:

L_camera(λ) ≈ T_atm [ F·L_sun + (1−F)·L_water + F·L_sky + L_bottom + L_scatter + L_foam + L_spray + L_indirect ] + L_atm R,G,B = ∫ L(λ) · r,g,b(λ) dλ C_pixel = ToneMap( Exposure × L_camera ) The tone mapper's job is to compress a physically computed range, not to create the lighting. Get that backwards and the glints clip, the foam goes flat and the water loses its gradients.

VIThe whole system

One vector defines the physical personality of a beach.

Every appearance in the scene descends from a single parameter set. Change one entry and the beach changes character without anything being redrawn:

P = [ β, H_s, T_s, H_w, T_w, θ, K_p, d₅₀, ρ_s, K_R, A_IG, T_IG, A_t, L_t, A_y, C_f, C_b, λ_f, λ_d, U_w, A_tide, reef_depth, reef_distance, sediment_albedo, water_clarity, sun_elevation ] Calm lagoon, open tropical beach, reef-protected, stormy, reflective, dissipative — these are regions of this space, not separate art assets.

The example beachThe one you are looking at

ParameterValueWhat it sets
β0.075 facethe swash-built slope of the beach face
H_swell / T1.35 m / 11.5 sdeep-water swell, before the reef takes any of it
H_wind / T0.74 m / 4.5 slocal chop riding on the swell
d₅₀0.42 mmmedian grain — sets permeability and colour
K_p1.98 × 10⁻³ m/show fast the sand drinks the swash
γ_b0.78 ± 0.055breaking threshold, jittered so waves differ
λ_f0.82 s⁻¹foam decay — how far rafts travel before bursting
A_IG / T_IG0.08 m / 55 sthe slow shove of the shoreline
reef258 m offshorefilters the swell to ~0.55 m at the beach
α_s65.5°sun elevation — near-noon tropical

ScalesWhy small structure matters

A convincing scene carries several scales at once, in space and in time. Missing the small ones is what makes an otherwise correct simulation read as computer graphics.

ScaleSpaceTime
Largewave envelope, crest, trough, boretide, morphology — minutes to hours
Mediumfoam patches, jets, vortices, splash crownswaves, swash, backwash — seconds
Smallbubbles, droplets, ripples, foam filamentsfoam breakup, spray — sub-second
Microair–water interfaces, capillary wavesmilliseconds

RulesFifteen ways to get it wrong

  1. Never make two waves identical.
  2. Never make shoreline motion perfectly periodic.
  3. Never distribute foam uniformly.
  4. Never make the beach perfectly flat.
  5. Never let wet sand dry instantly.
  6. Never make every bubble the same size.
  7. Never make backwash the mirror of uprush.
  8. Never break along a perfectly straight line.
  9. Never hold water colour constant with depth.
  10. Never make foam disappear instantly.
  11. Never give every wave the same runup.
  12. Never use independent per-pixel noise for the shoreline.
  13. Always use correlated randomness.
  14. Always run multiple time scales at once.
  15. Always let the beach remember previous waves.

If you build oneThe minimum that still convinces

With limited resources, the components that carry most of the realism are: a stochastic wave spectrum; shallow-water propagation; a breaking threshold; a dynamic shoreline; uprush and backwash; infiltration; wet-sand memory; foam generation and decay; depth-dependent water colour; Fresnel reflection; dynamic surface normals; sun glints; bottom reflection; shadows that stay blue rather than black; and an HDR exposure at the end. Fifteen systems, and the rest is refinement.

Do not tell the environment what a tropical beach should look like. Tell it what rules govern water, sand, waves, gravity, air, sediment, foam, bubbles, terrain, sunlight and time — and then let the shoreline emerge. The final generative principle

The most convincing virtual beach is not a photograph recreated by mathematics. It is a mathematical ocean and a mathematical beach allowed to produce the photograph as an emergent result.

REALISM ≈ PHYSICS + MULTISCALE VARIATION + MEMORY + STOCHASTICITY