27constexpr float MAX_LOG = 10.0f;
34constexpr int binOf(
float log2Luminance) {
35 if (!(log2Luminance >
MIN_LOG))
return 0;
36 if (!(log2Luminance < MAX_LOG))
return BINS - 1;
37 const int bin = 1 +
static_cast<int>((log2Luminance -
MIN_LOG) /
BIN_STEP);
38 return bin <
BINS - 1 ? bin :
BINS - 1;
52constexpr float KEY = 0.09f;
87 Adaptation() =
default;
88 ~Adaptation() =
default;
90 Adaptation(
const Adaptation& other) =
default;
91 Adaptation& operator=(
const Adaptation& other) =
default;
93 Adaptation(Adaptation && other) =
default;
94 Adaptation& operator=(Adaptation && other) =
default;
112 float m_target = 0.0f;
113 float m_stops = 0.0f;
114 bool m_adapted =
false;
float update(const uint32_t *newest, float seconds, const RenderSettings &settings)
The stops this frame is exposed by, RenderSettings::exposure included.
void forget()
Take the next read whole, as for a replaced world; the stops hold until it comes.
Definition exposure.h:109
How auto-exposure (RenderSettings::autoExposure) measures a frame and adapts to it.
Definition exposure.h:16
constexpr int binOf(float log2Luminance)
The bin a pixel of log2 luminance log2Luminance counts in.
Definition exposure.h:34
constexpr float HIGH_SHARE
The share past which the brightest is left out: the sun and its glints do not either.
Definition exposure.h:49
constexpr float binCentre(int bin)
The log2 luminance at the middle of bin, one past the first.
Definition exposure.h:42
constexpr int STRIDE
A backend counts a pixel every STRIDE each way.
Definition exposure.h:31
std::optional< float > targetStops(const uint32_t *bins, const RenderSettings &settings)
The stops that bring a histogram's average to KEY, within the settings' range.
constexpr float BIN_STEP
The log2 luminance one bin spans.
Definition exposure.h:29
constexpr float KEY
Where the average lands before RenderSettings::exposure is added.
Definition exposure.h:52
constexpr int BINS
Histogram bins, laid out by binOf (which a backend's counting mirrors).
Definition exposure.h:24
constexpr float LOW_SHARE
The darkest share of what is lit, left out of the average: shade does not set the exposure.
Definition exposure.h:47
float adaptStops(float current, float target, float seconds, const RenderSettings &settings)
current moved toward target over seconds, as an eye adapts.
constexpr float MIN_LOG
log2 luminance at the floor of the second bin, and at the ceiling of the last.
Definition exposure.h:26
Editable render tuning: pass toggles + per-effect parameters.
Definition render_settings.h:101