2
* $Id: SHD_valToRgb.c,v 1.4 2007/04/04 13:58:12 jesterking Exp $
4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* The Original Code is Copyright (C) 2005 Blender Foundation.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): none yet.
27
* ***** END GPL LICENSE BLOCK *****
30
#include "../SHD_util.h"
32
/* **************** VALTORGB ******************** */
33
static bNodeSocketType sh_node_valtorgb_in[]= {
34
{ SOCK_VALUE, 1, "Fac", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
37
static bNodeSocketType sh_node_valtorgb_out[]= {
38
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
39
{ SOCK_VALUE, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
43
static void node_shader_exec_valtorgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
45
/* stack order in: fac */
46
/* stack order out: col, alpha */
50
nodestack_get_vec(&fac, SOCK_VALUE, in[0]);
52
do_colorband(node->storage, fac, out[0]->vec);
53
out[1]->vec[0]= out[0]->vec[3];
57
static void node_shader_init_valtorgb(bNode *node)
59
node->storage= add_colorband(1);
62
bNodeType sh_node_valtorgb= {
63
/* *next,*prev */ NULL, NULL,
64
/* type code */ SH_NODE_VALTORGB,
65
/* name */ "ColorRamp",
66
/* width+range */ 240, 200, 300,
67
/* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS,
68
/* input sock */ sh_node_valtorgb_in,
69
/* output sock */ sh_node_valtorgb_out,
70
/* storage */ "ColorBand",
71
/* execfunc */ node_shader_exec_valtorgb,
73
/* initfunc */ node_shader_init_valtorgb,
74
/* freestoragefunc */ node_free_standard_storage,
75
/* copystoragefunc */ node_copy_standard_storage,
80
/* **************** RGBTOBW ******************** */
81
static bNodeSocketType sh_node_rgbtobw_in[]= {
82
{ SOCK_RGBA, 1, "Color", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
85
static bNodeSocketType sh_node_rgbtobw_out[]= {
86
{ SOCK_VALUE, 0, "Val", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
91
static void node_shader_exec_rgbtobw(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
93
/* stack order out: bw */
94
/* stack order in: col */
96
out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f;
99
bNodeType sh_node_rgbtobw= {
100
/* *next,*prev */ NULL, NULL,
101
/* type code */ SH_NODE_RGBTOBW,
102
/* name */ "RGB to BW",
103
/* width+range */ 80, 40, 120,
104
/* class+opts */ NODE_CLASS_CONVERTOR, 0,
105
/* input sock */ sh_node_rgbtobw_in,
106
/* output sock */ sh_node_rgbtobw_out,
108
/* execfunc */ node_shader_exec_rgbtobw,
111
/* freestoragefunc */ NULL,
112
/* copystoragefunc */ NULL,