{
 "id": "film-grain-synthesis",
 "title": "Film grain synthesis",
 "aliases": [],
 "domain": "post",
 "subdomain": "film look",
 "stage": "post",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cpu",
  "python"
 ],
 "year_introduced": 2017,
 "inputs": [
  "ldr-image",
  "hdr-image"
 ],
 "outputs": [
  "ldr-image"
 ],
 "style": "photoreal",
 "dynamic": "both",
 "summary": "Adds grain from a stochastic model of film grains rather than uniform noise, giving intensity-dependent, resolution-independent texture; real-time shaders approximate it with filtered noise.",
 "how_it_works": "Newson et al. model film as a Boolean process: grains are discs of random radius scattered over the image as a Poisson point process. A pixel's output value is the probability that it is covered by some grain, which is a function of the input intensity. Rendering simulates by Monte Carlo: for each output pixel, a few random points are drawn over a window, grains are placed around the nearest Poisson grid cells, and the covered fraction is counted. Rendering at any resolution is possible because the model is defined in continuous space. Mid-tones get the strongest grain, while shadows and highlights show less, matching real film. Real-time engines substitute luminance-weighted blue-ish noise with a grain size parameter.",
 "when_to_use": "Choose it when you want grain whose size and distribution match a real film stock and survive resolution changes.\n\nPrefer cheap hash noise scaled by luminance for games, and apply it after `chromatic-aberration`. Prefer a full `film-emulation` pipeline if colour behaviour matters, not only texture.",
 "cost": {
  "class": "medium",
  "notes": "The exact Monte Carlo model is heavy; shader approximations are cheap. GPU code exists for the full model."
 },
 "failure_modes": [
  "Animated grain crawls and shimmers if the seed is not changed per frame at film rate",
  "Grain applied before AA or upscaling is smeared or reinforced by the filter",
  "Plain Gaussian noise looks digital and shows in sky gradients as banding structure",
  "Video compression erases fine grain at low bitrates"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.5201/ipol.2017.192",
   "type": "paper",
   "title": "Realistic Film Grain Rendering",
   "authors": [
    "Alasdair Newson",
    "Noura Faraj",
    "Bruno Galerne",
    "Julie Delon"
   ],
   "year": 2017,
   "venue": "Image Processing On Line",
   "url": "https://doi.org/10.5201/ipol.2017.192",
   "ids": {
    "doi": "10.5201/ipol.2017.192"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.5201/ipol.2017.192 (CSL-JSON)",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.5201/ipol.2017.192 (CSL-JSON)",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.5201/ipol.2017.192 (CSL-JSON)",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.5201/ipol.2017.192 (CSL-JSON)",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.5201/ipol.2017.192 (CSL-JSON)",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "newson2017realistic"
  },
  {
   "role": "primary",
   "key": "doi:10.1111/cgf.13159",
   "type": "paper",
   "title": "A Stochastic Film Grain Model for Resolution‐Independent Rendering",
   "authors": [
    "A. Newson",
    "J. Delon",
    "B. Galerne"
   ],
   "year": 2017,
   "venue": "Computer Graphics Forum",
   "url": "https://doi.org/10.1111/cgf.13159",
   "ids": {
    "doi": "10.1111/cgf.13159"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.13159",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.13159",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.13159",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.13159",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.13159",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "newson2017stochastic"
  },
  {
   "role": "implementation",
   "key": "gh:mrdoob/three.js",
   "type": "code",
   "title": "mrdoob/three.js",
   "description": "JavaScript 3D Library.",
   "authors": [
    "mrdoob"
   ],
   "year": 2010,
   "venue": "GitHub",
   "url": "https://github.com/mrdoob/three.js",
   "ids": {
    "repo": "mrdoob/three.js"
   },
   "license": "MIT",
   "extra": {
    "stars": 119718,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-29T11:39:51Z",
    "language": "JavaScript",
    "homepage": "https://threejs.org/",
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "mrdoob2010mrdoob"
  }
 ],
 "presets": [
  {
   "id": "film-grain-synthesis-specimen",
   "title": "A smooth grey ramp. Left: uniform additive noise. Right: correlated grain scaled by an intensity function",
   "runtime": "glsl-fragment",
   "params": {
    "GRAINSZ": 1.6,
    "AMT": 0.55
   },
   "code": "float hash(vec2 c){uvec2 u=uvec2(ivec2(floor(c)));uint h=u.x*1597334673u^u.y*3812015801u;h^=h>>15;h*=2246822519u;h^=h>>13;h*=3266489917u;h^=h>>16;return float(h)*(1./4294967296.);}\nfloat lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}\nvec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}\n\nconst float GRAINSZ=1.6; // P\nconst float AMT=0.55; // P\nfloat vn(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);\n  return mix(mix(hash(i),hash(i+vec2(1.,0.)),f.x),mix(hash(i+vec2(0.,1.)),hash(i+vec2(1.,1.)),f.x),f.y);}\nvoid mainImage(out vec4 fragColor,in vec2 fragCoord){\n  vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;vec2 q=vec2(uv.x+(R?-.25:.25),uv.y);\n  float L=clamp((q.x+.25)/.5,0.,1.);if(uv.y<0.)L=.5;\n  float g=(vn(fragCoord/GRAINSZ+3.)+.5*vn(fragCoord/(GRAINSZ*.5)+9.)-.75)*1.6;\n  float n=hash(fragCoord)-.5;\n  float v=R?L+g*AMT*sqrt(max(L*(1.-L),0.))*.5:L+n*.18;\n  vec3 col=vec3(clamp(v,0.,1.));\n  if(abs(uv.x)<.0015)col=vec3(1.);\n  fragColor=vec4(col,1.);\n}",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "film-grain-synthesis",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5023,
      "std": 0.2104,
      "unique_colors": 32
     },
     "image": "/specimens/film-grain-synthesis-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "chromatic-aberration",
  "film-emulation"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "film-emulation",
   "why": "Grain is the last stage of a film-stock simulation."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/post/film-grain-synthesis.json"
 },
 "solves": [
  "digital image looks too clean and sterile",
  "want grain that resembles a real film stock",
  "uniform noise looks fake and resolution dependent",
  "grain should be stronger in midtones than highlights",
  "match cinematic texture across different output sizes"
 ],
 "authority": "Newson et al., 2017",
 "url": "https://texelatlas.vercel.app/t/film-grain-synthesis/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 2.93,
  "tier": "light",
  "p50_ms": 0.0965,
  "p95_ms": 0.1,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "film-grain-synthesis-specimen",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 2.58,
   "tier": "light",
   "p50_ms": 0.041,
   "p95_ms": 0.041,
   "speedup_x": 2.35,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 1.72,
   "tier": "feather",
   "p50_ms": 0.0494,
   "p95_ms": 0.0495,
   "speedup_x": 1.95,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}