home/ atoms/ pixel-manipulation

CPU pixel manipulation reads and writes the raw RGBA array directly, unlike a per-pixel GPU shader

Pixel manipulation reads and writes the raw RGBA pixels[] array directly on the CPU, enabling arbitrary per-pixel operations such as pixel sorting, databending, and non-uniform sampling. It is distinct from a per-pixel shader effect (grain-glitch, pixelate): a shader runs the same GPU-uniform function at every pixel in parallel, whereas CPU pixel manipulation can apply arbitrary, position-dependent, order-dependent logic (e.g. sorting a row by luminance) that a stateless shader cannot express. The tradeoff is that CPU access is far slower than GPU parallelism.

Examples

loadPixels(); then sort each row of pixels[] by brightness for a pixel-sort/databend look; updatePixels() writes the result back — an order-dependent operation a fragment shader cannot do.

Assessment

Contrast CPU pixel manipulation with a per-pixel GPU shader. Give one effect that requires CPU pixel access and explain why a stateless shader cannot produce it.

“**`pixel-manipulation`** — *read/write the raw RGBA `pixels[]` array on the CPU* (sorting, databending, arbitrary sampling). Distinct from a per-pixel shader (`grain-glitch`/`pixelate`): CPU-arbitrary vs GPU-uniform.”
context/ · L2-composer/visual/immediate-mode.md · chunk 1