80 static constexpr float min_log_lum = -10.0f;
81 static constexpr float max_log_lum = 20.0f;
82 static constexpr int histogram_bins = 256;
86 static constexpr std::uint32_t max_metering_dim = 512;
101 cache_uniform(program.get(), s_hdr_input,
"s_hdr_input", gfx::uniform_type::Sampler);
102 cache_uniform(program.get(), u_histogram_params,
"u_histogram_params", gfx::uniform_type::Vec4);
103 cache_uniform(program.get(), u_metering_params,
"u_metering_params", gfx::uniform_type::Vec4);
105 } histogram_program_;
107 struct average_program : uniforms_cache
114 void cache_uniforms()
116 cache_uniform(program.get(), u_average_params0,
"u_average_params0", gfx::uniform_type::Vec4);
117 cache_uniform(program.get(), u_average_params1,
"u_average_params1", gfx::uniform_type::Vec4);
118 cache_uniform(program.get(), u_average_params2,
"u_average_params2", gfx::uniform_type::Vec4);
122 bgfx::DynamicIndexBufferHandle histogram_buffer_ = BGFX_INVALID_HANDLE;
std::shared_ptr< frame_buffer > ptr
auto shutdown() -> int32_t
auto init(rtti::context &ctx) -> bool
void run(gfx::render_view &rview, const run_params ¶ms)
Runs histogram + temporal average to produce a 1x1 adapted exposure texture.
auto_exposure_pass()=default
void release_resources(gfx::render_view &rview)
auto get_exposure_texture(gfx::render_view &rview) const -> gfx::texture::ptr
std::shared_ptr< gpu_program > ptr
exposure_metering_mode
Spatial weighting applied to pixels when building the luminance histogram.
@ center_weighted
Smooth radial falloff toward the screen edges (Gaussian). Default.
std::shared_ptr< uniform > uniform_ptr
gfx::frame_buffer::ptr input
float adaptation_speed_up
float high_percentile
Upper fraction kept before excluding the brightest (weighted) pixels.
float low_percentile
Fraction of the darkest (weighted) pixels excluded from the average.
exposure_metering_mode metering_mode
How pixels are spatially weighted when metering scene luminance.
float adaptation_speed_down
Time constant in seconds for the exposure to DECREASE (scene getting brighter).
float compensation
Exposure bias in EV stops applied on top of the metered result (+1 = 2x brighter).