Fix: EEVEE: Imprecision in HiZ gather coordinates

The offset was only 0.5 which centered the gather
sample exactly on the first pixel of the quad.
With floating point arithmetic differences on Nvidia
this lead to the wrong set of texture pixel being
fetched by gather.

Using the coordinate at the center of the quad fixes
the issue.

Fix #123262
This commit is contained in:
Clément Foucault
2024-06-20 13:06:26 +02:00
parent b76a95b8b4
commit ab0e6386fc

View File

@@ -45,10 +45,10 @@ void main()
/* Copy level 0. */
ivec2 src_px = ivec2(kernel_origin + local_px) * 2;
#ifdef HIZ_LAYER
vec2 samp_co = (vec2(src_px) + 0.5) / vec2(textureSize(depth_layered_tx, 0).xy);
vec2 samp_co = vec2(src_px + 1) / vec2(textureSize(depth_layered_tx, 0).xy);
vec4 samp = textureGather(depth_layered_tx, vec3(samp_co, float(layer_id)));
#else
vec2 samp_co = (vec2(src_px) + 0.5) / vec2(textureSize(depth_tx, 0));
vec2 samp_co = vec2(src_px + 1) / vec2(textureSize(depth_tx, 0));
vec4 samp = textureGather(depth_tx, samp_co);
#endif