|
Blender
V2.59
|
00001 /* 00002 * $Id: SHD_mixRgb.c 35237 2011-02-27 20:13:22Z jesterking $ 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) 2005 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #include "../SHD_util.h" 00036 00037 /* **************** MIX RGB ******************** */ 00038 static bNodeSocketType sh_node_mix_rgb_in[]= { 00039 { SOCK_VALUE, 1, "Fac", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, 00040 { SOCK_RGBA, 1, "Color1", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, 00041 { SOCK_RGBA, 1, "Color2", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, 00042 { -1, 0, "" } 00043 }; 00044 static bNodeSocketType sh_node_mix_rgb_out[]= { 00045 { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, 00046 { -1, 0, "" } 00047 }; 00048 00049 static void node_shader_exec_mix_rgb(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) 00050 { 00051 /* stack order in: fac, col1, col2 */ 00052 /* stack order out: col */ 00053 float col[3]; 00054 float fac; 00055 float vec[3]; 00056 00057 nodestack_get_vec(&fac, SOCK_VALUE, in[0]); 00058 CLAMP(fac, 0.0f, 1.0f); 00059 00060 nodestack_get_vec(col, SOCK_VECTOR, in[1]); 00061 nodestack_get_vec(vec, SOCK_VECTOR, in[2]); 00062 00063 ramp_blend(node->custom1, col, col+1, col+2, fac, vec); 00064 VECCOPY(out[0]->vec, col); 00065 } 00066 00067 static int gpu_shader_mix_rgb(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) 00068 { 00069 static const char *names[] = {"mix_blend", "mix_add", "mix_mult", "mix_sub", 00070 "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light", 00071 "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat", 00072 "mix_val", "mix_color", "mix_soft", "mix_linear"}; 00073 00074 return GPU_stack_link(mat, names[node->custom1], in, out); 00075 } 00076 00077 00078 void register_node_type_sh_mix_rgb(ListBase *lb) 00079 { 00080 static bNodeType ntype; 00081 00082 node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, NODE_OPTIONS, 00083 sh_node_mix_rgb_in, sh_node_mix_rgb_out); 00084 node_type_size(&ntype, 100, 60, 150); 00085 node_type_label(&ntype, node_blend_label); 00086 node_type_exec(&ntype, node_shader_exec_mix_rgb); 00087 node_type_gpu(&ntype, gpu_shader_mix_rgb); 00088 00089 nodeRegisterType(lb, &ntype); 00090 } 00091