diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-28 18:24:03 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-28 18:24:03 +0400 |
commit | 33d609144ef60c0223b2925cd39a713ed8c9060c (patch) | |
tree | 2e1ce05df337214010bef1d1844f265fb0685814 | |
parent | ef4db04da848a9790e502300285ccd17d71b4646 (diff) |
Cycles: normal maps are now backwards compatible again after recent fix, with
a separate Blender Object/World Space that is compatible with Blender render
baking and uses the YZ flipping convention.
-rw-r--r-- | intern/cycles/kernel/shaders/node_normal_map.osl | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_tex_coord.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_types.h | 4 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_node_types.h | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 2 |
6 files changed, 24 insertions, 8 deletions
diff --git a/intern/cycles/kernel/shaders/node_normal_map.osl b/intern/cycles/kernel/shaders/node_normal_map.osl index 9018cca1390..2557e5ecb4b 100644 --- a/intern/cycles/kernel/shaders/node_normal_map.osl +++ b/intern/cycles/kernel/shaders/node_normal_map.osl @@ -56,13 +56,19 @@ shader node_normal_map( } } else if (space == "Object") { + Normal = normalize(transform("object", "world", vector(mcolor))); + } + else if (space == "World") { + Normal = normalize(vector(mcolor)); + } + else if (space == "Blender Object") { /* strange blender convention */ mcolor[1] = -mcolor[1]; mcolor[2] = -mcolor[2]; Normal = normalize(transform("object", "world", vector(mcolor))); } - else if (space == "World") { + else if (space == "Blender World") { /* strange blender convention */ mcolor[1] = -mcolor[1]; mcolor[2] = -mcolor[2]; diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h index 686b332a322..98f99a91bc6 100644 --- a/intern/cycles/kernel/svm/svm_tex_coord.h +++ b/intern/cycles/kernel/svm/svm_tex_coord.h @@ -277,13 +277,15 @@ __device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stac } else { /* strange blender convention */ - color.y = -color.y; - color.z = -color.z; + if(space == NODE_NORMAL_MAP_BLENDER_OBJECT || space == NODE_NORMAL_MAP_BLENDER_WORLD) { + color.y = -color.y; + color.z = -color.z; + } /* object, world space */ N = color; - if(space == NODE_NORMAL_MAP_OBJECT) + if(space == NODE_NORMAL_MAP_OBJECT || space == NODE_NORMAL_MAP_BLENDER_OBJECT) object_normal_transform(kg, sd, &N); else N = normalize(N); diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index fd440c9bf91..af188477a73 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -309,7 +309,9 @@ typedef enum NodeTangentAxis { typedef enum NodeNormalMapSpace { NODE_NORMAL_MAP_TANGENT, NODE_NORMAL_MAP_OBJECT, - NODE_NORMAL_MAP_WORLD + NODE_NORMAL_MAP_WORLD, + NODE_NORMAL_MAP_BLENDER_OBJECT, + NODE_NORMAL_MAP_BLENDER_WORLD, } NodeNormalMapSpace; typedef enum ShaderType { diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 84038f13270..f73f04ba61c 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3344,6 +3344,8 @@ static ShaderEnum normal_map_space_init() enm.insert("Tangent", NODE_NORMAL_MAP_TANGENT); enm.insert("Object", NODE_NORMAL_MAP_OBJECT); enm.insert("World", NODE_NORMAL_MAP_WORLD); + enm.insert("Blender Object", NODE_NORMAL_MAP_BLENDER_OBJECT); + enm.insert("Blender World", NODE_NORMAL_MAP_BLENDER_WORLD); return enm; } diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index e3606f57e48..8a9a95a9935 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -944,9 +944,11 @@ typedef struct NodeShaderNormalMap { #define SHD_TANGENT_AXIS_Z 2 /* normal map space */ -#define SHD_NORMAL_MAP_TANGENT 0 -#define SHD_NORMAL_MAP_OBJECT 1 -#define SHD_NORMAL_MAP_WORLD 2 +#define SHD_NORMAL_MAP_TANGENT 0 +#define SHD_NORMAL_MAP_OBJECT 1 +#define SHD_NORMAL_MAP_WORLD 2 +#define SHD_NORMAL_MAP_BLENDER_OBJECT 3 +#define SHD_NORMAL_MAP_BLENDER_WORLD 4 /* blur node */ #define CMP_NODE_BLUR_ASPECT_NONE 0 diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index e57256efd87..8bc446d7bfc 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3460,6 +3460,8 @@ static void def_sh_normal_map(StructRNA *srna) {SHD_NORMAL_MAP_TANGENT, "TANGENT", 0, "Tangent Space", "Tangent space normal mapping"}, {SHD_NORMAL_MAP_OBJECT, "OBJECT", 0, "Object Space", "Object space normal mapping"}, {SHD_NORMAL_MAP_WORLD, "WORLD", 0, "World Space", "World space normal mapping"}, + {SHD_NORMAL_MAP_BLENDER_OBJECT, "BLENDER_OBJECT", 0, "Blender Object Space", "Object space normal mapping, compatible with Blender render baking"}, + {SHD_NORMAL_MAP_BLENDER_WORLD, "BLENDER_WORLD", 0, "Blender World Space", "World space normal mapping, compatible with Blender render baking"}, {0, NULL, 0, NULL, NULL} }; |