~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/nodes/intern/SHD_nodes/SHD_valToRgb.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: SHD_valToRgb.c,v 1.4 2007/04/04 13:58:12 jesterking Exp $
 
3
 *
 
4
 * ***** BEGIN GPL LICENSE BLOCK *****
 
5
 *
 
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. 
 
10
 *
 
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.
 
15
 *
 
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.
 
19
 *
 
20
 * The Original Code is Copyright (C) 2005 Blender Foundation.
 
21
 * All rights reserved.
 
22
 *
 
23
 * The Original Code is: all of this file.
 
24
 *
 
25
 * Contributor(s): none yet.
 
26
 *
 
27
 * ***** END GPL LICENSE BLOCK *****
 
28
 */
 
29
 
 
30
#include "../SHD_util.h"
 
31
 
 
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},
 
35
        {       -1, 0, ""       }
 
36
};
 
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},
 
40
        {       -1, 0, ""       }
 
41
};
 
42
 
 
43
static void node_shader_exec_valtorgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
44
{
 
45
        /* stack order in: fac */
 
46
        /* stack order out: col, alpha */
 
47
        
 
48
        if(node->storage) {
 
49
                float fac;
 
50
                nodestack_get_vec(&fac, SOCK_VALUE, in[0]);
 
51
 
 
52
                do_colorband(node->storage, fac, out[0]->vec);
 
53
                out[1]->vec[0]= out[0]->vec[3];
 
54
        }
 
55
}
 
56
 
 
57
static void node_shader_init_valtorgb(bNode *node)
 
58
{
 
59
   node->storage= add_colorband(1);
 
60
}
 
61
 
 
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,
 
72
        /* butfunc     */       NULL,
 
73
        /* initfunc    */       node_shader_init_valtorgb,
 
74
        /* freestoragefunc    */        node_free_standard_storage,
 
75
        /* copystoragefunc    */        node_copy_standard_storage,
 
76
        /* id          */       NULL
 
77
        
 
78
};
 
79
 
 
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},
 
83
   {    -1, 0, ""       }
 
84
};
 
85
static bNodeSocketType sh_node_rgbtobw_out[]= {
 
86
   {    SOCK_VALUE, 0, "Val",                   0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
87
   {    -1, 0, ""       }
 
88
};
 
89
 
 
90
 
 
91
static void node_shader_exec_rgbtobw(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
92
{
 
93
   /* stack order out: bw */
 
94
   /* stack order in: col */
 
95
 
 
96
   out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f;
 
97
}
 
98
 
 
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,
 
107
        /* storage     */       "",
 
108
        /* execfunc    */       node_shader_exec_rgbtobw,
 
109
        /* butfunc     */       NULL,
 
110
        /* initfunc    */       NULL,
 
111
        /* freestoragefunc    */        NULL,
 
112
        /* copystoragefunc    */        NULL,
 
113
        /* id          */       NULL
 
114
 
 
115
};
 
116