[Bf-blender-cvs] [8ada6855811] master: Fix T70644 EEVEE: Bump issue with geometry node normal coordinate
Clément Foucault
noreply at git.blender.org
Thu Oct 10 16:57:40 CEST 2019
Commit: 8ada6855811b7750fdee829306b908a7472c1315
Author: Clément Foucault
Date: Thu Oct 10 16:51:08 2019 +0200
Branches: master
https://developer.blender.org/rB8ada6855811b7750fdee829306b908a7472c1315
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.
===================================================================
M source/blender/nodes/shader/nodes/node_shader_geometry.c
M source/blender/nodes/shader/nodes/node_shader_tex_coord.c
===================================================================
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;
More information about the Bf-blender-cvs
mailing list