---
id: "ascii-rendering"
title: "ASCII / character-cell rendering"
domain: "npr"
stage: "post"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, cpu]
inputs: [ldr-image, depth]
outputs: [ldr-image]
style: "stylized"
dynamic: "dynamic"
cost: "cheap"
authority: "Harri"
url: "https://texelatlas.vercel.app/t/ascii-rendering/"
sources_verified_at: "2026-11-29"
---
# ASCII / character-cell rendering (Harri)

> 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.

## Reach for it when

- 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

## 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 it

Choose it for terminal, hacker or retro aesthetics. Prefer [Halftone screens](https://texelatlas.vercel.app/t/halftone-screen.md) or [Ordered dithering with Bayer matrices](https://texelatlas.vercel.app/t/ordered-dithering-bayer.md) when you want a fine pattern rather than readable glyphs, and [Pixel-art 3D rendering](https://texelatlas.vercel.app/t/pixel-art-3d-rendering.md) for blocky pixel look.

## Cost

cheap — One downsample and one atlas lookup pass; cheap.
Measured GPU Weight: 1.84× baseline (feather) — 0.0606 ms median / 0.0644 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 1.28× baseline (feather) — 0.0204 ms median (2.97× faster on L4).
Ampere A100 scaling: 1.24× baseline (feather) — 0.0356 ms median (1.7× faster on A100).

## 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

## Engine support

- babylonjs: official — `new BABYLON.AsciiArtPostProcess('a', camera, {font:'40px Monospace'}) from @babylonjs/post-processes` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/postProcesses/src/asciiArt/asciiArtPostProcess.ts, checked 2026-12-01)
- threejs: official — `import { AsciiEffect } from 'three/addons/effects/AsciiEffect.js'` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/effects/AsciiEffect.js, checked 2026-12-01)

## Dataflow

- Inputs: ldr-image, depth
- Outputs: ldr-image
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, cpu

## Presets

### Left: source image. Right: 8px character cells, glyph density chosen from cell brightness (glsl-fragment; rendered 2026-11-29)

```json
{
  "CELL": 8
}
```

```glsl
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.);}
float lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}
vec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}
vec3 img(vec2 p){
  vec3 c=mix(vec3(.12,.18,.34),vec3(.95,.72,.45),clamp(p.y+.5,0.,1.));
  vec2 q=p-vec2(-.03,.14); float rr=.16; float d=length(q)-rr;
  vec3 n=normalize(vec3(q/rr,sqrt(max(1.-dot(q,q)/(rr*rr),0.))));
  float l=clamp(dot(n,normalize(vec3(-.5,.6,.6))),0.,1.);
  c=mix(c,vec3(.85,.26,.2)*(.18+.9*l),smoothstep(.002,-.002,d));
  vec2 r=p-vec2(0.,-.2);
  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.)));
  if(p.y<-.34&&p.y>-.42){ vec3 h=.5+.5*cos(6.2832*((p.x+.25)*2.+vec3(0.,.33,.67))); c=h; }
  c=mix(c,vec3(.97,.85,.2),smoothstep(.003,-.003,abs(p.x-.17)-.025)*step(.0,p.y)*step(p.y,.4));
  return c;
}

const float CELL=8.0; // P
float glyph(vec2 g,int lv){
  if(lv==1)return step(length(g-vec2(0.,-.55)),.22);
  if(lv==2)return max(step(length(g-vec2(0.,-.55)),.22),step(length(g-vec2(0.,.15)),.22));
  if(lv==3)return step(abs(g.y),.16)*step(abs(g.x),.6);
  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));
  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));
  if(lv>=6)return step(abs(g.x),.8)*step(abs(g.y),.85)*(1.-.6*step(length(g),.35));
  return 0.;}
void mainImage(out vec4 fragColor,in vec2 fragCoord){
  vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;vec2 q=vec2(uv.x+(R?-.25:.25),uv.y);
  vec3 col;
  if(!R) col=img(q);
  else{
    vec2 cc=(floor(fragCoord/CELL)+.5)*CELL,cu=(cc-.5*iResolution.xy)/iResolution.y;
    float L=lum(img(vec2(cu.x-.25,cu.y)));
    int lv=int(clamp(floor(L*7.),0.,6.));
    vec2 g=(fract(fragCoord/CELL)-.5)*2.;
    col=vec3(.04,.06,.05)+vec3(.45,1.,.6)*glyph(g,lv)*(.55+.45*L);
  }
  if(abs(uv.x)<.0015)col=vec3(1.);fragColor=vec4(clamp(col,0.,1.),1.);
}
```

Attribution: written for this index

## Combines with

- [Depth/normal Sobel edge outlines](https://texelatlas.vercel.app/t/screen-space-edge-outline.md): Edge directions choose line-drawing glyphs along contours.

## Sources

1. [primary] Alex Harri ASCII rendering. alexharri.com. https://alexharri.com/blog/ascii-rendering (verified via http on 2026-11-29)
2. [implementation] kb173 (2020) kb173/godot-ascii-shader. https://github.com/kb173/godot-ascii-shader License: MIT. (verified via github on 2026-11-29)

## Cite this entry

Texel. "ASCII / character-cell rendering." https://texelatlas.vercel.app/t/ascii-rendering/ (accessed 2026-12-01).
