Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-05-09 00:21:09 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-09 00:28:06 +0300
commit7ec7888ff384adccfaca2777c021b40dd726fa8d (patch)
treeee99e9ce2bd72ebb33ce966d6c4e762c25c473f5 /source/blender/nodes
parentc9537ee5c3f58105f553a32f337f7c5d1be8b1a4 (diff)
Eevee: Fix Tangent vectors using NormalMatrix and make them world space
Making them world space by default remove a lot of legacy conversion from viewspace.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c31
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c13
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_displacement.c2
4 files changed, 11 insertions, 38 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index 37c35c0adc8..72852d28744 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -114,10 +114,9 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
GPU_link(mat, "tangent_orco_z", orco, &in[19].link);
GPU_link(mat,
"node_tangent",
- GPU_builtin(GPU_VIEW_NORMAL),
+ GPU_builtin(GPU_WORLD_NORMAL),
in[19].link,
GPU_builtin(GPU_OBJECT_MATRIX),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
&in[19].link);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
index d769a219fa0..4976d038065 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -84,52 +84,33 @@ static int gpu_shader_normal_map(GPUMaterial *mat,
realnorm = GPU_constant(in[1].vec);
}
- negnorm = GPU_builtin(GPU_VIEW_NORMAL);
+ negnorm = GPU_builtin(GPU_WORLD_NORMAL);
GPU_link(mat, "math_max", strength, GPU_constant(d), &strength);
const char *color_to_normal_fnc_name = "color_to_normal_new_shading";
if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD) {
color_to_normal_fnc_name = "color_to_blender_normal_new_shading";
}
+
+ GPU_link(mat, color_to_normal_fnc_name, realnorm, &realnorm);
switch (nm->space) {
case SHD_SPACE_TANGENT:
- GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm);
GPU_link(mat,
"node_normal_map",
GPU_builtin(GPU_OBJECT_INFO),
GPU_attribute(CD_TANGENT, nm->uv_map),
- negnorm,
+ GPU_builtin(GPU_WORLD_NORMAL),
realnorm,
&realnorm);
- GPU_link(
- mat, "vec_math_mix", strength, realnorm, GPU_builtin(GPU_VIEW_NORMAL), &out[0].link);
- /* for uniform scale this is sufficient to match Cycles */
- GPU_link(mat,
- "direction_transform_m4v3",
- out[0].link,
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- &out[0].link);
- GPU_link(mat, "vect_normalize", out[0].link, &out[0].link);
- return true;
+ break;
case SHD_SPACE_OBJECT:
case SHD_SPACE_BLENDER_OBJECT:
- GPU_link(mat,
- "direction_transform_m4v3",
- negnorm,
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- &negnorm);
- GPU_link(mat, color_to_normal_fnc_name, realnorm, &realnorm);
GPU_link(
mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_OBJECT_MATRIX), &realnorm);
break;
case SHD_SPACE_WORLD:
case SHD_SPACE_BLENDER_WORLD:
- GPU_link(mat,
- "direction_transform_m4v3",
- negnorm,
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- &negnorm);
- GPU_link(mat, color_to_normal_fnc_name, realnorm, &realnorm);
+ /* Nothing to do. */
break;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index 5512754d9a2..6795f48edb3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -42,13 +42,7 @@ static int node_shader_gpu_tangent(GPUMaterial *mat,
NodeShaderTangent *attr = node->storage;
if (attr->direction_type == SHD_TANGENT_UVMAP) {
- return GPU_stack_link(mat,
- node,
- "node_tangentmap",
- in,
- out,
- GPU_attribute(CD_TANGENT, ""),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
+ return GPU_stack_link(mat, node, "node_tangentmap", in, out, GPU_attribute(CD_TANGENT, ""));
}
else {
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
@@ -68,10 +62,9 @@ static int node_shader_gpu_tangent(GPUMaterial *mat,
"node_tangent",
in,
out,
- GPU_builtin(GPU_VIEW_NORMAL),
+ GPU_builtin(GPU_WORLD_NORMAL),
orco,
- GPU_builtin(GPU_OBJECT_MATRIX),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
+ GPU_builtin(GPU_OBJECT_MATRIX));
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
index cbc012040b0..ac8b49c4572 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
@@ -61,7 +61,7 @@ static int gpu_shader_vector_displacement(GPUMaterial *mat,
in,
out,
GPU_attribute(CD_TANGENT, ""),
- GPU_builtin(GPU_VIEW_NORMAL),
+ GPU_builtin(GPU_WORLD_NORMAL),
GPU_builtin(GPU_OBJECT_MATRIX),
GPU_builtin(GPU_VIEW_MATRIX));
}