ascii-dither-halftone
ASCII Art, Dithering & Halftone
When to use this
- You want to render a photo, video feed, or 3D scene as ASCII characters in real time.
- You need dithering to reduce an image to fewer colors (1-bit, 2-bit) with minimal banding.
- The design calls for a halftone dot-screen effect (print/newspaper aesthetic).
- You are building a retro terminal aesthetic, glitch art, or data-visualization with character density.
- Do NOT use this for grain/noise texture overlays -- see
noise-grain-textureinstead. These techniques change the fundamental rendering, not just overlay texture.
Mental model
All three techniques solve the same underlying problem: representing continuous tones with a limited set of discrete values.
ASCII rendering: Map each block of pixels (e.g. 8x8) to a single character chosen from a brightness ramp. Dark areas get dense characters (@, #), light areas get sparse ones (., ). The character grid replaces the pixel grid. Resolution is determined by character cell size, not pixel count.
Dithering: Distribute quantization error spatially so the eye perceives intermediate tones from a pattern of only two values (black and white). Ordered dithering (Bayer matrix) uses a fixed threshold pattern -- each pixel is compared against a position-dependent threshold. This creates a regular, structured pattern. Error diffusion (Floyd-Steinberg) pushes each pixel's rounding error to neighboring pixels, creating a more organic, irregular pattern.
Halftone: A specific type of ordered dithering that mimics the print process. Continuous tones become circles of varying size arranged on a grid. Darker areas get larger dots. The dot screen angle and frequency define the look. CMYK halftone uses four rotated screens, one per ink channel.
For real-time (video, webcam), these run as fragment shaders. The shader samples the source texture, computes brightness, and applies the threshold/character/dot logic per pixel. CPU implementations work for static images but cannot sustain 60fps on video-resolution sources.