Texel A field guide to 3D techniques

FFT Ocean (Tessendorf) × LEADR mapping × Real-time glints (distributed binomial laws)

Sun glitter from horizon to bow. An ocean that sparkles at every distance. Waves too small to see fold into a correctly stretched specular lobe, and the same filtered slope distribution drives discrete glints, so distant water glitters instead of turning into a flat smear.

Open in StudioReproduced15.1× · 0.469 ms

FFT Ocean (Tessendorf)Volume · Real-timein: material-paramsout: heightfield, normals, texturetextureLEADR mappingMaterial · Real-timein: texture, normals, meshout: texture, material-paramsmaterial-paramsReal-time glints (distributed binomial laws)Material · Real-timein: material-params, normals, uv-atlasout: radiance

Verified proof

reproduced · 2026-12-01wrong-nebulalicense MIT
Specimen render of Sun glitter ocean (left: point-sampled specular, right: LEADR slope moments + discrete glints)
Cross-proof specimen. Sun glitter ocean (left: point-sampled specular, right: LEADR slope moments + discrete glints). Verified WebGL2 proof · 2026-12-01

Split-screen WebGL2 proof comparing naive point-sampled ocean normal specular (left, aliasing in mid-field and collapsing toward the horizon) against multi-cascade spectral waves filtered via LEADR slope-covariance moments driving both a stretched anisotropic specular lobe and temporally twinkling discrete sun glints from bow to horizon (right).

Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · maintains physically stretched horizon glitter path and coherent wave-period twinkling glints across 3 distance decades without sub-pixel sparkle aliasing

