EEVEE-Next: Add exposure awareness to denoising

This uses the exposure to get a better approximation of the perceptual
brighness of a sample before accumulating it.

Note that we do not modify exposure of the image. Only the samples weights
are computed differently.
This commit is contained in:
Clément Foucault 2022-07-22 21:03:06 +02:00
parent 676a2f690c
commit 7d8b651268
3 changed files with 8 additions and 10 deletions

View File

@ -164,6 +164,8 @@ inline bool operator!=(const FilmData &a, const FilmData &b)
void Film::init(const int2 &extent, const rcti *output_rect)
{
Sampling &sampling = inst_.sampling;
Scene &scene = *inst_.scene;
SceneEEVEE &scene_eevee = scene.eevee;
init_aovs();
@ -230,9 +232,8 @@ void Film::init(const int2 &extent, const rcti *output_rect)
data.offset = int2(output_rect->xmin, output_rect->ymin);
data.extent_inv = 1.0f / float2(data.extent);
/* Disable filtering if sample count is 1. */
data.filter_size = (sampling.sample_count() == 1) ?
0.0f :
clamp_f(inst_.scene->r.gauss, 0.0f, 100.0f);
data.filter_size = (sampling.sample_count() == 1) ? 0.0f :
clamp_f(scene.r.gauss, 0.0f, 100.0f);
/* TODO(fclem): parameter hidden in experimental.
* We need to figure out LOD bias first in order to preserve texture crispiness. */
data.scaling_factor = 1;
@ -254,7 +255,7 @@ void Film::init(const int2 &extent, const rcti *output_rect)
EEVEE_RENDER_PASS_MIST |
EEVEE_RENDER_PASS_SHADOW | EEVEE_RENDER_PASS_AO;
data_.exposure = 1.0f /* TODO */;
data_.exposure_scale = pow2f(scene.view_settings.exposure);
data_.has_data = (enabled_passes_ & data_passes) != 0;
data_.any_render_pass_1 = (enabled_passes_ & color_passes_1) != 0;
data_.any_render_pass_2 = (enabled_passes_ & color_passes_2) != 0;
@ -346,7 +347,7 @@ void Film::init(const int2 &extent, const rcti *output_rect)
}
}
force_disable_reprojection_ = (inst_.scene->eevee.flag & SCE_EEVEE_TAA_REPROJECTION) == 0;
force_disable_reprojection_ = (scene_eevee.flag & SCE_EEVEE_TAA_REPROJECTION) == 0;
}
void Film::sync()

View File

@ -202,7 +202,7 @@ struct FilmData {
/** Settings to render mist pass */
float mist_scale, mist_bias, mist_exponent;
/** Scene exposure used for better noise reduction. */
float exposure;
float exposure_scale;
/** Scaling factor for scaled resolution rendering. */
int scaling_factor;
/** Film pixel filter radius. */

View File

@ -48,8 +48,6 @@ vec3 film_scene_linear_from_YCoCg(vec3 ycocg_color)
vec4 film_texelfetch_as_YCoCg_opacity(sampler2D tx, ivec2 texel)
{
vec4 color = texelFetch(combined_tx, texel, 0);
/* Can we assume safe color from earlier pass? */
// color = safe_color(color);
/* Convert transmittance to opacity. */
color.a = saturate(1.0 - color.a);
/* Transform to YCoCg for accumulation. */
@ -62,8 +60,7 @@ float film_luma_weight(float luma)
{
/* Slide 20 of "High Quality Temporal Supersampling" by Brian Karis at Siggraph 2014. */
/* To preserve more details in dark areas, we use a bigger bias. */
/* TODO(fclem): exposure weighting. */
return 1.0 / (4.0 + luma);
return 1.0 / (4.0 + luma * film_buf.exposure_scale);
}
/* -------------------------------------------------------------------- */