Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_normal.c
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static void node_shader_exec_normal(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) | ||||
| /* stack order output: normal, value */ | /* stack order output: normal, value */ | ||||
| nodestack_get_vec(vec, SOCK_VECTOR, in[0]); | nodestack_get_vec(vec, SOCK_VECTOR, in[0]); | ||||
| /* render normals point inside... the widget points outside */ | /* render normals point inside... the widget points outside */ | ||||
| out[1]->vec[0] = -dot_v3v3(vec, out[0]->vec); | out[1]->vec[0] = -dot_v3v3(vec, out[0]->vec); | ||||
| } | } | ||||
| static int gpu_shader_normal(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | static int gpu_shader_normal(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | ||||
| { | { | ||||
| GPUNodeLink *vec = GPU_uniform(out[0].vec); | GPUNodeLink *vec = GPU_uniform(out[0].vec); | ||||
| if (GPU_material_use_new_shading_nodes(mat)) { | if (GPU_material_use_new_shading_nodes(mat)) { | ||||
| return GPU_stack_link(mat, "normal_new_shading", in, out, vec); | return GPU_stack_link(mat, node, "normal_new_shading", in, out, vec); | ||||
| } | } | ||||
| else { | else { | ||||
| return GPU_stack_link(mat, "normal", in, out, vec); | return GPU_stack_link(mat, node, "normal", in, out, vec); | ||||
| } | } | ||||
| } | } | ||||
| void register_node_type_sh_normal(void) | void register_node_type_sh_normal(void) | ||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0); | sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0); | ||||
| node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); | node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); | ||||
| node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out); | node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out); | ||||
| node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal); | node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal); | ||||
| node_type_gpu(&ntype, gpu_shader_normal); | node_type_gpu(&ntype, gpu_shader_normal); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||