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