{
 "id": "ascii-rendering",
 "title": "ASCII / character-cell rendering",
 "aliases": [],
 "domain": "npr",
 "subdomain": "glyph mapping",
 "stage": "post",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "cpu"
 ],
 "year_introduced": null,
 "inputs": [
  "ldr-image",
  "depth"
 ],
 "outputs": [
  "ldr-image"
 ],
 "style": "stylized",
 "dynamic": "dynamic",
 "summary": "Divides the frame into character cells and replaces each with the glyph whose shape best matches the average brightness (and optionally edge direction) of that cell.",
 "how_it_works": "The scene is rendered, then downsampled so each pixel represents one character cell. For each cell, a luminance value picks a glyph from a ramp ordered by ink coverage, for instance a space, a dot, a colon, and a hash. A font atlas texture stores the glyph images, and the final shader samples the atlas using the glyph index and the within-cell coordinates. Better variants compare the cell's shape with each glyph's shape vector and pick the best match, or use edge orientation from a Sobel pass to choose `/`, `|`, `\\`, `-` for contours. Colour can tint the glyph with the cell average.",
 "when_to_use": "Choose it for terminal, hacker or retro aesthetics. Prefer `halftone-screen` or `ordered-dithering-bayer` when you want a fine pattern rather than readable glyphs, and `pixel-art-3d-rendering` for blocky pixel look.",
 "cost": {
  "class": "cheap",
  "notes": "One downsample and one atlas lookup pass; cheap."
 },
 "failure_modes": [
  "Flicker in cells whose brightness hovers near a glyph threshold",
  "Low resolution loses small features entirely",
  "Glyph shape ignored by a brightness-only ramp gives soft, mushy structure",
  "Temporal instability when camera motion shifts content across cell boundaries"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://alexharri.com/blog/ascii-rendering",
   "type": "web",
   "title": "ASCII rendering",
   "authors": [
    "Alex Harri"
   ],
   "year": null,
   "venue": "alexharri.com",
   "url": "https://alexharri.com/blog/ascii-rendering",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261114222502/https://alexharri.com/blog/ascii-rendering",
     "timestamp": "20261114222502"
    },
    "page_title": "ASCII characters are not pixels: a deep dive into ASCII rendering",
    "host": "alexharri.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://alexharri.com/blog/ascii-rendering → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://alexharri.com/blog/ascii-rendering → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://alexharri.com/blog/ascii-rendering → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.95,
   "__bib": "harriascii"
  },
  {
   "role": "implementation",
   "key": "gh:kb173/godot-ascii-shader",
   "type": "code",
   "title": "kb173/godot-ascii-shader",
   "description": "",
   "authors": [
    "kb173"
   ],
   "year": 2020,
   "venue": "GitHub",
   "url": "https://github.com/kb173/godot-ascii-shader",
   "ids": {
    "repo": "kb173/godot-ascii-shader"
   },
   "license": "MIT",
   "extra": {
    "stars": 43,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2024-03-04T19:20:08Z",
    "language": null,
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/kb173/godot-ascii-shader",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/kb173/godot-ascii-shader",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/kb173/godot-ascii-shader",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/kb173/godot-ascii-shader",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/kb173/godot-ascii-shader",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/kb173/godot-ascii-shader",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "kb2020kb173"
  }
 ],
 "presets": [
  {
   "id": "ascii-rendering-specimen",
   "title": "Left: source image. Right: 8px character cells, glyph density chosen from cell brightness",
   "runtime": "glsl-fragment",
   "params": {
    "CELL": 8
   },
   "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));}\nvec3 img(vec2 p){\n  vec3 c=mix(vec3(.12,.18,.34),vec3(.95,.72,.45),clamp(p.y+.5,0.,1.));\n  vec2 q=p-vec2(-.03,.14); float rr=.16; float d=length(q)-rr;\n  vec3 n=normalize(vec3(q/rr,sqrt(max(1.-dot(q,q)/(rr*rr),0.))));\n  float l=clamp(dot(n,normalize(vec3(-.5,.6,.6))),0.,1.);\n  c=mix(c,vec3(.85,.26,.2)*(.18+.9*l),smoothstep(.002,-.002,d));\n  vec2 r=p-vec2(0.,-.2);\n  if(abs(r.x)<.2&&abs(r.y)<.09) c=mix(vec3(.1,.35,.3),vec3(.93,.92,.85),smoothstep(-.3,.3,sin(r.x*340.+r.y*90.)));\n  if(p.y<-.34&&p.y>-.42){ vec3 h=.5+.5*cos(6.2832*((p.x+.25)*2.+vec3(0.,.33,.67))); c=h; }\n  c=mix(c,vec3(.97,.85,.2),smoothstep(.003,-.003,abs(p.x-.17)-.025)*step(.0,p.y)*step(p.y,.4));\n  return c;\n}\n\nconst float CELL=8.0; // P\nfloat glyph(vec2 g,int lv){\n  if(lv==1)return step(length(g-vec2(0.,-.55)),.22);\n  if(lv==2)return max(step(length(g-vec2(0.,-.55)),.22),step(length(g-vec2(0.,.15)),.22));\n  if(lv==3)return step(abs(g.y),.16)*step(abs(g.x),.6);\n  if(lv==4)return max(step(abs(g.y),.14)*step(abs(g.x),.7),step(abs(g.x),.14)*step(abs(g.y),.7));\n  if(lv==5)return max(step(abs(abs(g.x)-.4),.14)*step(abs(g.y),.85),step(abs(abs(g.y)-.35),.14)*step(abs(g.x),.85));\n  if(lv>=6)return step(abs(g.x),.8)*step(abs(g.y),.85)*(1.-.6*step(length(g),.35));\n  return 0.;}\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  vec3 col;\n  if(!R) col=img(q);\n  else{\n    vec2 cc=(floor(fragCoord/CELL)+.5)*CELL,cu=(cc-.5*iResolution.xy)/iResolution.y;\n    float L=lum(img(vec2(cu.x-.25,cu.y)));\n    int lv=int(clamp(floor(L*7.),0.,6.));\n    vec2 g=(fract(fragCoord/CELL)-.5)*2.;\n    col=vec3(.04,.06,.05)+vec3(.45,1.,.6)*glyph(g,lv)*(.55+.45*L);\n  }\n  if(abs(uv.x)<.0015)col=vec3(1.);fragColor=vec4(clamp(col,0.,1.),1.);\n}",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "ascii-rendering",
     "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.3372,
      "std": 0.299,
      "unique_colors": 206
     },
     "image": "/specimens/ascii-rendering-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "halftone-screen",
  "pixel-art-3d-rendering",
  "screen-space-edge-outline"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "screen-space-edge-outline",
   "why": "Edge directions choose line-drawing glyphs along contours."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/npr/ascii-rendering.json"
 },
 "solves": [
  "want my 3d scene drawn with text characters",
  "need a terminal or hacker style look",
  "turn frame brightness into letters and symbols",
  "retro console aesthetic made of glyph cells"
 ],
 "authority": "Harri",
 "url": "https://texelatlas.vercel.app/t/ascii-rendering/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 1.84,
  "tier": "feather",
  "p50_ms": 0.0606,
  "p95_ms": 0.0644,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "ascii-rendering-specimen",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 1.28,
   "tier": "feather",
   "p50_ms": 0.0204,
   "p95_ms": 0.0207,
   "speedup_x": 2.97,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 1.24,
   "tier": "feather",
   "p50_ms": 0.0356,
   "p95_ms": 0.0356,
   "speedup_x": 1.7,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}