{
 "id": "small-angle-underwater-psf-scattering",
 "title": "Multi-Lobe Small-Angle Forward-Scattering Optical PSF Convolution",
 "aliases": [
  "underwater optical PSF",
  "small-angle forward scattering glow",
  "Wells-Jaffe underwater scattering"
 ],
 "domain": "volumes",
 "subdomain": "underwater optics & participating media",
 "stage": "volume",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal"
 ],
 "year_introduced": 1969,
 "inputs": [
  "hdr-image",
  "depth",
  "volume-density"
 ],
 "outputs": [
  "hdr-image"
 ],
 "style": "photoreal",
 "dynamic": "dynamic",
 "summary": "Models underwater image blur and luminous halation by convolving the HDR scene with a depth-dependent multi-lobe point spread function derived from small-angle forward scattering theory.",
 "how_it_works": "Underwater visibility degrades through three distinct radiative components (Jaffe 1990): exponentially attenuated direct radiance, ambient **backscatter** veiling light, and **small-angle forward scattering** of light leaving scene surfaces toward the camera. Because suspended marine particulates scatter strongly in the forward direction, photons deflected by small angles still reach nearby camera pixels, blurring distant edges and wrapping bright highlights in soft turquoise-gold haloes.\n\nFollowing **Wells' small-angle approximation**, the medium's optical transfer function decays exponentially with optical depth `b * z` and spatial frequency, yielding a radial **point spread function (PSF)** whose width grows with range `z` and scattering coefficient `b`. Because a real-time spatially varying convolution over arbitrary radii is expensive, the PSF is decomposed into a **weighted sum of concentric Gaussian lobes** (narrow core plus progressively wider forward-scatter tails) evaluated on a hierarchical HDR mip pyramid.\n\nDuring compositing, each pixel blends the sharp direct image with depth-weighted taps across pyramid levels—rejecting foreground bleed with bilateral depth weights—while applying wavelength-selective Beer-Lambert absorption (red fading first, then green, leaving blue-cyan) and in-scattered ambient veiling light.",
 "when_to_use": "Choose it when rendering submerged scenes, kelp forests, reefs, or underwater ROV/camera optics where realistic range-dependent contrast loss and forward-scattered light haloes matter more than simple uniform fog.\n\nPrefer [exponential-height-fog](exponential-height-fog) when cheap distance tinting alone is sufficient and edge blurring is unnecessary. Prefer [froxel-volumetric-fog](froxel-volumetric-fog) or [volume-ray-marching](volume-ray-marching) when heterogeneous light shafts, local spotlights, and shadowed 3D turbidity plumes dominate over image-space forward blur.",
 "cost": {
  "class": "cheap",
  "notes": "Separable downsample/upsample pyramid passes plus depth-weighted multi-lobe compositing run well under 1 ms at 1080p on mid-range desktop GPUs."
 },
 "failure_modes": [
  "Without bilateral depth weighting, bright foreground objects bleed halo energy onto dark backgrounds and distant bright highlights leak across sharp foreground silhouettes",
  "Screen-space convolution cannot scatter light from bright submerged objects or sunbeams located just outside the camera frustum",
  "Approximating the continuous range-dependent Wells PSF with too few discrete pyramid lobes creates visible depth banding across steep turbidity gradients",
  "Ignoring spectral absorption coupling causes forward-scattered haloes to keep unnaturally warm red tones at long distances"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1364/josa.59.000686",
   "type": "paper",
   "title": "Loss of Resolution in Water as a Result of Multiple Small-Angle Scattering",
   "authors": [
    "Willard H. Wells"
   ],
   "year": 1969,
   "venue": "Journal of the Optical Society of America",
   "url": "https://doi.org/10.1364/josa.59.000686",
   "ids": {
    "doi": "10.1364/josa.59.000686"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1364/josa.59.000686 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1364/josa.59.000686 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1364/josa.59.000686 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1364/josa.59.000686 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1364/josa.59.000686 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": 1,
   "__bib": "wells1969loss"
  },
  {
   "role": "primary",
   "key": "doi:10.1109/48.50695",
   "type": "paper",
   "title": "Computer modeling and the design of optimal underwater imaging systems",
   "authors": [
    "J.S. Jaffe"
   ],
   "year": 1990,
   "venue": "IEEE Journal of Oceanic Engineering",
   "url": "https://doi.org/10.1109/48.50695",
   "ids": {
    "doi": "10.1109/48.50695"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/48.50695",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/48.50695",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/48.50695",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/48.50695",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/48.50695",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": 1,
   "__bib": "jaffe1990computer"
  },
  {
   "role": "implementation",
   "key": "gh:mrdoob/codevember-2026",
   "type": "code",
   "title": "mrdoob/codevember-2026",
   "description": "Daily creative agentic coding experiments for November 2026.",
   "authors": [
    "mrdoob"
   ],
   "year": 2026,
   "venue": "GitHub",
   "url": "https://github.com/mrdoob/codevember-2026",
   "ids": {
    "repo": "mrdoob/codevember-2026"
   },
   "license": "MIT",
   "extra": {
    "stars": 102,
    "stars_checked": "2026-11-30",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-27T06:32:02Z",
    "language": "JavaScript",
    "homepage": "https://mrdoob.github.io/codevember-2026/",
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": null,
   "__bib": "mrdoob2026mrdoob"
  }
 ],
 "presets": [
  {
   "id": "small-angle-underwater-psf-scattering-live",
   "title": "Underwater Small-Angle PSF Scattering — Beer-Lambert only (left) vs depth-dependent multi-lobe optical PSF halation (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_TURBIDITY": 0.72,
    "P_PSF_WIDTH": 1.15,
    "P_LAMP_POWER": 1.65,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_TURBIDITY = 0.72; // P Water Turbidity [0.2, 1.6, 0.05]\nconst float P_PSF_WIDTH = 1.15; // P Forward PSF Spread [0.3, 2.2, 0.05]\nconst float P_LAMP_POWER = 1.65; // P Beacon Power [0.5, 3.0, 0.1]\nconst float P_SPLIT = 0.48; // P Sharp / PSF Split [0.0, 1.0, 0.02]\n\n// Evaluate crisp HDR underwater scene (coral archway + 3 glowing diver beacon lamps at near, mid, and far depths!)\nvoid evalUnderwaterScene(vec2 uv, float turb, float lampPow, out vec3 hdrCol, out float depthZ) {\n  // Deep ocean vertical caustic & veil gradient\n  float caustic = 0.5 + 0.5 * sin(uv.x * 16.0 + iTime * 1.4) * cos(uv.y * 12.0 - iTime * 1.1);\n  vec3 waterBg = mix(vec3(0.015, 0.09, 0.16), vec3(0.04, 0.28, 0.38), smoothstep(-0.5, 0.5, uv.y));\n  waterBg += vec3(0.03, 0.14, 0.18) * caustic * smoothstep(-0.1, 0.5, uv.y);\n\n  hdrCol = waterBg;\n  depthZ = 18.0;\n\n  // Seabed floor receding into distance\n  if (uv.y < -0.14) {\n    float z = 1.6 / max(-uv.y - 0.10, 0.04);\n    depthZ = min(z, 18.0);\n    float sandC = 0.5 + 0.5 * sin(uv.x * z * 4.5 + iTime * 1.6) * cos(z * 3.2 - iTime * 1.2);\n    vec3 sand = vec3(0.16, 0.24, 0.22) * (0.7 + 0.65 * sandC);\n    vec3 atten = exp(-vec3(0.45, 0.16, 0.11) * depthZ * turb * 0.45);\n    hdrCol = mix(waterBg, sand * atten, exp(-depthZ * turb * 0.08));\n  }\n\n  // Silhouetted sunken stone archway at mid depth (z = 7.5m)\n  vec2 ap = uv - vec2(0.0, -0.02);\n  float dArch = abs(length(ap * vec2(1.0, 1.15)) - 0.34) - 0.075;\n  if (dArch < 0.0 && ap.y > -0.28) {\n    depthZ = 7.5;\n    vec3 stone = vec3(0.06, 0.13, 0.16);\n    hdrCol = mix(waterBg, stone, exp(-depthZ * turb * 0.08));\n  }\n\n  // Three bright underwater beacon lamps at increasing depths: Near (z=2.5m), Mid (z=7.2m), Far (z=13.5m)!\n  vec2 lPos[3];\n  float lDepth[3];\n  vec3 lHue[3];\n  lPos[0] = vec2(-0.42 + 0.05 * sin(iTime * 0.7), -0.16); lDepth[0] = 2.6;  lHue[0] = vec3(2.8, 2.2, 1.2);\n  lPos[1] = vec2(0.02 + 0.04 * cos(iTime * 0.6), 0.12);   lDepth[1] = 7.2;  lHue[1] = vec3(1.1, 2.8, 2.4);\n  lPos[2] = vec2(0.42 + 0.04 * sin(iTime * 0.5), 0.04);   lDepth[2] = 13.5; lHue[2] = vec3(2.8, 1.3, 0.7);\n\n  for (int i = 0; i < 3; i++) {\n    float r = length(uv - lPos[i]);\n    float rad = 0.048 / sqrt(lDepth[i] * 0.35);\n    if (r < rad * 1.4) {\n      depthZ = min(depthZ, lDepth[i]);\n      float core = smoothstep(rad * 1.35, rad * 0.35, r);\n      vec3 atten = exp(-vec3(0.32, 0.11, 0.08) * lDepth[i] * turb * 0.32);\n      hdrCol += lHue[i] * atten * core * lampPow * 2.6;\n    }\n  }\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 usePSF = sx >= split;\n\n  float turb = clamp(P_TURBIDITY, 0.15, 2.0);\n  float psfW = clamp(P_PSF_WIDTH, 0.2, 2.5);\n  float lampPow = clamp(P_LAMP_POWER, 0.3, 3.5);\n\n  vec3 col;\n  float z;\n  evalUnderwaterScene(uv, turb, lampPow, col, z);\n\n  if (usePSF) {\n    // Right: Multi-lobe Small-Angle Forward-Scattering Optical PSF convolution (depth-dependent narrow + wide Gaussian lobes!)\n    vec2 lPos[3];\n    float lDepth[3];\n    vec3 lHue[3];\n    lPos[0] = vec2(-0.42 + 0.05 * sin(iTime * 0.7), -0.16); lDepth[0] = 2.6;  lHue[0] = vec3(2.8, 2.2, 1.2);\n    lPos[1] = vec2(0.02 + 0.04 * cos(iTime * 0.6), 0.12);   lDepth[1] = 7.2;  lHue[1] = vec3(1.1, 2.8, 2.4);\n    lPos[2] = vec2(0.42 + 0.04 * sin(iTime * 0.5), 0.04);   lDepth[2] = 13.5; lHue[2] = vec3(2.8, 1.3, 0.7);\n\n    // Subtle spatial small-angle PSF blur on background archway & seabed proportional to optical depth\n    vec3 blurAcc = col * 0.45;\n    float blurRad = clamp(z * turb * 0.0018 * psfW, 0.001, 0.028);\n    for (int k = 0; k < 6; k++) {\n      float ang = float(k) * 1.0471975;\n      vec3 cN; float zN;\n      evalUnderwaterScene(uv + vec2(cos(ang), sin(ang)) * blurRad, turb, lampPow, cN, zN);\n      blurAcc += cN * (0.55 / 6.0);\n    }\n    col = blurAcc;\n\n    // Analytical multi-lobe small-angle forward-scattering PSF halation around each underwater emitter:\n    // Lobe 1 (tight core), Lobe 2 (mid forward-scatter glow), Lobe 3 (broad multiple-scatter aureole)\n    // Spread grows with optical depth tau = turb * depth!\n    for (int i = 0; i < 3; i++) {\n      float r = length(uv - lPos[i]);\n      float tau = lDepth[i] * turb * 0.12;\n      float s1 = max(0.015 + 0.025 * tau * psfW, 0.01);\n      float s2 = max(0.045 + 0.085 * tau * psfW, 0.02);\n      float s3 = max(0.110 + 0.180 * tau * psfW, 0.05);\n\n      float psf = 0.55 * exp(-r * r / (2.0 * s1 * s1))\n                + 0.32 * exp(-r * r / (2.0 * s2 * s2))\n                + 0.16 * exp(-r / s3);\n      vec3 atten = exp(-vec3(0.32, 0.11, 0.08) * lDepth[i] * turb * 0.28);\n      // Forward scatter grows in relative energy as optical depth increases!\n      float scatFrac = 1.0 - exp(-tau * 1.85);\n      col += lHue[i] * atten * psf * scatFrac * lampPow * 0.88;\n    }\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": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "small-angle-underwater-psf-scattering",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:25.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6398,
      "std": 0.159,
      "min": 0.3524,
      "max": 0.9994
     },
     "image": "/specimens/small-angle-underwater-psf-scattering-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "henyey-greenstein-phase-function",
  "dual-filter-bloom",
  "froxel-volumetric-fog",
  "multiple-scattering-octaves",
  "volumetric-light-scattering-god-rays"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "dual-filter-bloom",
   "why": "Provides fast hierarchical downsample/upsample mip levels whose radii map directly onto the concentric underwater PSF lobes."
  },
  {
   "id": "volumetric-light-scattering-god-rays",
   "why": "Supplies directional sun shafts and backscatter veiling light that complement the forward-scattered image blur."
  }
 ],
 "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/small-angle-underwater-psf-scattering.json"
 },
 "solves": [
  "exponential underwater fog looks flat and misses bright silhouette halation",
  "need realistic turbid water blur that grows with optical distance",
  "simulate forward scattering glow around underwater sunbeams and lights",
  "distant reef and kelp outlines stay unrealistically crisp in murky water",
  "apply physically grounded underwater point spread filtering in post"
 ],
 "authority": "Wells, 1969",
 "url": "https://texelatlas.vercel.app/t/small-angle-underwater-psf-scattering/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 8.69,
  "tier": "moderate",
  "p50_ms": 0.2859,
  "p95_ms": 0.2879,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "small-angle-underwater-psf-scattering-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 7.12,
   "tier": "moderate",
   "p50_ms": 0.1132,
   "p95_ms": 0.1138,
   "speedup_x": 2.53,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 6.05,
   "tier": "moderate",
   "p50_ms": 0.1742,
   "p95_ms": 0.1748,
   "speedup_x": 1.64,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}