Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Allen <roblovski@gmail.com>2009-02-06 03:55:38 +0300
committerRobin Allen <roblovski@gmail.com>2009-02-06 03:55:38 +0300
commitfbdd75a4756423a1f884c4738defa31781513823 (patch)
tree8f686dded22a0d72f6acf5d9d163589095721028 /source/blender/nodes
parent8837d69ed3628937ce2c68f14c6e16e6ded23766 (diff)
Added compose/decompose, fixed bugs.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/TEX_node.h3
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_compose.c71
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_decompose.c92
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c34
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_proc.c34
5 files changed, 202 insertions, 32 deletions
diff --git a/source/blender/nodes/TEX_node.h b/source/blender/nodes/TEX_node.h
index 40cb65eacce..d667cd26a76 100644
--- a/source/blender/nodes/TEX_node.h
+++ b/source/blender/nodes/TEX_node.h
@@ -58,6 +58,9 @@ extern bNodeType tex_node_distance;
extern bNodeType tex_node_rotate;
extern bNodeType tex_node_translate;
+extern bNodeType tex_node_compose;
+extern bNodeType tex_node_decompose;
+
extern bNodeType tex_node_proc_voronoi;
extern bNodeType tex_node_proc_blend;
extern bNodeType tex_node_proc_magic;
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 <math.h>
+
+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 -- */