diff options
author | Alexander Romanov <a.romanov@blend4web.com> | 2016-05-27 14:25:39 +0300 |
---|---|---|
committer | Alexander Romanov <a.romanov@blend4web.com> | 2016-05-27 14:45:13 +0300 |
commit | 3d86a5bc72a63b1ef8b165d68a1806d0abf0a8ac (patch) | |
tree | 865a6af51a3b60f904066617f8e667174019c200 /source/blender | |
parent | 108b36f1ce79a61f067d21e5aff3bf72ba0fc313 (diff) |
more correct Normal Map node behavior for tangent mapping in Cycles Viewport
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_normal_map.c | 14 |
1 files changed, 9 insertions, 5 deletions
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 d2695609a88..85e2c77662d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c @@ -133,29 +133,33 @@ static int gpu_shader_normal_map(GPUMaterial *mat, bNode *node, bNodeExecData *U /* **************** CYCLES ******************** */ - GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm); - switch (nm->space) { case SHD_NORMAL_MAP_TANGENT: GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm); GPU_link(mat, "node_normal_map", GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm); - break; + 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; case SHD_NORMAL_MAP_OBJECT: + GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm); GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm); GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_OBJECT_MATRIX), &realnorm); break; case SHD_NORMAL_MAP_BLENDER_OBJECT: + GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm); GPU_link(mat, "color_to_blender_normal_new_shading", realnorm, &realnorm); GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_OBJECT_MATRIX), &realnorm); break; case SHD_NORMAL_MAP_WORLD: + GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm); GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm); break; case SHD_NORMAL_MAP_BLENDER_WORLD: + GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm); GPU_link(mat, "color_to_blender_normal_new_shading", realnorm, &realnorm); break; - - GPU_link(mat, "vect_normalize", realnorm, &realnorm); } } else { |