Show GLSL proof (164 lines)
const float WIND_SPEED = 1.15; // P
const float GLINT_DENSITY = 1.25; // P
const float SUN_ELEVATION = 0.14; // P
const float CHOPPINESS = 0.82; // P
float hash21(vec2 p) {
  p = fract(p * vec2(123.34, 456.21));
  p += dot(p, p + 45.32);
  return fract(p.x * p.y);
}
vec2 hash22(vec2 p) {
  vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
  p3 += dot(p3, p3.yzx + 33.33);
  return fract((p3.xx + p3.yz) * p3.zy);
}
// Multi-cascade directional wave spectrum returning height, resolved slope, and sub-footprint LEADR slope covariance
void evalOceanSpectrum(vec2 p, float t, float footprint, out float h, out vec2 slope, out vec3 cov) {
  h = 0.0;
  slope = vec2(0.0);
  cov = vec3(0.0020, 0.0020, 0.0);
  const int N = 12;
  for (int i = 0; i < N; i++) {
    float fi = float(i);
    float freq = 0.24 * pow(1.48, fi);
    float ang = (fi * 2.39996 - 1.2) * 0.42 + 0.14 * sin(fi * 1.7);
    vec2 dir = vec2(sin(ang), cos(ang));
    float amp = (0.38 / pow(freq, 1.34)) * CHOPPINESS * (0.65 + 0.35 * WIND_SPEED);
    float speed = sqrt(9.81 * freq) * (0.72 + 0.28 * WIND_SPEED);
    float ph = dot(dir, p) * freq - t * speed + fi * 1.91;
    float wLen = 6.2831853 / freq;
    float resWeight = exp(-pow(footprint * 2.1 / max(wLen, 0.02), 2.0));
    float subWeight = 1.0 - resWeight;
    h += amp * sin(ph) * resWeight;
    vec2 dSlope = dir * (amp * freq * cos(ph));
    slope += dSlope * resWeight;
    float k2 = 0.5 * (amp * freq) * (amp * freq) * subWeight;
    cov.x += k2 * dir.x * dir.x;
    cov.y += k2 * dir.y * dir.y;
    cov.z += k2 * dir.x * dir.y;
  }
}
vec3 evalSky(vec3 rd, vec3 sunDir) {
  float elev = max(rd.y, 0.0);
  vec3 zenith = vec3(0.008, 0.028, 0.105);
  vec3 mid = vec3(0.045, 0.125, 0.280);
  vec3 horiz = vec3(0.86, 0.32, 0.06);
  vec3 sky = mix(horiz, mid, pow(elev, 0.32));
  sky = mix(sky, zenith, pow(elev, 0.75));
  float sunCos = max(dot(rd, sunDir), 0.0);
  sky += vec3(1.0, 0.42, 0.10) * pow(sunCos, 18.0) * 0.60;
  sky += vec3(1.0, 0.76, 0.36) * pow(sunCos, 160.0) * 2.2;
  sky += vec3(1.0, 0.94, 0.78) * smoothstep(0.9985, 0.9995, sunCos) * 12.0;
  return sky;
}
// Anisotropic LEADR slope Gaussian/Beckmann NDF from filtered 2x2 slope covariance
float leadrNDF(vec2 hSlope, vec2 meanSlope, vec3 cov) {
  vec2 d = hSlope - meanSlope;
  float vx = max(cov.x, 0.0022);
  float vz = max(cov.y, 0.0022);
  float cxz = clamp(cov.z, -0.85 * sqrt(vx * vz), 0.85 * sqrt(vx * vz));
  float det = max(vx * vz - cxz * cxz, 1e-6);
  float q = (vz * d.x * d.x - 2.0 * cxz * d.x * d.y + vx * d.y * d.y) / det;
  return exp(-0.5 * q) / (6.2831853 * sqrt(det));
}
// Temporally varying discrete binomial microfacet sun glints driven by LEADR slope probability
float evalGlints(vec2 worldP, float dist, vec2 hSlope, vec2 meanSlope, vec3 cov, float t) {
  float prob = leadrNDF(hSlope, meanSlope, cov);
  if (prob < 0.0008) return 0.0;
  float level = log2(max(dist * 0.085, 0.10));
  float l0 = floor(level);
  float lf = fract(level);
  float glintSum = 0.0;
  for (int o = 0; o < 2; o++) {
    float w = o == 0 ? (1.0 - lf) : lf;
    float cellSize = 0.24 * exp2(l0 + float(o));
    vec2 cell = floor(worldP / cellSize);
    vec2 local = fract(worldP / cellSize) - 0.5;
    float tStep = floor(t * (2.6 + 1.2 * WIND_SPEED));
    float tFrac = fract(t * (2.6 + 1.2 * WIND_SPEED));
    float twinkle = 0.5 - 0.5 * cos(tFrac * 6.2831853);
    for (int k = 0; k < 2; k++) {
      float tw = k == 0 ? (1.0 - twinkle) : twinkle;
      vec2 seed = cell + vec2(tStep + float(k) * 19.0, float(o) * 41.0);
      vec2 rnd = hash22(seed);
      vec2 jitter = (rnd - 0.5) * 0.70;
      float r2 = dot(local - jitter, local - jitter);
      float spot = exp(-r2 * 42.0);
      float pHit = clamp(prob * 0.14 * GLINT_DENSITY / (1.0 + 0.004 * dist), 0.0, 0.96);
      float gate = smoothstep(1.0 - pHit, 1.0, hash21(seed + 7.3));
      glintSum += w * tw * spot * gate * (3.5 + 8.5 * rnd.x);
    }
  }
  return glintSum * smoothstep(260.0, 6.0, dist);
}
vec3 acesTone(vec3 x) {
  return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  bool useLeadr = uv.x > 0.0;
  vec2 suv = vec2(useLeadr ? uv.x - 0.25 : uv.x + 0.25, uv.y);
  vec3 ro = vec3(0.0, 2.85, 0.0);
  vec3 rd = normalize(vec3(suv.x * 1.15, suv.y - 0.16, 1.35));
  vec3 sunDir = normalize(vec3(0.0, max(SUN_ELEVATION, 0.04), 0.99));
  vec3 skyCol = evalSky(rd, sunDir);
  vec3 col = skyCol;
  if (rd.y < -0.002) {
    float tPlane = -ro.y / rd.y;
    float tHit = min(tPlane, 260.0);
    vec2 wp = ro.xz + rd.xz * tHit;
    float fp = clamp(tHit / (iResolution.y * max(-rd.y, 0.035)) * 1.65, 0.015, 34.0);
    float h; vec2 slope; vec3 cov;
    for (int s = 0; s < 3; s++) {
      evalOceanSpectrum(wp, iTime, fp, h, slope, cov);
      tHit = clamp((h - ro.y) / rd.y, 0.5, 260.0);
      wp = ro.xz + rd.xz * tHit;
    }
    fp = clamp(tHit / (iResolution.y * max(-rd.y, 0.035)) * 1.65, 0.015, 34.0);
    float evalFp = useLeadr ? fp : 0.006;
    evalOceanSpectrum(wp, iTime, evalFp, h, slope, cov);
    vec3 N = normalize(vec3(-slope.x, 1.0, -slope.y));
    vec3 V = -rd;
    vec3 H = normalize(sunDir + V);
    float ndv = clamp(dot(N, V), 0.02, 1.0);
    float fres = 0.02 + 0.98 * pow(1.0 - ndv, 5.0);
    vec3 R = reflect(rd, N);
    R.y = max(R.y, 0.02);
    vec3 reflSky = evalSky(R, sunDir) * 0.42;
    vec3 deepWater = vec3(0.003, 0.016, 0.042);
    float crest = clamp(h * 1.7 + 0.22, 0.0, 1.0);
    vec3 sss = vec3(0.008, 0.13, 0.16) * pow(crest, 2.2) * pow(max(dot(V, -sunDir + N * 0.45), 0.0), 3.0) * 1.25;
    vec3 waterBase = mix(deepWater + sss, reflSky, clamp(fres * 0.78, 0.0, 0.88));
    vec3 sunCol = vec3(1.0, 0.64, 0.20) * 10.0;
    vec3 spec = vec3(0.0);
    if (!useLeadr) {
      // Left: naive point-sampled GGX specular (breaks up in midground and collapses to flat smear toward horizon)
      float rough = 0.055;
      float a2 = rough * rough;
      float ndh = max(dot(N, H), 0.0);
      float denom = ndh * ndh * (a2 - 1.0) + 1.0;
      float D = a2 / (3.1415926 * denom * denom);
      float atten = exp(-tHit * 0.035);
      spec = sunCol * D * fres * 0.08 * atten;
    } else {
      // Right: LEADR slope-moment anisotropic lobe + discrete twinkling glints across full bow-to-horizon path
      vec2 hSlope = -H.xz / max(H.y, 0.05);
      vec3 totalCov = cov + vec3(0.0045 * WIND_SPEED, 0.028 * WIND_SPEED, 0.0);
      float Dleadr = leadrNDF(hSlope, slope, totalCov);
      float G = 1.0 / (1.0 + 0.28 / max(ndv, 0.05));
      float glint = evalGlints(wp, tHit, hSlope, slope, totalCov, iTime);
      vec3 lobe = sunCol * Dleadr * (0.28 + 0.72 * fres) * G * 0.28;
      vec3 sparkles = vec3(1.0, 0.90, 0.56) * glint * (0.35 + 0.65 * fres) * 6.5;
      spec = lobe + sparkles;
    }
    float slopeMag = length(slope);
    float foamMask = smoothstep(0.72, 1.15, slopeMag + hash21(floor(wp * 4.0)) * 0.16) * smoothstep(85.0, 10.0, tHit);
    vec3 surf = waterBase + spec;
    surf = mix(surf, vec3(0.58, 0.64, 0.72) * (0.35 + 0.65 * max(dot(N, sunDir), 0.0)), foamMask * 0.34);
    float fog = 1.0 - exp(-tHit * 0.0068);
    col = mix(surf, evalSky(vec3(rd.x, 0.015, rd.z), sunDir) * 0.68, clamp(fog, 0.0, 0.80));
  }
  col = acesTone(col);
  if (abs(uv.x) < 0.003) col = vec3(0.95, 0.92, 0.86);
  fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}

