mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-02 14:39:41 -06:00
The dark channel is a Gaussian blur, not a patch minimum, so near a bright neighbour it can credit a dark pixel with more veil than its own minimum channel holds; (c - air*(1-t))/t then went negative and was clamped to black - the blotches on CR3 raws. Bound the credited veil by the pixel's own minimum channel (d = min(dark/air_pre, c_min/air)), which provably keeps every channel non-negative for any gain, airlight estimate or windowed fixed_air, in both the CPU and GPU paths. Also zero-guards the divisions, fixing a 0/0 NaN on an all-black frame. Regression test: a uniform dark field beside a bright haze must render uniformly; pre-fix the bleed zone crushed to black. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>