diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-07-22 22:03:06 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-07-22 22:03:06 +0300 |
commit | 7d8b651268df74157f89858eda9ddce9fd452138 (patch) | |
tree | 54321b498337bdd32248aea2f6a708019d6838cd /source/blender/draw/engines/eevee_next | |
parent | 676a2f690c3e3fffe2e515208d4d308e0a96e8e6 (diff) |
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.
Diffstat (limited to 'source/blender/draw/engines/eevee_next')
3 files changed, 8 insertions, 10 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index 486413a0834..42c61ac90a8 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -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() diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh index 9cf7f75b2c3..819f49756d7 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh +++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh @@ -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. */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl index 451b8e8fca7..efd3d2dfe35 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl @@ -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); } /* -------------------------------------------------------------------- */ |