Why they connect

FFT Ocean (Tessendorf) outputs heightfield, normals and slope textures per cascade every frame. LEADR mapping takes those textures, builds mip chains of slope moments (mean and covariance), and outputs material-params per pixel: the filtered, wind-stretched slope distribution of everything below pixel size. Real-time glints (distributed binomial laws) consumes those material-params as the normal distribution behind its binomial facet counts, so the number of sparkles per footprint and their spread follow the actual sea state, then adds glint radiance on top of the filtered lobe.

How to build it

Unity HDRP or Unreal with a custom water shader. Each frame, after the inverse FFTs, compute slope moments per cascade and build their mips in a compute pass. In the water shader, sum moments across cascades, add the footprint covariance, and use the result both for an anisotropic specular lobe and as the glint model's distribution. Make the glint hash vary in time on the scale of the wave period, so sparkles flicker like water instead of staying pinned to the surface. Fade glint density with distance through the facet-count parameter.

Field marks

  1. Moment mips must be rebuilt every frame for animated waves, adding bandwidth.
  2. Glints pinned to UV space look like glitter paint unless the hash varies in time.
  3. Gaussian slope moments miss foam and breaking crests, which need their own term.
  4. Glint cost is significant on lower-end GPUs.

Prior art

No prior art found on 2026-11-29.

Searches run (4)
  • arXiv: all:"ocean" AND all:"glints" AND all:"rendering" → 0 results
  • GitHub repos: ocean glints rendering → 0 results
  • arXiv: all:"ocean rendering" AND all:"BRDF" AND all:"filtering" → 0 results
  • GitHub repos: "ocean rendering" BRDF filtering → 0 results