Fix T70644 EEVEE: Bump issue with geometry node normal coordinate

Was caused by non-normalized coordinates (normals). Note this is not 100%
correct as the dFdx functions can be the same for packs of 4 pixels and the
derivated value can only be correct for one pixels.

This is because smoothed normals are a non-linear function (because of the
normalization).

The correct fix would be to do the dFdx offset BEFORE any normalization.
This commit is contained in:
Clément Foucault 2019-10-10 16:51:08 +02:00
parent eac0f35845
commit 8ada685581
Notes: blender-bot 2023-02-14 00:32:43 +01:00
Referenced by issue #70644, Eevee refractions don't work anymore
2 changed files with 16 additions and 0 deletions

View File

@ -62,6 +62,14 @@ static int node_shader_gpu_geometry(GPUMaterial *mat,
/* for each output */
for (int i = 0; sh_node_geometry_out[i].type != -1; i++) {
node_shader_gpu_bump_tex_coord(mat, node, &out[i].link);
/* Normalize some vectors after dFdx/dFdy offsets.
* This is the case for interpolated, non linear functions.
* The resulting vector can still be a bit wrong but not as much.
* (see T70644) */
if (node->branch_tag != 0 && ELEM(i, 1, 2, 4)) {
GPU_link(
mat, "vector_math_normalize", out[i].link, out[i].link, out[i].link, &out[i].link, NULL);
}
}
return success;

View File

@ -63,6 +63,14 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat,
/* for each output. */
for (int i = 0; sh_node_tex_coord_out[i].type != -1; i++) {
node_shader_gpu_bump_tex_coord(mat, node, &out[i].link);
/* Normalize some vectors after dFdx/dFdy offsets.
* This is the case for interpolated, non linear functions.
* The resulting vector can still be a bit wrong but not as much.
* (see T70644) */
if (node->branch_tag != 0 && ELEM(i, 1, 6)) {
GPU_link(
mat, "vector_math_normalize", out[i].link, out[i].link, out[i].link, &out[i].link, NULL);
}
}
return 1;