![]() |
Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2006 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): Juho Vepsäläinen 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00033 #include "node_shader_util.h" 00034 00035 /* **************** SEPARATE RGBA ******************** */ 00036 static bNodeSocketTemplate sh_node_seprgb_in[]= { 00037 { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f}, 00038 { -1, 0, "" } 00039 }; 00040 static bNodeSocketTemplate sh_node_seprgb_out[]= { 00041 { SOCK_FLOAT, 0, "R"}, 00042 { SOCK_FLOAT, 0, "G"}, 00043 { SOCK_FLOAT, 0, "B"}, 00044 { -1, 0, "" } 00045 }; 00046 00047 static void node_shader_exec_seprgb(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out) 00048 { 00049 out[0]->vec[0] = in[0]->vec[0]; 00050 out[1]->vec[0] = in[0]->vec[1]; 00051 out[2]->vec[0] = in[0]->vec[2]; 00052 } 00053 00054 static int gpu_shader_seprgb(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) 00055 { 00056 return GPU_stack_link(mat, "separate_rgb", in, out); 00057 } 00058 00059 void register_node_type_sh_seprgb(bNodeTreeType *ttype) 00060 { 00061 static bNodeType ntype; 00062 00063 node_type_base(ttype, &ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0); 00064 node_type_compatibility(&ntype, NODE_OLD_SHADING|NODE_NEW_SHADING); 00065 node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out); 00066 node_type_size(&ntype, 80, 40, 140); 00067 node_type_exec(&ntype, node_shader_exec_seprgb); 00068 node_type_gpu(&ntype, gpu_shader_seprgb); 00069 00070 nodeRegisterType(ttype, &ntype); 00071 } 00072 00073 00074 00075 /* **************** COMBINE RGB ******************** */ 00076 static bNodeSocketTemplate sh_node_combrgb_in[]= { 00077 { SOCK_FLOAT, 1, "R", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, 00078 { SOCK_FLOAT, 1, "G", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, 00079 { SOCK_FLOAT, 1, "B", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, 00080 { -1, 0, "" } 00081 }; 00082 static bNodeSocketTemplate sh_node_combrgb_out[]= { 00083 { SOCK_RGBA, 0, "Image"}, 00084 { -1, 0, "" } 00085 }; 00086 00087 static void node_shader_exec_combrgb(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out) 00088 { 00089 out[0]->vec[0] = in[0]->vec[0]; 00090 out[0]->vec[1] = in[1]->vec[0]; 00091 out[0]->vec[2] = in[2]->vec[0]; 00092 } 00093 00094 static int gpu_shader_combrgb(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) 00095 { 00096 return GPU_stack_link(mat, "combine_rgb", in, out); 00097 } 00098 00099 void register_node_type_sh_combrgb(bNodeTreeType *ttype) 00100 { 00101 static bNodeType ntype; 00102 00103 node_type_base(ttype, &ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, NODE_OPTIONS); 00104 node_type_compatibility(&ntype, NODE_OLD_SHADING|NODE_NEW_SHADING); 00105 node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out); 00106 node_type_size(&ntype, 80, 40, 140); 00107 node_type_exec(&ntype, node_shader_exec_combrgb); 00108 node_type_gpu(&ntype, gpu_shader_combrgb); 00109 00110 nodeRegisterType(ttype, &ntype); 00111 }