Expand description
Auto-exposure: the tunables the post-process config resolves into, the luminance histogram the backends measure a frame with, and the running EMA that turns that measurement into the next frame’s exposure.
Structs§
- Auto
Exposure Settings - Clamped auto-exposure tunables resolved from the authored asset fields. Held
by the backend; the per-frame EMA in
AutoExposureState::updatereads them to clamp the adapted EV and drive its adaptation rate. - Auto
Exposure State - Running auto-exposure state. The current adapted EV moves toward the target EV (derived from the GPU-measured average log-luminance) via an exponential moving average so a sudden brightness change ramps in over a fraction of a second rather than snapping. One instance lives on each backend that runs auto-exposure.
Constants§
- HDR_
MIDDLE_ GREY_ LOG2 log2(0.18): perceptual middle-grey in linear light. AE shifts the scene’s geometric-mean luminance to this value on the HDR output path so the average pixel reads as a comfortable mid-tone instead of “scene white = SDR reference white = bright” (which only worked on the SDR path because the ACES tonemap implicitly compressed scene-white back down).- HISTOGRAM_
BINS - Number of histogram bins the build kernel writes into and the average kernel reduces. 256 is small enough to fit in threadgroup memory on every Apple GPU (1 KiB at u32) and big enough that the per-bin log-luminance step is fine.
- LUM_
LOG2_ MAX - Highest log2(luminance) the histogram bins span. Pixels brighter than this
fall in the last bin. Roughly matches a direct sun reflection at the bright
end. The shader uses
(LUM_LOG2_MAX - LUM_LOG2_MIN)to convert a bin index back to a log-luminance value during the average pass. - LUM_
LOG2_ MIN - Lowest log2(luminance) the histogram bins span. Pixels darker than this fall in bin 0. Roughly matches a moonlit interior at the dim end.