[Bf-blender-cvs] [7dbedf6] master: Fix T40795: Dot output is inverted in viewport with Cycles

Sergey Sharybin noreply at git.blender.org
Mon Jun 30 12:27:17 CEST 2014


Commit: 7dbedf6d4ac719d5e452091d82d902cf99c47471
Author: Sergey Sharybin
Date:   Mon Jun 30 16:24:03 2014 +0600
https://developer.blender.org/rB7dbedf6d4ac719d5e452091d82d902cf99c47471

Fix T40795: Dot output is inverted in viewport with Cycles

===================================================================

M	source/blender/gpu/GPU_material.h
M	source/blender/gpu/intern/gpu_material.c
M	source/blender/nodes/shader/nodes/node_shader_normal.c

===================================================================

diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index a1c249d..8d44ad8 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -147,6 +147,7 @@ void GPU_material_vertex_attributes(GPUMaterial *material,
 	struct GPUVertexAttribs *attrib);
 
 bool GPU_material_do_color_management(GPUMaterial *mat);
+bool GPU_material_use_new_shading_nodes(GPUMaterial *mat);
 
 /* Exported shading */
 
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 5ed47cd..1750d31 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -417,6 +417,11 @@ bool GPU_material_do_color_management(GPUMaterial *mat)
 	return !((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT));
 }
 
+bool GPU_material_use_new_shading_nodes(GPUMaterial *mat)
+{
+	return BKE_scene_use_new_shading_nodes(mat->scene);
+}
+
 static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **lv, GPUNodeLink **dist)
 {
 	GPUNodeLink *visifac, *inpr;
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c
index 22b27ce..fcd738f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal.c
@@ -61,7 +61,12 @@ static void node_shader_exec_normal(void *UNUSED(data), int UNUSED(thread), bNod
 static int gpu_shader_normal(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
 {
 	GPUNodeLink *vec = GPU_uniform(out[0].vec);
-	return GPU_stack_link(mat, "normal", in, out, vec);
+	int ret = GPU_stack_link(mat, "normal", in, out, vec);
+	if (ret && GPU_material_use_new_shading_nodes(mat)) {
+		float fac[3] = {1.0f, 0.0f, 0.0f};
+		GPU_link(mat, "invert", GPU_uniform(fac), out[1].link, &out[1].link);
+	}
+	return ret;
 }
 
 void register_node_type_sh_normal(void)




More information about the Bf-blender-cvs mailing list