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:
Diffstat (limited to 'source/blender/nodes/intern')
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c30
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_texture.c13
-rw-r--r--source/blender/nodes/intern/SHD_util.c1
-rw-r--r--source/blender/nodes/intern/TEX_nodes/Makefile48
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_bricks.c123
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_checker.c85
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_curves.c127
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c104
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_image.c106
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_invert.c79
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_math.c172
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c81
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_output.c90
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_proc.c310
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_rotate.c114
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_texture.c103
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_translate.c78
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c122
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_viewer.c61
-rw-r--r--source/blender/nodes/intern/TEX_util.c270
-rw-r--r--source/blender/nodes/intern/TEX_util.h104
21 files changed, 2214 insertions, 7 deletions
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
index 49473b213ce..2065ac2ed33 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
@@ -27,17 +27,21 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#ifndef DISABLE_PYTHON
#include <Python.h>
#include <compile.h>
#include <eval.h>
+#endif
#include "DNA_text_types.h"
#include "BKE_text.h"
#include "BKE_utildefines.h"
+#ifndef DISABLE_PYTHON
#include "api2_2x/Node.h"
#include "api2_2x/gen_utils.h"
#include "BPY_extern.h"
+#endif
#include "../SHD_util.h"
@@ -45,6 +49,7 @@ static void node_dynamic_setup(bNode *node);
static void node_dynamic_exec_cb(void *data, bNode *node, bNodeStack **in, bNodeStack **out);
static void node_dynamic_free_storage_cb(bNode *node);
+#ifndef DISABLE_PYTHON
static PyObject *init_dynamicdict(void) {
PyObject *newscriptdict;
PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -58,6 +63,7 @@ static PyObject *init_dynamicdict(void) {
return newscriptdict;
}
+#endif
static bNodeType *node_dynamic_find_typeinfo(ListBase *list, ID *id)
{
@@ -140,12 +146,12 @@ static void node_dynamic_update_socket_links(bNode *node, bNodeTree *ntree)
static void node_dynamic_free_storage_cb(bNode *node)
{
+#ifndef DISABLE_PYTHON
NodeScriptDict *nsd;
PyObject *pydict;
BPy_Node *pynode;
if (!node->storage) return;
-
nsd = (NodeScriptDict *)(node->storage);
pydict = nsd->dict;
if (pydict) {
@@ -155,6 +161,7 @@ static void node_dynamic_free_storage_cb(bNode *node)
if (pynode) {
Py_DECREF(pynode);
}
+#endif
MEM_freeN(node->storage);
node->storage = NULL;
}
@@ -169,6 +176,7 @@ static void node_dynamic_disable(bNode *node)
/* Disable all pynodes using the given text (script) id */
static void node_dynamic_disable_all_by_id(ID *id)
{
+#ifndef DISABLE_PYTHON
Material *ma; /* XXX hardcoded for shaders */
for (ma= G.main->mat.first; ma; ma= ma->id.next) {
@@ -183,6 +191,7 @@ static void node_dynamic_disable_all_by_id(ID *id)
}
}
}
+#endif
}
static void node_rem_socklist_links(bNodeTree *ntree, ListBase *lb)
@@ -327,6 +336,7 @@ int nodeDynamicUnlinkText(ID *txtid) {
static void node_dynamic_pyerror_print(bNode *node)
{
+#ifndef DISABLE_PYTHON
PyGILState_STATE gilstate = PyGILState_Ensure();
fprintf(stderr, "\nError in dynamic node script \"%s\":\n", node->name);
@@ -334,6 +344,7 @@ static void node_dynamic_pyerror_print(bNode *node)
else { fprintf(stderr, "Not a valid dynamic node Python script.\n"); }
PyGILState_Release(gilstate);
+#endif
}
static void node_dynamic_register_type(bNode *node)
@@ -348,6 +359,7 @@ static void node_dynamic_register_type(bNode *node)
node->typeinfo->name = BLI_strdup(node->name);
}
+#ifndef DISABLE_PYTHON
/* node_dynamic_get_pynode:
* Find the pynode definition from the script */
static PyObject *node_dynamic_get_pynode(PyObject *dict)
@@ -389,9 +401,13 @@ static PyObject *node_dynamic_get_pynode(PyObject *dict)
"no PyNode definition found in the script!");
return NULL;
}
+#endif /* DISABLE_PYTHON */
static int node_dynamic_parse(struct bNode *node)
{
+#ifdef DISABLE_PYTHON
+ return -1;
+#else
PyObject *dict= NULL;
PyObject *pynode_data= NULL;
PyObject *pynode= NULL;
@@ -479,12 +495,14 @@ static int node_dynamic_parse(struct bNode *node)
}
return 0;
+#endif
}
/* node_dynamic_setup: prepare for execution (state: NODE_DYNAMIC_READY)
* pynodes already linked to a script (node->id != NULL). */
static void node_dynamic_setup(bNode *node)
{
+#ifndef DISABLE_PYTHON
NodeScriptDict *nsd = NULL;
bNodeTree *nodetree = NULL;
bNodeType *ntype = NULL;
@@ -608,7 +626,7 @@ static void node_dynamic_setup(bNode *node)
node->custom1 = BSET(node->custom1, NODE_DYNAMIC_READY);
PyGILState_Release(gilstate);
-
+#endif /* DISABLE_PYTHON */
return;
}
@@ -641,6 +659,9 @@ static void node_dynamic_init_cb(bNode *node) {
/* node_dynamic_copy_cb: pynode copy callback */
static void node_dynamic_copy_cb(bNode *orig_node, bNode *new_node)
{
+#ifdef DISABLE_PYTHON
+ return;
+#else
NodeScriptDict *nsd;
PyGILState_STATE gilstate;
@@ -657,11 +678,15 @@ static void node_dynamic_copy_cb(bNode *orig_node, bNode *new_node)
Py_INCREF((PyObject *)(nsd->dict));
PyGILState_Release(gilstate);
+#endif
}
/* node_dynamic_exec_cb: the execution callback called per pixel
* during rendering. */
static void node_dynamic_exec_cb(void *data, bNode *node, bNodeStack **in, bNodeStack **out) {
+#ifdef DISABLE_PYTHON
+ return;
+#else
BPy_Node *mynode = NULL;
NodeScriptDict *nsd = NULL;
PyObject *pyresult = NULL;
@@ -716,6 +741,7 @@ static void node_dynamic_exec_cb(void *data, bNode *node, bNodeStack **in, bNode
PyGILState_Release(gilstate);
}
}
+#endif
}
bNodeType node_dynamic_typeinfo = {
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_texture.c b/source/blender/nodes/intern/SHD_nodes/SHD_texture.c
index 31dbde940fd..908cbf5abfd 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_texture.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_texture.c
@@ -50,6 +50,9 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
TexResult texres;
float vec[3], nor[3]={0.0f, 0.0f, 0.0f};
int retval;
+ short which_output = node->custom1;
+
+ short thread = shi->thread;
/* out: value, color, normal */
@@ -61,7 +64,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
if(in[0]->datatype==NS_OSA_VECTORS) {
float *fp= in[0]->data;
- retval= multitex_ext((Tex *)node->id, vec, fp, fp+3, shi->osatex, &texres);
+ retval= multitex_thread((Tex *)node->id, vec, fp, fp+3, shi->osatex, &texres, thread, which_output);
}
else if(in[0]->datatype==NS_OSA_VALUES) {
float *fp= in[0]->data;
@@ -69,14 +72,14 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
dxt[0]= fp[0]; dxt[1]= dxt[2]= 0.0f;
dyt[0]= fp[1]; dyt[1]= dyt[2]= 0.0f;
- retval= multitex_ext((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres);
+ retval= multitex_thread((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres, thread, which_output);
}
else
- retval= multitex_ext((Tex *)node->id, vec, NULL, NULL, 0, &texres);
+ retval= multitex_thread((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output);
}
- else { /* only for previewrender, so we see stuff */
+ else {
VECCOPY(vec, shi->lo);
- retval= multitex_ext((Tex *)node->id, vec, NULL, NULL, 0, &texres);
+ retval= multitex_thread((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output);
}
/* stupid exception */
diff --git a/source/blender/nodes/intern/SHD_util.c b/source/blender/nodes/intern/SHD_util.c
index f673834d2b7..b5e82db8a93 100644
--- a/source/blender/nodes/intern/SHD_util.c
+++ b/source/blender/nodes/intern/SHD_util.c
@@ -82,6 +82,7 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
/* convert caller data to struct */
scd.shi= shi;
scd.shr= shr;
+
/* each material node has own local shaderesult, with optional copying */
memset(shr, 0, sizeof(ShadeResult));
diff --git a/source/blender/nodes/intern/TEX_nodes/Makefile b/source/blender/nodes/intern/TEX_nodes/Makefile
new file mode 100644
index 00000000000..7fad19a772c
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/Makefile
@@ -0,0 +1,48 @@
+#
+# $Id: Makefile 12796 2007-12-05 16:58:52Z sirdude $
+#
+# ***** BEGIN GPL/BL DUAL 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. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# 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) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+#
+
+LIBNAME = nodes_tex
+DIR = $(OCGDIR)/blender/$(LIBNAME)
+
+include nan_compile.mk
+
+CFLAGS += $(LEVEL_1_C_WARNINGS)
+
+CPPFLAGS += -I../../../blenkernel
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+CPPFLAGS += -I../../../makesdna
+CPPFLAGS += -I../../../blenlib
+CPPFLAGS += -I../../../include
+CPPFLAGS += -I../../../imbuf
+CPPFLAGS += -I../../../render/extern/include
+CPPFLAGS += -I$(OPENGL_HEADERS)
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
new file mode 100644
index 00000000000..c9fa3528b02
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
@@ -0,0 +1,123 @@
+/**
+ *
+ * ***** 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, 1, "Bricks 1", 0.596f, 0.282f, 0.0f, 1.0f, 0.0f, 1.0f },
+ { SOCK_RGBA, 1, "Bricks 2", 0.632f, 0.504f, 0.05f, 1.0f, 0.0f, 1.0f },
+ { SOCK_RGBA, 1, "Mortar", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+ { SOCK_VALUE, 1, "Thickness", 0.02f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
+ { SOCK_VALUE, 1, "Bias", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f },
+ { SOCK_VALUE, 1, "Brick Width", 0.5f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f },
+ { SOCK_VALUE, 1, "Row Height", 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.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 init(bNode *node) {
+ node->custom3 = 0.5; /* offset */
+ node->custom4 = 1.0; /* squash */
+}
+
+static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+ float x = coord[0];
+ float y = coord[1];
+
+ float bricknum, rownum, offset = 0;
+ float ins_x, ins_y;
+ float tint;
+
+ float bricks1[4];
+ float bricks2[4];
+ float mortar[4];
+
+ float mortar_thickness = tex_input_value(in[3], coord, thread);
+ float bias = tex_input_value(in[4], coord, thread);
+ float brick_width = tex_input_value(in[5], coord, thread);
+ float row_height = tex_input_value(in[6], coord, thread);
+
+ tex_input_rgba(bricks1, in[0], coord, thread);
+ tex_input_rgba(bricks2, in[1], coord, thread);
+ tex_input_rgba(mortar, in[2], coord, thread);
+
+ rownum = floor(y / row_height);
+
+ if( node->custom1 && node->custom2 ) {
+ brick_width *= ((int)(rownum) % node->custom2 ) ? 1.0f : node->custom4; /* squash */
+ offset = ((int)(rownum) % node->custom1 ) ? 0 : (brick_width*node->custom3); /* offset */
+ }
+
+ bricknum = floor((x+offset) / brick_width);
+
+ ins_x = (x+offset) - brick_width*bricknum;
+ ins_y = y - row_height*rownum;
+
+ srand( (123456*rownum) + bricknum );
+ tint = rand() / (float)RAND_MAX + bias;
+ CLAMP(tint,0.0f,1.0f);
+
+ if( ins_x < mortar_thickness || ins_y < mortar_thickness ||
+ ins_x > (brick_width - mortar_thickness) ||
+ ins_y > (row_height - mortar_thickness) ) {
+ QUATCOPY( out, mortar );
+ } else {
+ QUATCOPY( out, bricks1 );
+ ramp_blend( MA_RAMP_BLEND, out, out+1, out+2, tint, bricks2 );
+ }
+}
+
+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_bricks= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_BRICKS,
+ /* name */ "Bricks",
+ /* width+range */ 150, 60, 150,
+ /* class+opts */ NODE_CLASS_PATTERN, NODE_OPTIONS | NODE_PREVIEW,
+ /* input sock */ inputs,
+ /* output sock */ outputs,
+ /* storage */ "",
+ /* execfunc */ exec,
+ /* butfunc */ NULL,
+ /* initfunc */ init,
+ /* freestoragefunc */ NULL,
+ /* copystoragefunc */ NULL,
+ /* id */ NULL
+
+};
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c
new file mode 100644
index 00000000000..60357782e25
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c
@@ -0,0 +1,85 @@
+/**
+ *
+ * ***** 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, 1, "Color1", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+ { SOCK_RGBA, 1, "Color2", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f },
+ { SOCK_VALUE, 1, "Size", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.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 x = coord[0];
+ float y = coord[1];
+ float z = coord[2];
+ float sz = tex_input_value(in[2], coord, thread);
+
+ /* 0.00001 because of unit sized stuff */
+ int xi = (int)fabs(floor(0.00001 + x / sz));
+ int yi = (int)fabs(floor(0.00001 + y / sz));
+ int zi = (int)fabs(floor(0.00001 + z / sz));
+
+ if( (xi % 2 == yi % 2) == (zi % 2) ) {
+ tex_input_rgba(out, in[0], coord, thread);
+ } else {
+ tex_input_rgba(out, in[1], coord, thread);
+ }
+}
+
+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_checker= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_CHECKER,
+ /* name */ "Checker",
+ /* width+range */ 100, 60, 150,
+ /* class+opts */ NODE_CLASS_PATTERN, NODE_OPTIONS | NODE_PREVIEW,
+ /* 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_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c
new file mode 100644
index 00000000000..8c86656b4f3
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c
@@ -0,0 +1,127 @@
+/**
+ *
+ * ***** 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"
+
+/* **************** CURVE Time ******************** */
+
+/* custom1 = sfra, custom2 = efra */
+static bNodeSocketType time_outputs[]= {
+ { SOCK_VALUE, 0, "Value", 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f },
+ { -1, 0, "" }
+};
+
+static void time_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+ /* stack order output: fac */
+ float fac= 0.0f;
+
+ if(node->custom1 < node->custom2)
+ fac = (G.scene->r.cfra - node->custom1)/(float)(node->custom2-node->custom1);
+
+ fac = curvemapping_evaluateF(node->storage, 0, fac);
+ out[0] = CLAMPIS(fac, 0.0f, 1.0f);
+}
+
+static void time_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ tex_output(node, in, out[0], &time_colorfn);
+}
+
+
+static void time_init(bNode* node)
+{
+ node->custom1= G.scene->r.sfra;
+ node->custom2= G.scene->r.efra;
+ node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+}
+
+bNodeType tex_node_curve_time= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_CURVE_TIME,
+ /* name */ "Time",
+ /* width+range */ 140, 100, 320,
+ /* class+opts */ NODE_CLASS_INPUT, NODE_OPTIONS,
+ /* input sock */ NULL,
+ /* output sock */ time_outputs,
+ /* storage */ "CurveMapping",
+ /* execfunc */ time_exec,
+ /* butfunc */ NULL,
+ /* initfunc */ time_init,
+ /* freestoragefunc */ node_free_curves,
+ /* copystoragefunc */ node_copy_curves,
+ /* id */ NULL
+};
+
+/* **************** CURVE RGB ******************** */
+static bNodeSocketType rgb_inputs[]= {
+ { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketType rgb_outputs[]= {
+ { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void rgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+ float cin[4];
+ tex_input_rgba(cin, in[0], coord, thread);
+
+ curvemapping_evaluateRGBF(node->storage, out, cin);
+ out[3] = cin[3];
+}
+
+static void rgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ tex_output(node, in, out[0], &rgb_colorfn);
+}
+
+static void rgb_init(bNode *node)
+{
+ node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
+}
+
+bNodeType tex_node_curve_rgb= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_CURVE_RGB,
+ /* name */ "RGB Curves",
+ /* width+range */ 200, 140, 320,
+ /* class+opts */ NODE_CLASS_OP_COLOR, NODE_OPTIONS,
+ /* input sock */ rgb_inputs,
+ /* output sock */ rgb_outputs,
+ /* storage */ "CurveMapping",
+ /* execfunc */ rgb_exec,
+ /* butfunc */ NULL,
+ /* initfunc */ rgb_init,
+ /* freestoragefunc */ node_free_curves,
+ /* copystoragefunc */ node_copy_curves,
+ /* id */ NULL
+};
+
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
new file mode 100644
index 00000000000..d1a33896fc3
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
@@ -0,0 +1,104 @@
+/**
+ *
+ * ***** 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) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Juho Vepsäläinen
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../TEX_util.h"
+
+
+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, "" }
+};
+static bNodeSocketType outputs[]= {
+ { 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)
+{
+ if(fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) {
+ float col[3], hsv[3], mfac= 1.0f - fac;
+
+ rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
+ hsv[0]+= (hue - 0.5f);
+ if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0;
+ hsv[1]*= sat;
+ if(hsv[1]>1.0) hsv[1]= 1.0; else if(hsv[1]<0.0) hsv[1]= 0.0;
+ hsv[2]*= val;
+ if(hsv[2]>1.0) hsv[2]= 1.0; else if(hsv[2]<0.0) hsv[2]= 0.0;
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
+
+ out[0]= mfac*in[0] + fac*col[0];
+ out[1]= mfac*in[1] + fac*col[1];
+ out[2]= mfac*in[2] + fac*col[2];
+ }
+ else {
+ QUATCOPY(out, in);
+ }
+}
+
+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 in4[4];
+ tex_input_rgba(in4, in[4], coord, thread);
+
+ do_hue_sat_fac(node, out, in0, in1, in2, in4, in3);
+}
+
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ tex_output(node, in, out[0], &colorfn);
+}
+
+bNodeType tex_node_hue_sat= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_HUE_SAT,
+ /* name */ "Hue Saturation Value",
+ /* width+range */ 150, 80, 250,
+ /* class+opts */ NODE_CLASS_OP_COLOR, 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_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c
new file mode 100644
index 00000000000..f9477fef12b
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c
@@ -0,0 +1,106 @@
+/**
+ * $Id: TEX_image.c 10456 2007-04-04 13:58:12Z jesterking $
+ *
+ * ***** 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) 2006 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 outputs[]= {
+ { SOCK_RGBA, 0, "Image", 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 x = coord[0];
+ float y = coord[1];
+ Image *ima= (Image *)node->id;
+ ImageUser *iuser= (ImageUser *)node->storage;
+
+ if( ima ) {
+ ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser);
+ if( ibuf ) {
+ float xsize, ysize;
+ float xoff, yoff;
+ int px, py;
+
+ float *result;
+
+ xsize = ibuf->x / 2;
+ ysize = ibuf->y / 2;
+ xoff = yoff = -1;
+
+ px = (int)( (x-xoff) * xsize );
+ py = (int)( (y-yoff) * ysize );
+
+ if( (!xsize) || (!ysize) ) return;
+ if( !ibuf->rect_float ) IMB_float_from_rect(ibuf);
+
+ while( px < 0 ) px += ibuf->x;
+ while( py < 0 ) py += ibuf->y;
+ while( px >= ibuf->x ) px -= ibuf->x;
+ while( py >= ibuf->y ) py -= ibuf->y;
+
+ result = ibuf->rect_float + py*ibuf->x*4 + px*4;
+ QUATCOPY( out, result );
+ }
+ }
+};
+
+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);
+}
+
+static void init(bNode* node)
+{
+ ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user");
+ node->storage= iuser;
+ iuser->sfra= 1;
+ iuser->fie_ima= 2;
+ iuser->ok= 1;
+}
+
+bNodeType tex_node_image= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_IMAGE,
+ /* name */ "Image",
+ /* width+range */ 120, 80, 300,
+ /* class+opts */ NODE_CLASS_INPUT, NODE_PREVIEW|NODE_OPTIONS,
+ /* input sock */ NULL,
+ /* output sock */ outputs,
+ /* storage */ "ImageUser",
+ /* execfunc */ exec,
+ /* butfunc */ NULL,
+ /* initfunc */ init,
+ /* freestoragefunc */ node_free_standard_storage,
+ /* copystoragefunc */ node_copy_standard_storage,
+ /* id */ NULL
+};
+
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c
new file mode 100644
index 00000000000..09716951009
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c
@@ -0,0 +1,79 @@
+/**
+ *
+ * ***** 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"
+
+/* **************** INVERT ******************** */
+static bNodeSocketType inputs[]= {
+ { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 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, "" }
+};
+
+static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+ float col[4];
+
+ tex_input_rgba(col, in[0], coord, thread);
+
+ col[0] = 1.0f - col[0];
+ col[1] = 1.0f - col[1];
+ col[2] = 1.0f - col[2];
+
+ VECCOPY(out, col);
+ out[3] = col[3];
+}
+
+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_invert= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_INVERT,
+ /* name */ "Invert",
+ /* width+range */ 90, 80, 100,
+ /* class+opts */ NODE_CLASS_OP_COLOR, 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_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c
new file mode 100644
index 00000000000..a2c66078692
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c
@@ -0,0 +1,172 @@
+/**
+ *
+ * ***** 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"
+
+
+
+/* **************** SCALAR MATH ******************** */
+static bNodeSocketType inputs[]= {
+ { SOCK_VALUE, 1, "Value", 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f},
+ { SOCK_VALUE, 1, "Value", 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketType outputs[]= {
+ { SOCK_VALUE, 0, "Value", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void valuefn(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);
+
+ switch(node->custom1){
+
+ case 0: /* Add */
+ *out= in0 + in1;
+ break;
+ case 1: /* Subtract */
+ *out= in0 - in1;
+ break;
+ case 2: /* Multiply */
+ *out= in0 * in1;
+ break;
+ case 3: /* Divide */
+ {
+ if(in1==0) /* We don't want to divide by zero. */
+ *out= 0.0;
+ else
+ *out= in0 / in1;
+ }
+ break;
+ case 4: /* Sine */
+ {
+ *out= sin(in0);
+ }
+ break;
+ case 5: /* Cosine */
+ {
+ *out= cos(in0);
+ }
+ break;
+ case 6: /* Tangent */
+ {
+ *out= tan(in0);
+ }
+ break;
+ case 7: /* Arc-Sine */
+ {
+ /* Can't do the impossible... */
+ if( in0 <= 1 && in0 >= -1 )
+ *out= asin(in0);
+ else
+ *out= 0.0;
+ }
+ break;
+ case 8: /* Arc-Cosine */
+ {
+ /* Can't do the impossible... */
+ if( in0 <= 1 && in0 >= -1 )
+ *out= acos(in0);
+ else
+ *out= 0.0;
+ }
+ break;
+ case 9: /* Arc-Tangent */
+ {
+ *out= atan(in0);
+ }
+ break;
+ case 10: /* Power */
+ {
+ /* Don't want any imaginary numbers... */
+ if( in0 >= 0 )
+ *out= pow(in0, in1);
+ else
+ *out= 0.0;
+ }
+ break;
+ case 11: /* Logarithm */
+ {
+ /* Don't want any imaginary numbers... */
+ if( in0 > 0 && in1 > 0 )
+ *out= log(in0) / log(in1);
+ else
+ *out= 0.0;
+ }
+ break;
+ case 12: /* Minimum */
+ {
+ if( in0 < in1 )
+ *out= in0;
+ else
+ *out= in1;
+ }
+ break;
+ case 13: /* Maximum */
+ {
+ if( in0 > in1 )
+ *out= in0;
+ else
+ *out= in1;
+ }
+ break;
+ case 14: /* Round */
+ {
+ *out= (int)(in0 + 0.5f);
+ }
+ break;
+ }
+}
+
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ tex_output(node, in, out[0], &valuefn);
+
+ tex_do_preview(node, out[0], data);
+}
+
+bNodeType tex_node_math= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_MATH,
+ /* name */ "Math",
+ /* width+range */ 120, 110, 160,
+ /* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS,
+ /* input sock */ inputs,
+ /* output sock */ outputs,
+ /* storage */ "node_math",
+ /* execfunc */ exec,
+ /* butfunc */ NULL,
+ /* initfunc */ NULL,
+ /* freestoragefunc */ NULL,
+ /* copystoragefunc */ NULL,
+ /* id */ NULL
+};
+
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c
new file mode 100644
index 00000000000..b1ccb7a3d07
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c
@@ -0,0 +1,81 @@
+/**
+ *
+ * ***** 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"
+
+
+/* **************** MIX RGB ******************** */
+static bNodeSocketType inputs[]= {
+ { SOCK_VALUE, 1, "Factor", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
+ { SOCK_RGBA, 1, "Color1", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f },
+ { SOCK_RGBA , 1, "Color2", 0.5f, 0.5f, 0.5f, 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, "" }
+};
+
+static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+ float fac = tex_input_value(in[0], coord, thread);
+ float col1[4], col2[4];
+
+ tex_input_rgba(col1, in[1], coord, thread);
+ tex_input_rgba(col2, in[2], coord, thread);
+
+ CLAMP(fac, 0.0f, 1.0f);
+
+ QUATCOPY(out, col1);
+ ramp_blend(node->custom1, out, out+1, out+2, fac, col2);
+}
+
+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_mix_rgb= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_MIX_RGB,
+ /* name */ "Mix",
+ /* width+range */ 100, 60, 150,
+ /* class+opts */ NODE_CLASS_OP_COLOR, 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_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c
new file mode 100644
index 00000000000..060ea8d7e67
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c
@@ -0,0 +1,90 @@
+/**
+ *
+ * ***** 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) 2006 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"
+
+/* **************** COMPOSITE ******************** */
+static bNodeSocketType inputs[]= {
+ { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_VECTOR, 1, "Normal", 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+/* applies to render pipeline */
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ TexCallData *cdata = (TexCallData *)data;
+ TexResult *target = cdata->target;
+
+ if(in[1]->hasinput && !in[0]->hasinput)
+ tex_do_preview(node, in[1], data);
+ else
+ tex_do_preview(node, in[0], data);
+
+ if(!cdata->do_preview) {
+ if(cdata->which_output == node->custom1)
+ {
+ tex_input_rgba(&target->tr, in[0], cdata->coord, cdata->thread);
+
+ target->tin = (target->tr + target->tg + target->tb) / 3.0f;
+ target->talpha = 1.0f;
+
+ if(target->nor) {
+ if(in[1]->hasinput)
+ tex_input_vec(target->nor, in[1], cdata->coord, cdata->thread);
+ else
+ target->nor = 0;
+ }
+ }
+ }
+}
+
+static void init(bNode* node)
+{
+ TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output");
+ strcpy(tno->name, "Default");
+ node->storage= tno;
+}
+
+
+bNodeType tex_node_output= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_OUTPUT,
+ /* name */ "Output",
+ /* width+range */ 150, 60, 200,
+ /* class+opts */ NODE_CLASS_OUTPUT, NODE_PREVIEW | NODE_OPTIONS,
+ /* input sock */ inputs,
+ /* output sock */ NULL,
+ /* storage */ "TexNodeOutput",
+ /* execfunc */ exec,
+ /* butfunc */ NULL,
+ /* initfunc */ init,
+ /* freestoragefunc */ node_free_standard_storage,
+ /* copystoragefunc */ node_copy_standard_storage,
+ /* id */ NULL
+};
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c
new file mode 100644
index 00000000000..9078dd1be21
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c
@@ -0,0 +1,310 @@
+/**
+ *
+ * ***** 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 "RE_shader_ext.h"
+
+/*
+ In this file: wrappers to use procedural textures as nodes
+*/
+
+
+static bNodeSocketType outputs_both[]= {
+ { SOCK_RGBA, 0, "Color", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+ { SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f },
+ { -1, 0, "" }
+};
+static bNodeSocketType outputs_color_only[]= {
+ { SOCK_RGBA, 0, "Color", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+ { -1, 0, "" }
+};
+
+/* Inputs common to all, #defined because nodes will need their own inputs too */
+#define I 2 /* count */
+#define COMMON_INPUTS \
+ { SOCK_RGBA, 1, "Color 1", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, \
+ { SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }
+
+/* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */
+static void do_proc(float *result, float *coord, float *col1, float *col2, char is_normal, Tex *tex, short thread)
+{
+ TexResult texres;
+ int textype;
+
+ if(is_normal) {
+ texres.nor = result;
+ }
+ else
+ texres.nor = NULL;
+
+ textype = multitex_thread(tex, coord, 0, 0, 0, &texres, thread, 0);
+
+ if(is_normal)
+ return;
+
+ if(textype & TEX_RGB) {
+ QUATCOPY(result, &texres.tr);
+ }
+ else {
+ QUATCOPY(result, col1);
+ ramp_blend(MA_RAMP_BLEND, result, result+1, result+2, texres.tin, col2);
+ }
+}
+
+typedef void (*MapFn) (Tex *tex, bNodeStack **in, float *coord, short thread);
+
+static void texfn(
+ float *result,
+ float *coord,
+ bNode *node,
+ bNodeStack **in,
+ char is_normal,
+ MapFn map_inputs,
+ short thread)
+{
+ Tex tex = *((Tex*)(node->storage));
+ float col1[4], col2[4];
+ tex_input_rgba(col1, in[0], coord, thread);
+ tex_input_rgba(col2, in[1], coord, thread);
+
+ map_inputs(&tex, in, coord, thread);
+
+ do_proc(result, coord, col1, col2, is_normal, &tex, thread);
+}
+
+static int count_outputs(bNode *node)
+{
+ bNodeSocket *sock;
+ int num = 0;
+ for(sock= node->outputs.first; sock; sock= sock->next) {
+ num++;
+ }
+ return num;
+}
+
+/* Boilerplate generators */
+
+#define ProcNoInputs(name) \
+ 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); \
+ }
+
+
+/* --- VORONOI -- */
+static bNodeSocketType voronoi_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "W1", 1.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f },
+ { SOCK_VALUE, 1, "W2", 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f },
+ { SOCK_VALUE, 1, "W3", 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f },
+ { SOCK_VALUE, 1, "W4", 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f },
+
+ { SOCK_VALUE, 1, "iScale", 1.0f, 0.0f, 0.0f, 0.0f, 0.01f, 10.0f },
+ { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 4.0f },
+
+ { -1, 0, "" }
+};
+static void voronoi_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->vn_w1 = tex_input_value(in[I+0], coord, thread);
+ tex->vn_w2 = tex_input_value(in[I+1], coord, thread);
+ tex->vn_w3 = tex_input_value(in[I+2], coord, thread);
+ tex->vn_w4 = tex_input_value(in[I+3], coord, thread);
+
+ tex->ns_outscale = tex_input_value(in[I+4], coord, thread);
+ tex->noisesize = tex_input_value(in[I+5], coord, thread);
+}
+ProcDef(voronoi)
+
+/* --- BLEND -- */
+static bNodeSocketType blend_inputs[]= {
+ COMMON_INPUTS,
+ { -1, 0, "" }
+};
+ProcNoInputs(blend)
+ProcDef(blend)
+
+/* -- MAGIC -- */
+static bNodeSocketType magic_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f },
+ { -1, 0, "" }
+};
+static void magic_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->turbul = tex_input_value(in[I+0], coord, thread);
+}
+ProcDef(magic)
+
+/* --- MARBLE --- */
+static bNodeSocketType marble_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f },
+ { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f },
+ { -1, 0, "" }
+};
+static void marble_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->noisesize = tex_input_value(in[I+0], coord, thread);
+ tex->turbul = tex_input_value(in[I+1], coord, thread);
+}
+ProcDef(marble)
+
+/* --- CLOUDS --- */
+static bNodeSocketType clouds_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f },
+ { -1, 0, "" }
+};
+static void clouds_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->noisesize = tex_input_value(in[I+0], coord, thread);
+}
+ProcDef(clouds)
+
+/* --- DISTORTED NOISE --- */
+static bNodeSocketType distnoise_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f },
+ { SOCK_VALUE, 1, "Distortion", 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f },
+ { -1, 0, "" }
+};
+static void distnoise_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->noisesize = tex_input_value(in[I+0], coord, thread);
+ tex->dist_amount = tex_input_value(in[I+1], coord, thread);
+}
+ProcDef(distnoise)
+
+/* --- WOOD --- */
+static bNodeSocketType wood_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f },
+ { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f },
+ { -1, 0, "" }
+};
+static void wood_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->noisesize = tex_input_value(in[I+0], coord, thread);
+ tex->turbul = tex_input_value(in[I+1], coord, thread);
+}
+ProcDef(wood)
+
+/* --- MUSGRAVE --- */
+static bNodeSocketType musgrave_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "H", 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f },
+ { SOCK_VALUE, 1, "Lacunarity", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f },
+ { SOCK_VALUE, 1, "Octaves", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 8.0f },
+
+ { SOCK_VALUE, 1, "iScale", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f },
+ { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f },
+ { -1, 0, "" }
+};
+static void musgrave_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->mg_H = tex_input_value(in[I+0], coord, thread);
+ tex->mg_lacunarity = tex_input_value(in[I+1], coord, thread);
+ tex->mg_octaves = tex_input_value(in[I+2], coord, thread);
+ tex->ns_outscale = tex_input_value(in[I+3], coord, thread);
+ tex->noisesize = tex_input_value(in[I+4], coord, thread);
+}
+ProcDef(musgrave)
+
+/* --- NOISE --- */
+static bNodeSocketType noise_inputs[]= {
+ COMMON_INPUTS,
+ { -1, 0, "" }
+};
+ProcNoInputs(noise)
+ProcDef(noise)
+
+/* --- STUCCI --- */
+static bNodeSocketType stucci_inputs[]= {
+ COMMON_INPUTS,
+ { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f },
+ { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f },
+ { -1, 0, "" }
+};
+static void stucci_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
+{
+ tex->noisesize = tex_input_value(in[I+0], coord, thread);
+ tex->turbul = tex_input_value(in[I+1], coord, thread);
+}
+ProcDef(stucci)
+
+/* --- */
+
+static void init(bNode *node)
+{
+ Tex *tex = MEM_callocN(sizeof(Tex), "Tex");
+ node->storage= tex;
+
+ default_tex(tex);
+ tex->type = node->type - TEX_NODE_PROC;
+
+ if(tex->type == TEX_WOOD)
+ tex->stype = TEX_BANDNOISE;
+
+}
+
+/* Node type definitions */
+#define TexDef(TEXTYPE, outputs, name, Name) \
+ { NULL, NULL, TEX_NODE_PROC+TEXTYPE, Name, 140,80,140, NODE_CLASS_TEXTURE, \
+ NODE_OPTIONS | NODE_PREVIEW, name##_inputs, outputs, "Tex", name##_exec, NULL, init, \
+ node_free_standard_storage, node_copy_standard_storage, NULL }
+
+#define C outputs_color_only
+#define CV outputs_both
+
+bNodeType tex_node_proc_voronoi = TexDef(TEX_VORONOI, CV, voronoi, "Voronoi" );
+bNodeType tex_node_proc_blend = TexDef(TEX_BLEND, C, blend, "Blend" );
+bNodeType tex_node_proc_magic = TexDef(TEX_MAGIC, C, magic, "Magic" );
+bNodeType tex_node_proc_marble = TexDef(TEX_MARBLE, CV, marble, "Marble" );
+bNodeType tex_node_proc_clouds = TexDef(TEX_CLOUDS, CV, clouds, "Clouds" );
+bNodeType tex_node_proc_wood = TexDef(TEX_WOOD, CV, wood, "Wood" );
+bNodeType tex_node_proc_musgrave = TexDef(TEX_MUSGRAVE, CV, musgrave, "Musgrave" );
+bNodeType tex_node_proc_noise = TexDef(TEX_NOISE, C, noise, "Noise" );
+bNodeType tex_node_proc_stucci = TexDef(TEX_STUCCI, CV, stucci, "Stucci" );
+bNodeType tex_node_proc_distnoise = TexDef(TEX_DISTNOISE, CV, distnoise, "Distorted Noise" );
+
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c
new file mode 100644
index 00000000000..93bf17d4862
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c
@@ -0,0 +1,114 @@
+/**
+ *
+ * ***** 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 <math.h>
+#include "MTC_vectorops.h"
+#include "../TEX_util.h"
+
+static bNodeSocketType inputs[]= {
+ { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_VALUE, 1, "Turns", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f },
+ { SOCK_VECTOR, 1, "Axis", 0.0f, 0.0f, 1.0f, 0.0f, -1.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)
+{
+ float new_coord[3];
+
+ float ax[4];
+ float para[3];
+ float perp[3];
+ float cp[3];
+
+ float magsq, ndx;
+
+ float a = tex_input_value(in[1], coord, thread);
+ float cos_a = cos(a * 2 * M_PI);
+ float sin_a = sin(a * 2 * M_PI);
+
+ // x' = xcosa + n(n.x)(1-cosa)+(x*n)sina
+
+ tex_input_vec(ax, in[2], coord, thread);
+ magsq = ax[0]*ax[0] + ax[1]*ax[1] + ax[2]*ax[2];
+
+ if(magsq == 0) magsq = 1;
+
+ ndx = MTC_dot3Float(coord, ax);
+
+ para[0] = ax[0] * ndx * (1 - cos_a);
+ para[1] = ax[1] * ndx * (1 - cos_a);
+ para[2] = ax[2] * ndx * (1 - cos_a);
+
+ MTC_diff3Float(perp, coord, para);
+
+ perp[0] = coord[0] * cos_a;
+ perp[1] = coord[1] * cos_a;
+ perp[2] = coord[2] * cos_a;
+
+ MTC_cross3Float(cp, ax, coord);
+
+ cp[0] = cp[0] * sin_a;
+ cp[1] = cp[1] * sin_a;
+ cp[2] = cp[2] * sin_a;
+
+ new_coord[0] = para[0] + perp[0] + cp[0];
+ new_coord[1] = para[1] + perp[1] + cp[1];
+ new_coord[2] = para[2] + perp[2] + cp[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);
+
+ tex_do_preview(node, out[0], data);
+}
+
+bNodeType tex_node_rotate= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_ROTATE,
+ /* name */ "Rotate",
+ /* 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_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c
new file mode 100644
index 00000000000..884d2cd0eb6
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c
@@ -0,0 +1,103 @@
+/**
+ *
+ * ***** 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 "RE_shader_ext.h"
+
+static bNodeSocketType inputs[]= {
+ { SOCK_RGBA, 1, "Color1", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f },
+ { SOCK_RGBA, 1, "Color2", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+ { -1, 0, "" }
+};
+
+static bNodeSocketType outputs[]= {
+ { SOCK_RGBA, 0, "Color", 1.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)
+{
+ static float red[] = {1,0,0,1};
+ static float white[] = {1,1,1,1};
+
+ Tex *nodetex = (Tex *)node->id;
+
+ if(node->custom2) {
+ /* this node refers to its own texture tree! */
+ QUATCOPY(
+ out,
+ (fabs(coord[0] - coord[1]) < .01) ? white : red
+ );
+ }
+ else if(nodetex) {
+ TexResult texres;
+ int textype;
+ float nor[] = {0,0,0};
+ float col1[4], col2[4];
+
+ tex_input_rgba(col1, in[0], coord, thread);
+ tex_input_rgba(col2, in[1], coord, thread);
+
+ texres.nor = nor;
+ textype = multitex_ext(nodetex, coord, 0, 0, 0, &texres);
+
+ if(textype & TEX_RGB) {
+ QUATCOPY(out, &texres.tr);
+ }
+ else {
+ QUATCOPY(out, col1);
+ ramp_blend(MA_RAMP_BLEND, out, out+1, out+2, texres.tin, col2);
+ }
+ }
+}
+
+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_texture= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_TEXTURE,
+ /* name */ "Texture",
+ /* width+range */ 120, 80, 240,
+ /* class+opts */ NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW,
+ /* 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
new file mode 100644
index 00000000000..bd7e61d0ff4
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c
@@ -0,0 +1,78 @@
+/**
+ *
+ * ***** 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 <math.h>
+#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, "Offset", 0.0f, 0.0f, 0.0f, 0.0f, -1.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)
+{
+ float offset[3], new_coord[3];
+
+ tex_input_vec(offset, in[1], coord, thread);
+
+ new_coord[0] = coord[0] + offset[0];
+ new_coord[1] = coord[1] + offset[1];
+ new_coord[2] = coord[2] + offset[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);
+
+ tex_do_preview(node, out[0], data);
+}
+
+bNodeType tex_node_translate = {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_TRANSLATE,
+ /* name */ "Translate",
+ /* 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_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c
new file mode 100644
index 00000000000..ec59769fdfd
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c
@@ -0,0 +1,122 @@
+/**
+ * $Id: SHD_valToRgb.c 10456 2007-04-04 13:58:12Z jesterking $
+ *
+ * ***** 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"
+
+/* **************** VALTORGB ******************** */
+static bNodeSocketType valtorgb_in[]= {
+ { SOCK_VALUE, 1, "Fac", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+static bNodeSocketType valtorgb_out[]= {
+ { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void valtorgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+ if(node->storage) {
+ float fac = tex_input_value(in[0], coord, thread);
+
+ do_colorband(node->storage, fac, out);
+ }
+}
+
+static void valtorgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ tex_output(node, in, out[0], &valtorgb_colorfn);
+}
+
+static void valtorgb_init(bNode *node)
+{
+ node->storage = add_colorband(1);
+}
+
+bNodeType tex_node_valtorgb= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_VALTORGB,
+ /* name */ "ColorRamp",
+ /* width+range */ 240, 200, 300,
+ /* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS,
+ /* input sock */ valtorgb_in,
+ /* output sock */ valtorgb_out,
+ /* storage */ "ColorBand",
+ /* execfunc */ valtorgb_exec,
+ /* butfunc */ NULL,
+ /* initfunc */ valtorgb_init,
+ /* freestoragefunc */ node_free_standard_storage,
+ /* copystoragefunc */ node_copy_standard_storage,
+ /* id */ NULL
+
+};
+
+/* **************** RGBTOBW ******************** */
+static bNodeSocketType rgbtobw_in[]= {
+ { SOCK_RGBA, 1, "Color", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+static bNodeSocketType rgbtobw_out[]= {
+ { SOCK_VALUE, 0, "Val", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+
+static void rgbtobw_valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+ float cin[4];
+ tex_input_rgba(cin, in[0], coord, thread);
+
+ *out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f;
+}
+
+static void rgbtobw_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ tex_output(node, in, out[0], &rgbtobw_valuefn);
+
+ tex_do_preview(node, out[0], data);
+}
+
+bNodeType tex_node_rgbtobw= {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_RGBTOBW,
+ /* name */ "RGB to BW",
+ /* width+range */ 80, 40, 120,
+ /* class+opts */ NODE_CLASS_CONVERTOR, 0,
+ /* input sock */ rgbtobw_in,
+ /* output sock */ rgbtobw_out,
+ /* storage */ "",
+ /* execfunc */ rgbtobw_exec,
+ /* butfunc */ NULL,
+ /* initfunc */ NULL,
+ /* freestoragefunc */ NULL,
+ /* copystoragefunc */ NULL,
+ /* id */ NULL
+
+};
+
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c
new file mode 100644
index 00000000000..acdaacf873c
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c
@@ -0,0 +1,61 @@
+/**
+ *
+ * ***** 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, 1, "Color", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+ { -1, 0, "" }
+};
+static bNodeSocketType outputs[]= {
+ { -1, 0, "" }
+};
+
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ tex_do_preview(node, in[0], data);
+}
+
+bNodeType tex_node_viewer = {
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ TEX_NODE_VIEWER,
+ /* name */ "Viewer",
+ /* width+range */ 100, 60, 150,
+ /* class+opts */ NODE_CLASS_OUTPUT, NODE_PREVIEW,
+ /* 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_util.c b/source/blender/nodes/intern/TEX_util.c
new file mode 100644
index 00000000000..10fe3bab26c
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_util.c
@@ -0,0 +1,270 @@
+/**
+ *
+ * ***** 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 *****
+ */
+
+/*
+ HOW TEXTURE NODES WORK
+
+ In contrast to Shader nodes, which place a colour into the output
+ stack when executed, Texture nodes place a TexDelegate* there. To
+ obtain a colour value from this, a node further up the chain reads
+ the TexDelegate* from its input stack, and uses tex_call_delegate to
+ retrieve the colour from the delegate.
+*/
+
+#include <assert.h>
+#include "TEX_util.h"
+
+#define PREV_RES 128 /* default preview resolution */
+
+void tex_call_delegate(TexDelegate *dg, float *out, float *coord, short thread)
+{
+ dg->fn(out, coord, dg->node, dg->in, thread);
+}
+
+void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread)
+{
+ TexDelegate *dg = in->data;
+ if(dg) {
+ tex_call_delegate(dg, out, coord, thread);
+
+ if(in->hasoutput && in->sockettype == SOCK_VALUE) {
+ out[1] = out[2] = out[0];
+ out[3] = 1;
+ }
+ }
+ else {
+ QUATCOPY(out, in->vec);
+ }
+}
+
+void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread)
+{
+ tex_input_vec(out, in, coord, thread);
+
+ if(in->hasoutput && in->sockettype == SOCK_VECTOR) {
+ out[0] = out[0] * .5f + .5f;
+ out[1] = out[1] * .5f + .5f;
+ out[2] = out[2] * .5f + .5f;
+ out[3] = 1;
+ }
+}
+
+float tex_input_value(bNodeStack *in, float *coord, short thread)
+{
+ float out[4];
+ tex_input_vec(out, in, coord, thread);
+ return out[0];
+}
+
+static void init_preview(bNode *node)
+{
+ int xsize = node->prvr.xmax - node->prvr.xmin;
+ int ysize = node->prvr.ymax - node->prvr.ymin;
+
+ if(xsize == 0) {
+ xsize = PREV_RES;
+ ysize = PREV_RES;
+ }
+
+ if(node->preview==NULL)
+ node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
+
+ if(node->preview->rect)
+ if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
+ MEM_freeN(node->preview->rect);
+ node->preview->rect= NULL;
+ }
+
+ if(node->preview->rect==NULL) {
+ node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
+ node->preview->xsize= xsize;
+ node->preview->ysize= ysize;
+ }
+}
+
+void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata)
+{
+ int x, y;
+ float *result;
+ bNodePreview *preview;
+
+ if(!cdata->do_preview)
+ return;
+
+ if(!(node->typeinfo->flag & NODE_PREVIEW))
+ return;
+
+ init_preview(node);
+
+ preview = node->preview;
+
+ for(x=0; x<preview->xsize; x++)
+ for(y=0; y<preview->ysize; y++)
+ {
+ cdata->coord[0] = ((float) x / preview->xsize) * 2 - 1;
+ cdata->coord[1] = ((float) y / preview->ysize) * 2 - 1;
+
+ result = preview->rect + 4 * (preview->xsize*y + x);
+
+ tex_input_rgba(result, ns, cdata->coord, cdata->thread);
+ }
+}
+
+void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn)
+{
+ TexDelegate *dg;
+ if(!out->data)
+ /* Freed in tex_end_exec (node.c) */
+ dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
+ else
+ dg = out->data;
+
+
+ dg->fn = texfn;
+ dg->node = node;
+ memcpy(dg->in, in, MAX_SOCKET * sizeof(bNodeStack*));
+ dg->type = out->sockettype;
+}
+
+void ntreeTexCheckCyclics(struct bNodeTree *ntree)
+{
+ bNode *node;
+ for(node= ntree->nodes.first; node; node= node->next) {
+
+ if(node->type == TEX_NODE_TEXTURE && node->id)
+ {
+ /* custom2 stops the node from rendering */
+ if(node->custom1) {
+ node->custom2 = 1;
+ node->custom1 = 0;
+ } else {
+ Tex *tex = (Tex *)node->id;
+
+ node->custom2 = 0;
+
+ node->custom1 = 1;
+ if(tex->use_nodes && tex->nodetree) {
+ ntreeTexCheckCyclics(tex->nodetree);
+ }
+ node->custom1 = 0;
+ }
+ }
+
+ }
+}
+
+void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, Tex *tex, short which_output)
+{
+ TexResult dummy_texres;
+ TexCallData data;
+
+ if(!texres) texres = &dummy_texres;
+ data.coord = coord;
+ data.target = texres;
+ data.do_preview = do_preview;
+ data.thread = thread;
+ data.which_output = which_output;
+
+ ntreeExecTree(nodes, &data, thread);
+}
+
+void ntreeTexUpdatePreviews(bNodeTree* nodetree)
+{
+ Tex *tex;
+ float coord[] = {0,0,0};
+ TexResult dummy_texres;
+
+ for(tex= G.main->tex.first; tex; tex= tex->id.next)
+ if(tex->nodetree == nodetree) break;
+ if(!tex) return;
+
+ dummy_texres.nor = 0;
+
+ ntreeBeginExecTree(nodetree);
+ ntreeTexExecTree(nodetree, &dummy_texres, coord, 1, 0, tex, 0);
+ ntreeEndExecTree(nodetree);
+
+}
+
+char* ntreeTexOutputMenu(bNodeTree *ntree)
+{
+ bNode *node;
+ int len = 1;
+ char *str;
+ char ctrl[4];
+ int index = 0;
+
+ for(node= ntree->nodes.first; node; node= node->next)
+ if(node->type == TEX_NODE_OUTPUT) {
+ len += strlen(
+ ((TexNodeOutput*)node->storage)->name
+ ) + strlen(" %xNNN|");
+ index ++;
+
+ if(node->custom1 > 999) {
+ printf("Error: too many outputs");
+ break;
+ }
+ }
+
+ str = malloc(len * sizeof(char));
+ *str = 0;
+
+ for(node= ntree->nodes.first; node; node= node->next)
+ if(node->type == TEX_NODE_OUTPUT) {
+ strcat(str, ((TexNodeOutput*)node->storage)->name);
+ strcat(str, " %x");
+
+ sprintf(ctrl, "%d", node->custom1);
+ strcat(str, ctrl);
+
+ if(--index)
+ strcat(str, "|");
+ else
+ break;
+ }
+
+ return str;
+}
+
+void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node)
+{
+ bNode *tnode;
+ int index = 0;
+
+ check_index:
+ for(tnode= ntree->nodes.first; tnode; tnode= tnode->next)
+ if(tnode->type == TEX_NODE_OUTPUT && tnode != node)
+ if(tnode->custom1 == index) {
+ index ++;
+ goto check_index;
+ }
+
+ node->custom1 = index;
+}
+
diff --git a/source/blender/nodes/intern/TEX_util.h b/source/blender/nodes/intern/TEX_util.h
new file mode 100644
index 00000000000..69cf20794c9
--- /dev/null
+++ b/source/blender/nodes/intern/TEX_util.h
@@ -0,0 +1,104 @@
+/**
+ *
+ * ***** 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 *****
+ */
+
+#ifndef TEX_NODE_UTIL_H_
+#define TEX_NODE_UTIL_H_
+
+#include <math.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_action_types.h"
+#include "DNA_color_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_ID.h"
+#include "DNA_image_types.h"
+#include "DNA_material_types.h"
+#include "DNA_node_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BKE_blender.h"
+#include "BKE_colortools.h"
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
+#include "BKE_texture.h"
+#include "BKE_utildefines.h"
+#include "BKE_library.h"
+
+#include "../SHD_node.h"
+#include "node_util.h"
+
+#include "BLI_arithb.h"
+#include "BLI_blenlib.h"
+#include "BLI_rand.h"
+#include "BLI_threads.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h"
+
+typedef struct TexCallData {
+ TexResult *target;
+ float *coord;
+ char do_preview;
+ short thread;
+ short which_output;
+} TexCallData;
+
+typedef void(*TexFn) (float *out, float *coord, bNode *node, bNodeStack **in, short thread);
+
+typedef struct TexDelegate {
+ TexFn fn;
+ bNode *node;
+ bNodeStack *in[MAX_SOCKET];
+ int type;
+} TexDelegate;
+
+void tex_call_delegate(TexDelegate*, float *out, float *coord, short thread);
+
+void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread);
+void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread);
+float tex_input_value(bNodeStack *in, float *coord, short thread);
+
+void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn);
+void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata);
+
+void ntreeTexUpdatePreviews( bNodeTree* nodetree );
+void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, struct Tex *tex, short which_output);
+
+#endif