diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-10-10 17:51:08 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-10-10 17:57:28 +0300 |
commit | 8ada6855811b7750fdee829306b908a7472c1315 (patch) | |
tree | 971af341437fcb5f52a4a0d15acf303c583fdee4 /source/blender/nodes/shader | |
parent | eac0f3584545e9e5d9674d2fd9b74c256ce841f3 (diff) |
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.
Diffstat (limited to 'source/blender/nodes/shader')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_geometry.c | 8 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_tex_coord.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c index 54a5411114a..3798cfbbfac 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geometry.c +++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c @@ -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; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c index 068458b7e1f..8bb17acc4d3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c @@ -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; |