Fix: EEVEE: Overblur of textures because of TAA

This was a missing block of the TAA implementation.
TAA jitter and reprojection have a tedency to soften
the texture. Add a 1.5 bias to make them a bit sharper.

Note that this is a bit different than the usual TAA
blurring. In final render we don't do reprojection
so it is only because the texture filter (box filter
from the LOD) is applied at the same time than our pixel
filter (blackmann-harris). It is less noticeable than
the normal TAA blur, but still blurs ~2px instead of
1.5px.
This commit is contained in:
Clément Foucault
2024-06-18 19:31:39 +02:00
parent 10b1e45ca8
commit ff03ab4d08
4 changed files with 8 additions and 8 deletions

View File

@@ -253,6 +253,8 @@ void Film::init(const int2 &extent, const rcti *output_rect)
data_.scaling_factor = BKE_render_preview_pixel_size(&inst_.scene->r);
}
}
/* Sharpen the LODs (1.5x) to avoid TAA filtering causing over-blur (see #122941). */
data_.texture_lod_bias = 1.0f / (data_.scaling_factor * 1.5f);
}
{
rcti fallback_rect;

View File

@@ -449,13 +449,14 @@ struct FilmData {
float exposure_scale;
/** Scaling factor for scaled resolution rendering. */
int scaling_factor;
/** Software LOD bias to apply to when sampling texture inside the node-tree evaluation. */
float texture_lod_bias;
/** Film pixel filter radius. */
float filter_radius;
/** Precomputed samples. First in the table is the closest one. The rest is unordered. */
int samples_len;
/** Sum of the weights of all samples in the sample table. */
float samples_weight_total;
int _pad1;
int _pad2;
FilmSample samples[FILM_PRECOMP_SAMPLE_MAX];
};

View File

@@ -9,8 +9,6 @@
#pragma BLENDER_REQUIRE(gpu_shader_codegen_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_renderpass_lib.glsl)
#define filmScalingFactor float(uniform_buf.film.scaling_factor)
vec3 g_emission;
vec3 g_transmittance;
float g_holdout;
@@ -713,9 +711,9 @@ vec3 coordinate_incoming(vec3 P)
*
* \{ */
float film_scaling_factor_get()
float texture_lod_bias_get()
{
return float(uniform_buf.film.scaling_factor);
return uniform_buf.film.texture_lod_bias;
}
/** \} */

View File

@@ -57,9 +57,8 @@ void point_map_to_tube(vec3 vin, out vec3 vout)
void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
#ifdef GPU_FRAGMENT_SHADER
vec2 scaling_factor = vec2(film_scaling_factor_get());
vec2 dx = dFdx(co.xy) / scaling_factor;
vec2 dy = dFdy(co.xy) / scaling_factor;
vec2 dx = dFdx(co.xy) * texture_lod_bias_get();
vec2 dy = dFdy(co.xy) * texture_lod_bias_get();
color = safe_color(textureGrad(ima, co.xy, dx, dy));
#else