diff options
Diffstat (limited to 'source/blender/nodes')
-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; |