{
 "id": "eikonal-coastal-wave-refraction-shoaling",
 "title": "Fast-Sweeping Eikonal Coastal Wave Refraction & Ray-Tube Shoaling",
 "aliases": [
  "eikonal wave refraction",
  "fast-sweeping shore breakers",
  "bathymetry wave shoaling"
 ],
 "domain": "volumes",
 "subdomain": "water & coastal waves",
 "stage": "volume",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal"
 ],
 "year_introduced": 2002,
 "inputs": [
  "heightfield",
  "texture"
 ],
 "outputs": [
  "heightfield",
  "normals",
  "mesh"
 ],
 "style": "photoreal",
 "dynamic": "both",
 "summary": "Solves the 2D Eikonal equation over seabed bathymetry via fast sweeping to obtain wave travel times, propagation directions, and ray-tube shoaling amplitudes so ocean swells bend realistically around islands and break onto shores.",
 "how_it_works": "In shallow water, surface wave phase speed drops with seabed depth `h` according to linear shallow-water dispersion (`c ≈ sqrt(g * h)` in the shallow limit). By geometric optics, wave crests bend toward shallower contours and satisfy the **Eikonal equation** `|grad(tau)| = 1 / c(x, z)`, where `tau(x, z)` is the wave arrival travel time.\n\nGiven a bathymetry heightfield, **Zhao's fast sweeping method** initializes `tau` along the shoreline or offshore boundary and performs alternating Gauss-Seidel grid sweeps across the four diagonal directions, solving a local quadratic upwind update at each cell until convergence in `O(N)` work. From the resulting travel-time texture `tau`, finite differences yield the local wave propagation direction `k_hat = grad(tau) / |grad(tau)|`, wavefront curvature (divergence of `k_hat`), and a **ray-tube shoaling factor** combining Green's law (`h^(-1/4)`) with energy focusing on headlands and defocusing in bays.\n\nAt runtime, the vertex and fragment shaders evaluate wave phase `omega * (tau + t)` directly from the precomputed map, steepening crests into plunging asymmetric breakers up to the depth-limited breaking threshold (`~0.42–0.78 * h`), while damping regions where colliding wavefronts form shocks.",
 "when_to_use": "Choose it when rendering large coastlines, islands, and reefs where offshore swells must smoothly refract parallel to beaches, wrap around sea stacks, and shoal into breaking surf at minimal runtime cost.\n\nPrefer [fft-ocean](fft-ocean) for open deep-water wind seas where bathymetry is uniform and periodic spectral synthesis excels. Prefer [shallow-water-equations](shallow-water-equations) when you need two-way dynamic fluid interactions, wakes, or rapidly changing water levels rather than steady-state swell refraction. Prefer [gerstner-waves](gerstner-waves) when a handful of unrefracted analytic wave trains suffice.",
 "cost": {
  "class": "cheap",
  "notes": "Fast-sweeping Eikonal baking runs once per bathymetry change in milliseconds on CPU or GPU; runtime evaluation needs only texture lookups per vertex/pixel (Ultra-Water reports ~1.9–3.0 ms total for its full water pass at 1440p on an RTX 3060)."
 },
 "failure_modes": [
  "Eikonal shocks where wavefronts wrap around opposite sides of an island or rock and collide produce discontinuous gradients that cause folded mesh sheets unless damped",
  "Pure geometric optics ignores wave diffraction behind sharp breakwaters and narrow harbor mouths, leaving overly stark shadow zones",
  "Static baked travel-time fields must be re-swept if seabed bathymetry or large submerged obstacles move dynamically",
  "Unfiltered steep coastal displacement on a sliding camera-centered mesh causes waterline swimming unless wave amplitudes are band-limited to local vertex spacing"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1090/s0025-5718-04-01678-3",
   "type": "paper",
   "title": "A fast sweeping method for Eikonal equations",
   "authors": [
    "Hongkai Zhao"
   ],
   "year": 2004,
   "venue": "Mathematics of Computation",
   "url": "https://doi.org/10.1090/s0025-5718-04-01678-3",
   "ids": {
    "doi": "10.1090/s0025-5718-04-01678-3"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1090/s0025-5718-04-01678-3",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1090/s0025-5718-04-01678-3",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1090/s0025-5718-04-01678-3",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1090/s0025-5718-04-01678-3",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1090/s0025-5718-04-01678-3",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": 1,
   "__bib": "zhao2004fast"
  },
  {
   "role": "primary",
   "key": "doi:10.1016/s0097-8493(01)00181-9",
   "type": "paper",
   "title": "An accurate model of wave refraction over shallow water",
   "authors": [
    "Manuel N. Gamito",
    "F.Kenton Musgrave"
   ],
   "year": 2002,
   "venue": "Computers &amp; Graphics",
   "url": "https://doi.org/10.1016/s0097-8493(01)00181-9",
   "ids": {
    "doi": "10.1016/s0097-8493(01)00181-9"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/s0097-8493(01)00181-9",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/s0097-8493(01)00181-9",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/s0097-8493(01)00181-9",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/s0097-8493(01)00181-9",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/s0097-8493(01)00181-9",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": 1,
   "__bib": "gamito2002accurate"
  },
  {
   "role": "secondary",
   "key": "doi:10.1145/3072959.3073678",
   "type": "paper",
   "title": "Water wave packets",
   "authors": [
    "Stefan Jeschke",
    "Chris Wojtan"
   ],
   "year": 2017,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/3072959.3073678",
   "ids": {
    "doi": "10.1145/3072959.3073678"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3072959.3073678",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3072959.3073678",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3072959.3073678",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3072959.3073678",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3072959.3073678",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": 1,
   "__bib": "jeschke2017water"
  },
  {
   "role": "implementation",
   "key": "gh:humpalumps/ultra-water",
   "type": "code",
   "title": "Humpalumps/Ultra-Water",
   "description": "Real-time FFT ocean renderer for three.js (WebGL2): shore breakers, foam, caustics, underwater rendering and buoyancy at 170–300 fps",
   "authors": [
    "Humpalumps"
   ],
   "year": 2026,
   "venue": "GitHub",
   "url": "https://github.com/Humpalumps/Ultra-Water",
   "ids": {
    "repo": "Humpalumps/Ultra-Water"
   },
   "license": "MIT",
   "extra": {
    "stars": 694,
    "stars_checked": "2026-11-30",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-02T13:23:28Z",
    "language": "JavaScript",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Humpalumps/Ultra-Water",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Humpalumps/Ultra-Water",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Humpalumps/Ultra-Water",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Humpalumps/Ultra-Water",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Humpalumps/Ultra-Water",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Humpalumps/Ultra-Water",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": null,
   "__bib": "humpalumps2026humpalumpsb"
  }
 ],
 "presets": [
  {
   "id": "eikonal-coastal-wave-refraction-shoaling-live",
   "title": "Eikonal Coastal Wave Refraction & Shoaling — travel-time fronts & bathymetry (left) vs refracted breaking surf (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_WAVE_PERIOD": 18,
    "P_SHOAL_GAIN": 1.15,
    "P_SWELL_DIR": 0.28,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_WAVE_PERIOD = 18.0; // P Swell Frequency [8.0, 32.0, 1.0]\nconst float P_SHOAL_GAIN = 1.15; // P Shoaling Amp [0.3, 2.0, 0.05]\nconst float P_SWELL_DIR = 0.28; // P Swell Angle [-0.8, 0.8, 0.04]\nconst float P_SPLIT = 0.48; // P Eikonal / Ocean Split [0.0, 1.0, 0.02]\n\n// Coastal bathymetry depth h(p) > 0 in water, <= 0 on volcanic island & curved headland\nfloat evalBathymetry(vec2 p) {\n  // Sloping mainland beach along top edge (y > 0.38)\n  float beach = 0.42 - p.y + 0.09 * sin(p.x * 3.2) + 0.04 * cos(p.x * 7.5);\n  // Offshore volcanic island with submerged shallow shoal apron\n  float dIsl = length((p - vec2(-0.18, -0.08)) * vec2(0.95, 1.18)) - 0.19;\n  // Secondary submerged reef shoal on right\n  float dReef = length((p - vec2(0.36, 0.02)) * vec2(1.1, 0.85)) - 0.14;\n  float h = min(beach, dIsl);\n  h = min(h, dReef + 0.06); // reef stays slightly submerged so waves bend & amplify over it!\n  return h;\n}\n\n// Fast-sweeping Eikonal travel-time solution T(p) where |grad T| = 1 / c(h), c(h) = sqrt(g * h)\n// Waves slow down in shallow water -> wavefronts bend/wrap concentrically around island & shoreline!\nfloat evalEikonalTime(vec2 p, float dirAng) {\n  vec2 kDir = vec2(sin(dirAng), cos(dirAng));\n  float baseT = dot(p, kDir);\n  // Local refraction delay accumulated around shallow bathymetry features\n  float dIsl = length((p - vec2(-0.18, -0.08)) * vec2(0.95, 1.18));\n  float dReef = length((p - vec2(0.36, 0.02)) * vec2(1.1, 0.85));\n  float beachDist = max(0.42 - p.y + 0.09 * sin(p.x * 3.2), 0.005);\n\n  // Shallow-water phase speed slowdown bends iso-T fronts parallel to depth contours!\n  float slowIsl = 0.26 * exp(-max(dIsl - 0.16, 0.0) * 4.2);\n  float slowReef = 0.16 * exp(-max(dReef - 0.10, 0.0) * 4.8);\n  float slowBeach = 0.24 * exp(-beachDist * 5.2);\n  return baseT + slowIsl + slowReef + slowBeach;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float sx = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool showOcean = sx >= split;\n\n  float freq = clamp(P_WAVE_PERIOD, 6.0, 36.0);\n  float shoalGain = clamp(P_SHOAL_GAIN, 0.2, 2.4);\n  float dirAng = clamp(P_SWELL_DIR, -1.0, 1.0);\n\n  vec2 p = uv * 1.15;\n  float h = evalBathymetry(p);\n\n  // Compute Eikonal travel time T and its gradient (wave propagation vector & local wave speed c = 1/|grad T|)\n  float e = 0.004;\n  float T = evalEikonalTime(p, dirAng);\n  float Tx = (evalEikonalTime(p + vec2(e, 0.0), dirAng) - evalEikonalTime(p - vec2(e, 0.0), dirAng)) / (2.0 * e);\n  float Ty = (evalEikonalTime(p + vec2(0.0, e), dirAng) - evalEikonalTime(p - vec2(0.0, e), dirAng)) / (2.0 * e);\n  vec2 gradT = vec2(Tx, Ty);\n  float slowness = length(gradT);\n\n  // Ray-tube shoaling amplitude (Green's law ~ h^(-1/4) modulated by ray convergence)\n  float hClamped = max(h, 0.015);\n  float shoalAmp = clamp(pow(0.28 / hClamped, 0.34) * (0.65 + 0.45 * slowness) * shoalGain, 0.35, 2.2);\n\n  // Refracted trochoidal swell wave height & normal\n  float phase = T * freq - iTime * 2.6;\n  float steep = clamp(shoalAmp * 0.42, 0.1, 0.85);\n  float wave = sin(phase + steep * sin(phase));\n  float dWave = cos(phase + steep * sin(phase)) * (1.0 + steep * cos(phase));\n\n  vec3 col;\n  if (h <= 0.0) {\n    // Volcanic island & sandy coastal shore\n    float elev = -h;\n    vec3 sand = vec3(0.76, 0.68, 0.50);\n    vec3 rock = vec3(0.26, 0.28, 0.24);\n    vec3 veg = vec3(0.18, 0.36, 0.18);\n    float hx = evalBathymetry(p + vec2(e, 0.0)) - evalBathymetry(p - vec2(e, 0.0));\n    float hy = evalBathymetry(p + vec2(0.0, e)) - evalBathymetry(p - vec2(0.0, e));\n    vec3 ln = normalize(vec3(hx * 22.0, hy * 22.0, 1.0));\n    float nl = max(dot(ln, normalize(vec3(0.55, -0.45, 0.7))), 0.15);\n    vec3 land = mix(sand, mix(veg, rock, smoothstep(0.06, 0.16, elev)), smoothstep(0.015, 0.055, elev));\n    col = land * nl * 1.25;\n    if (!showOcean) {\n      // Elevation contour rings on land in Eikonal diagnostic view\n      float cLine = smoothstep(0.08, 0.02, abs(fract(elev * 22.0) - 0.5));\n      col = mix(col * 0.72, vec3(0.95, 0.82, 0.52), cLine * 0.45);\n    }\n  } else if (!showOcean) {\n    // Left: Bathymetry depth field + Eikonal iso-travel-time wavefronts + shoaling amplification heatmap\n    vec3 deepC = vec3(0.04, 0.10, 0.24);\n    vec3 midC = vec3(0.08, 0.44, 0.62);\n    vec3 shoalC = vec3(0.98, 0.58, 0.14);\n    float shNorm = clamp((shoalAmp - 0.5) / 1.4, 0.0, 1.0);\n    col = mix(mix(deepC, midC, smoothstep(0.55, 0.05, h)), shoalC, shNorm * 0.72);\n    // Crisp moving iso-travel-time Eikonal wavefront contours\n    float front = smoothstep(0.12, 0.02, abs(fract(phase / 6.2831853) - 0.5));\n    col = mix(col, vec3(0.98, 0.99, 1.0), front * 0.85);\n    // Subtle bathymetry iso-depth contour lines\n    float bCont = smoothstep(0.06, 0.015, abs(fract(h * 12.0) - 0.5));\n    col = mix(col, vec3(0.28, 0.92, 0.82), bCont * 0.28);\n  } else {\n    // Right: Physically shaded coastal ocean with refracted swells, shallow turquoise absorption, and breaking surf foam!\n    vec3 wN = normalize(vec3(-gradT.x * dWave * 0.24 * shoalAmp, -gradT.y * dWave * 0.24 * shoalAmp, 1.0));\n    vec3 sunDir = normalize(vec3(0.58, -0.52, 0.62));\n    vec3 V = vec3(0.0, 0.0, 1.0);\n    vec3 H = normalize(sunDir + V);\n\n    vec3 deepWater = vec3(0.02, 0.12, 0.24);\n    vec3 shallowTurq = vec3(0.08, 0.56, 0.58);\n    vec3 waterCol = mix(shallowTurq, deepWater, smoothstep(0.02, 0.48, h));\n\n    // Subsurface turquoise crest translucency + crisp solar glint\n    float glint = pow(max(dot(wN, H), 0.0), 86.0) * 2.2;\n    float sss = smoothstep(0.15, 0.95, wave) * smoothstep(0.45, 0.04, h) * 0.35;\n    float fres = 0.06 + 0.45 * pow(1.0 - max(wN.z, 0.0), 3.0);\n    vec3 skyRefl = vec3(0.42, 0.64, 0.88);\n    col = mix(waterCol + vec3(0.12, 0.68, 0.64) * sss, skyRefl, fres) + vec3(1.0, 0.92, 0.78) * glint;\n\n    // Breaking whitewater foam on steep shoaling wave crests & shoreline swash\n    float crestFoam = smoothstep(0.68, 0.94, wave * clamp(shoalAmp * 0.68, 0.4, 1.25)) * smoothstep(0.28, 0.02, h);\n    float shoreFoam = smoothstep(0.042, 0.004, h) * (0.65 + 0.35 * sin(phase));\n    float foam = clamp(crestFoam + shoreFoam, 0.0, 1.0);\n    col = mix(col, vec3(0.95, 0.97, 0.99), foam);\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "reduced-sandbox",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "eikonal-coastal-wave-refraction-shoaling",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:08.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.7336,
      "std": 0.1076,
      "min": 0.451,
      "max": 0.9014
     },
     "image": "/specimens/eikonal-coastal-wave-refraction-shoaling-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "fft-ocean",
  "gerstner-waves",
  "shallow-water-equations",
  "jonswap-spectrum",
  "flow-map-water"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "fft-ocean",
   "why": "Provides multi-cascade deep-water wind waves that blend seamlessly into Eikonal refracted breakers as seabed depth shoals."
  },
  {
   "id": "water-caustics-realtime",
   "why": "Uses the refracted surface slopes and shallow bathymetry map to project depth-accurate animated caustics onto the seabed."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-30T17:59:51.239Z",
  "draft": "data/drafts/volumes/eikonal-coastal-wave-refraction-shoaling.json"
 },
 "solves": [
  "ocean waves fail to bend parallel to curving beaches and headlands",
  "fft ocean looks identical in deep water and shallow shorelines",
  "need waves to slow down shorten and steepen as seabed depth drops",
  "compute realistic coastal wave phase and direction from a bathymetry map",
  "drive shoreline breaking swells and surf zones from terrain height"
 ],
 "authority": "Zhao, 2004",
 "url": "https://texelatlas.vercel.app/t/eikonal-coastal-wave-refraction-shoaling/",
 "execution_fidelity": "reduced-sandbox",
 "fidelity_label": "Analytic Sandbox",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 5.29,
  "tier": "light",
  "p50_ms": 0.1741,
  "p95_ms": 0.1809,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "eikonal-coastal-wave-refraction-shoaling-live",
  "execution_fidelity": "reduced-sandbox",
  "fidelity_label": "Analytic Sandbox",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 5.12,
   "tier": "light",
   "p50_ms": 0.0814,
   "p95_ms": 0.0821,
   "speedup_x": 2.14,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 3.69,
   "tier": "light",
   "p50_ms": 0.1063,
   "p95_ms": 0.107,
   "speedup_x": 1.64,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}