From fbdd75a4756423a1f884c4738defa31781513823 Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Fri, 6 Feb 2009 00:55:38 +0000 Subject: Added compose/decompose, fixed bugs. --- .../blender/nodes/intern/TEX_nodes/TEX_compose.c | 71 +++++++++++++++++ .../blender/nodes/intern/TEX_nodes/TEX_decompose.c | 92 ++++++++++++++++++++++ .../blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c | 34 ++++---- source/blender/nodes/intern/TEX_nodes/TEX_proc.c | 34 ++++---- 4 files changed, 199 insertions(+), 32 deletions(-) create mode 100644 source/blender/nodes/intern/TEX_nodes/TEX_compose.c create mode 100644 source/blender/nodes/intern/TEX_nodes/TEX_decompose.c (limited to 'source/blender/nodes/intern/TEX_nodes') diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c new file mode 100644 index 00000000000..bb7a654b41f --- /dev/null +++ b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c @@ -0,0 +1,71 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../TEX_util.h" + +static bNodeSocketType inputs[]= { + { SOCK_VALUE, 1, "Red", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 1, "Green", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 1, "Blue", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { -1, 0, "" } +}; +static bNodeSocketType outputs[]= { + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { -1, 0, "" } +}; + +static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + int i; + for(i = 0; i < 4; i++) + out[i] = tex_input_value(in[i], coord, thread); +} + +static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + tex_output(node, in, out[0], &colorfn); +} + +bNodeType tex_node_compose= { + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_COMPOSE, + /* name */ "Compose RGBA", + /* width+range */ 100, 60, 150, + /* class+opts */ NODE_CLASS_OP_COLOR, 0, + /* input sock */ inputs, + /* output sock */ outputs, + /* storage */ "", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL + +}; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c new file mode 100644 index 00000000000..3a4710ce98f --- /dev/null +++ b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c @@ -0,0 +1,92 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../TEX_util.h" +#include + +static bNodeSocketType inputs[]= { + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { -1, 0, "" } +}; +static bNodeSocketType outputs[]= { + { SOCK_VALUE, 1, "Red", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 1, "Green", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 1, "Blue", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { -1, 0, "" } +}; + +static void valuefn_r(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + tex_input_rgba(out, in[0], coord, thread); + *out = out[0]; +} + +static void valuefn_g(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + tex_input_rgba(out, in[0], coord, thread); + *out = out[1]; +} + +static void valuefn_b(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + tex_input_rgba(out, in[0], coord, thread); + *out = out[2]; +} + +static void valuefn_a(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + tex_input_rgba(out, in[0], coord, thread); + *out = out[3]; +} + +static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + tex_output(node, in, out[0], &valuefn_r); + tex_output(node, in, out[1], &valuefn_g); + tex_output(node, in, out[2], &valuefn_b); + tex_output(node, in, out[3], &valuefn_a); +} + +bNodeType tex_node_decompose= { + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_DECOMPOSE, + /* name */ "Decompose RGBA", + /* width+range */ 100, 60, 150, + /* class+opts */ NODE_CLASS_OP_COLOR, 0, + /* input sock */ inputs, + /* output sock */ outputs, + /* storage */ "", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL + +}; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c index d1a33896fc3..bb1a49fb235 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c @@ -30,16 +30,16 @@ static bNodeSocketType inputs[]= { - { SOCK_VALUE, 1, "Hue", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_VALUE, 1, "Saturation", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f}, - { SOCK_VALUE, 1, "Value", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f}, - { SOCK_VALUE, 1, "Fac", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 1, "Color", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { SOCK_VALUE, 1, "Hue", 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f }, + { SOCK_VALUE, 1, "Saturation", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f }, + { SOCK_VALUE, 1, "Value", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f }, + { SOCK_VALUE, 1, "Factor", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_RGBA, 1, "Color", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f }, + { -1, 0, "" } }; static bNodeSocketType outputs[]= { - { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { -1, 0, "" } }; static void do_hue_sat_fac(bNode *node, float *out, float hue, float sat, float val, float *in, float fac) @@ -67,15 +67,19 @@ static void do_hue_sat_fac(bNode *node, float *out, float hue, float sat, float static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) { - float in0 = tex_input_value(in[0], coord, thread); - float in1 = tex_input_value(in[1], coord, thread); - float in2 = tex_input_value(in[2], coord, thread); - float in3 = tex_input_value(in[3], coord, thread); + float hue = tex_input_value(in[0], coord, thread); + float sat = tex_input_value(in[1], coord, thread); + float val = tex_input_value(in[2], coord, thread); + float fac = tex_input_value(in[3], coord, thread); - float in4[4]; - tex_input_rgba(in4, in[4], coord, thread); + float col[4]; + tex_input_rgba(col, in[4], coord, thread); - do_hue_sat_fac(node, out, in0, in1, in2, in4, in3); + hue += 0.5f; /* [-.5, .5] -> [0, 1] */ + + do_hue_sat_fac(node, out, hue, sat, val, col, fac); + + out[3] = col[3]; } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c index 9078dd1be21..ec65cf186a8 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c @@ -110,25 +110,25 @@ static int count_outputs(bNode *node) /* Boilerplate generators */ #define ProcNoInputs(name) \ - static void name##_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) \ - {} + static void name##_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) \ + {} #define ProcDef(name) \ - static void name##_colorfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ - { \ - texfn(result, coord, node, in, 0, &name##_map_inputs, thread); \ - } \ - static void name##_normalfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ - { \ - texfn(result, coord, node, in, 1, &name##_map_inputs, thread); \ - } \ - static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \ - { \ - int outs = count_outputs(node); \ - if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn); \ - if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn); \ - if(outs >= 1) tex_do_preview(node, out[0], data); \ - } + static void name##_colorfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ + { \ + texfn(result, coord, node, in, 0, &name##_map_inputs, thread); \ + } \ + static void name##_normalfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ + { \ + texfn(result, coord, node, in, 1, &name##_map_inputs, thread); \ + } \ + static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \ + { \ + int outs = count_outputs(node); \ + if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn); \ + if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn); \ + if(outs >= 1) tex_do_preview(node, out[0], data); \ + } /* --- VORONOI -- */ -- cgit v1.2.3 From 6a669d00b230901f3d0a0aba3aeac8eafde7ca84 Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Fri, 6 Feb 2009 01:21:38 +0000 Subject: Patch #18015, adds "Value to Normal" node --- .../blender/nodes/intern/TEX_nodes/TEX_valToNor.c | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c (limited to 'source/blender/nodes/intern/TEX_nodes') diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c new file mode 100644 index 00000000000..f63f5682030 --- /dev/null +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c @@ -0,0 +1,92 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Jucas. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../TEX_util.h" + +static bNodeSocketType inputs[]= { + { SOCK_VALUE, 1, "Val", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 1, "Nabla", 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f }, + { -1, 0, "" } +}; + +static bNodeSocketType outputs[]= { + { SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f }, + { -1, 0, "" } +}; + +static void normalfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + float new_coord[3]; + + float nabla = tex_input_value(in[1], coord, thread); + float val; + float nor[2]; + + val = tex_input_value(in[0], coord, thread); + + new_coord[0] = coord[0] + nabla; + new_coord[1] = coord[1]; + new_coord[2] = coord[2]; + nor[0] = tex_input_value(in[0], new_coord, thread); + + new_coord[0] = coord[0]; + new_coord[1] = coord[1] + nabla; + nor[1] = tex_input_value(in[0], new_coord, thread); + + new_coord[1] = coord[1]; + new_coord[2] = coord[2] + nabla; + nor[2] = tex_input_value(in[0], new_coord, thread); + + out[0] = val-nor[0]; + out[1] = val-nor[1]; + out[2] = val-nor[2]; +} +static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + tex_output(node, in, out[0], &normalfn); + + tex_do_preview(node, out[0], data); +} + +bNodeType tex_node_valtonor = { + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_VALTONOR, + /* name */ "Value to Normal", + /* width+range */ 90, 80, 100, + /* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS, + /* input sock */ inputs, + /* output sock */ outputs, + /* storage */ "", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL +}; + -- cgit v1.2.3 From 09099111e39a7363fa186c4200b60b3b2bd93f9e Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Fri, 6 Feb 2009 18:09:35 +0000 Subject: Added Scale, fixed bugs incl. patch #18037 --- .../blender/nodes/intern/TEX_nodes/TEX_compose.c | 28 ++++---- .../blender/nodes/intern/TEX_nodes/TEX_decompose.c | 10 +-- source/blender/nodes/intern/TEX_nodes/TEX_math.c | 23 +++++++ source/blender/nodes/intern/TEX_nodes/TEX_rotate.c | 2 - source/blender/nodes/intern/TEX_nodes/TEX_scale.c | 76 ++++++++++++++++++++++ .../blender/nodes/intern/TEX_nodes/TEX_translate.c | 2 - 6 files changed, 118 insertions(+), 23 deletions(-) create mode 100644 source/blender/nodes/intern/TEX_nodes/TEX_scale.c (limited to 'source/blender/nodes/intern/TEX_nodes') diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c index bb7a654b41f..26576befa3e 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c @@ -53,19 +53,19 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) } bNodeType tex_node_compose= { - /* *next,*prev */ NULL, NULL, - /* type code */ TEX_NODE_COMPOSE, - /* name */ "Compose RGBA", - /* width+range */ 100, 60, 150, - /* class+opts */ NODE_CLASS_OP_COLOR, 0, - /* input sock */ inputs, - /* output sock */ outputs, - /* storage */ "", - /* execfunc */ exec, - /* butfunc */ NULL, - /* initfunc */ NULL, - /* freestoragefunc */ NULL, - /* copystoragefunc */ NULL, - /* id */ NULL + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_COMPOSE, + /* name */ "Compose RGBA", + /* width+range */ 100, 60, 150, + /* class+opts */ NODE_CLASS_OP_COLOR, 0, + /* input sock */ inputs, + /* output sock */ outputs, + /* storage */ "", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL }; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c index 3a4710ce98f..c08eb12a18f 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c @@ -30,14 +30,14 @@ #include static bNodeSocketType inputs[]= { - { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, { -1, 0, "" } }; static bNodeSocketType outputs[]= { - { SOCK_VALUE, 1, "Red", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_VALUE, 1, "Green", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_VALUE, 1, "Blue", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 0, "Red", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 0, "Green", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 0, "Blue", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, + { SOCK_VALUE, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, { -1, 0, "" } }; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index a2c66078692..bac91fc0901 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -143,6 +143,29 @@ static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, shor *out= (int)(in0 + 0.5f); } break; + + case 15: /* Less Than */ + { + if( in0 < in1 ) + *out= 1.0f; + else + *out= 0.0f; + } + break; + + case 16: /* Greater Than */ + { + if( in0 > in1 ) + *out= 1.0f; + else + *out= 0.0f; + } + break; + + default: + fprintf(stderr, + "%s:%d: unhandeld value in switch statement: %d\n", + __FILE__, __LINE__, node->custom1); } } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c index 93bf17d4862..3a2c2b1def1 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c @@ -91,8 +91,6 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { tex_output(node, in, out[0], &colorfn); - - tex_do_preview(node, out[0], data); } bNodeType tex_node_rotate= { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c new file mode 100644 index 00000000000..792c3468e9f --- /dev/null +++ b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c @@ -0,0 +1,76 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include "../TEX_util.h" + +static bNodeSocketType inputs[]= { + { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { SOCK_VECTOR, 1, "Scale", 1.0f, 1.0f, 1.0f, 0.0f, -10.0f, 10.0f }, + { -1, 0, "" } +}; + +static bNodeSocketType outputs[]= { + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + float scale[3], new_coord[3]; + + tex_input_vec(scale, in[1], coord, thread); + + new_coord[0] = coord[0] * scale[0]; + new_coord[1] = coord[1] * scale[1]; + new_coord[2] = coord[2] * scale[2]; + + tex_input_rgba(out, in[0], new_coord, thread); +} +static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + tex_output(node, in, out[0], &colorfn); +} + +bNodeType tex_node_scale = { + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_SCALE, + /* name */ "Scale", + /* width+range */ 90, 80, 100, + /* class+opts */ NODE_CLASS_DISTORT, NODE_OPTIONS, + /* input sock */ inputs, + /* output sock */ outputs, + /* storage */ "", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL +}; + diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c index bd7e61d0ff4..0e903301789 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c @@ -55,8 +55,6 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { tex_output(node, in, out[0], &colorfn); - - tex_do_preview(node, out[0], data); } bNodeType tex_node_translate = { -- cgit v1.2.3