Files
lightcraft/crates/gpu
stephen schureskoandFredApps 56d1cc2865 pipeline: apply 8x8 ordered Bayer dithering to prevent display banding (#3509)
* pipeline: apply 8x8 ordered Bayer dithering to prevent display banding

Quantizing float linear/display pixel values to 8-bit integers using
round-to-nearest produces noticeable Mach bands and contour stepping on
smooth gradients (skies, shallow depth-of-field backgrounds, skin tones).

This applies an 8x8 ordered Bayer dithering pattern centered around round-to-nearest
with sub-LSB amplitude in both CPU finish (crates/pipeline) and GPU compute
shader (crates/gpu/src/wgsl/finish.wgsl). Exact integer levels, pure black,
and white remain noise-free, while fractional gradients smoothly dissolve into
continuous gradations. Dithering coordinates account for window/tile view offsets
to maintain phase alignment across zoom tiles.

* pipeline, gpu: address review feedback on Bayer dithering

- Always pack VIG_VIEW in GPU params so windowed renders without a vignette
  maintain the correct absolute view origin for Bayer dithering coordinates.
- Restore the full Bayer threshold range (0..1) without deadzones, preserving
  float white via direct half-LSB rounding to prevent edge quantization drop.
- Return the true sampled bounds midpoint in geometry sub-pixel edge detector
  fallbacks.
- Add docstrings to satisfy coverage checks.

* pipeline, gpu: narrow highlight white guard to allow dithering on 254.5

* tests(pipeline): assert edge contrast in manual keystone tracking windows

* docs(pipeline): add docstrings to touched test functions

* Export tests: count distinct levels however the dither orders them

* Mask geometry tests ignore a level of 8-bit dither

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-05 06:47:45 +01:00
..
2026-10-15 03:40:17 -04:00