Fix T48533: camera node view vector wrong for Cycles GLSL.
authorRalf Hölzemer <r.hoelzemer@googlemail.com>
Sat, 28 May 2016 09:34:08 +0000 (11:34 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 28 May 2016 09:38:10 +0000 (11:38 +0200)
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2033

source/blender/nodes/shader/nodes/node_shader_camera.c

index 49ebb15d7a47096912fd372f840a4c35d64b0fa9..3bdb5c36d69bd4a120a616ac9cff947a1c65205a 100644 (file)
@@ -54,7 +54,15 @@ static void node_shader_exec_camera(void *data, int UNUSED(thread), bNode *UNUSE
 
 static int gpu_shader_camera(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
 {
-       return GPU_stack_link(mat, "camera", in, out, GPU_builtin(GPU_VIEW_POSITION));
+       GPUNodeLink *viewvec;
+
+       viewvec = GPU_builtin(GPU_VIEW_POSITION);
+
+       /* Blender has negative Z, Cycles positive Z convention */
+       if (GPU_material_use_new_shading_nodes(mat))
+               GPU_link(mat, "invert_z", viewvec, &viewvec);
+
+       return GPU_stack_link(mat, "camera", in, out, viewvec);
 }
 
 void register_node_type_sh_camera(void)