diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-09-06 01:01:50 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-09-06 01:01:50 +0400 |
commit | 8e0fe8bff72e2dc2926618577eaffdd3417a8304 (patch) | |
tree | 43b933c88cac451518dc68846c1119acacffca4f /source/blender/nodes/intern/TEX_nodes | |
parent | 6e9ff495eb082aeb49e6a1da23a7827d3fcd0fde (diff) |
Merged the particles-2010 branch with node improvements into trunk.
This branch adds mostly organizational improvements to the node system by renaming the node folders and files. A couple of internal features have been added too.
Detailed information can be found on the wiki page:
http://wiki.blender.org/index.php/User:Phonybone/Particles2010
Diffstat (limited to 'source/blender/nodes/intern/TEX_nodes')
22 files changed, 0 insertions, 2445 deletions
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_at.c b/source/blender/nodes/intern/TEX_nodes/TEX_at.c deleted file mode 100644 index d5980b786b0..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_at.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): R Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_at.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.h" - -static bNodeSocketType inputs[]= { - { SOCK_RGBA, 1, "Texture", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, - { SOCK_VECTOR, 1, "Coordinates", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, - { -1, 0, "" } -}; -static bNodeSocketType outputs[]= { - { SOCK_RGBA, 0, "Texture", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - TexParams np = *p; - float new_co[3]; - np.co = new_co; - - tex_input_vec(new_co, in[1], p, thread); - tex_input_rgba(out, in[0], &np, thread); -} - -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &colorfn, data); -} - -void register_node_type_tex_at(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT, 0, - inputs, outputs); - node_type_size(&ntype, 140, 100, 320); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c deleted file mode 100644 index 0eb982496a9..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_bricks.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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 float noise(int n) /* fast integer noise */ -{ - int nn; - n = (n >> 13) ^ n; - nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; - return 0.5f * ((float)nn / 1073741824.0f); -} - -static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float *co = p->co; - - float x = co[0]; - float y = co[1]; - - int bricknum, rownum; - float 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], p, thread); - float bias = tex_input_value(in[4], p, thread); - float brick_width = tex_input_value(in[5], p, thread); - float row_height = tex_input_value(in[6], p, thread); - - tex_input_rgba(bricks1, in[0], p, thread); - tex_input_rgba(bricks2, in[1], p, thread); - tex_input_rgba(mortar, in[2], p, thread); - - rownum = (int)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 = (int)floor((x+offset) / brick_width); - - ins_x = (x+offset) - brick_width*bricknum; - ins_y = y - row_height*rownum; - - tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + 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, data); -} - -void register_node_type_tex_bricks(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW|NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 150, 60, 150); - node_type_init(&ntype, init); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c deleted file mode 100644 index c6c25ba1a8a..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_checker.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float x = p->co[0]; - float y = p->co[1]; - float z = p->co[2]; - float sz = tex_input_value(in[2], p, thread); - - /* 0.00001 because of unit sized stuff */ - int xi = (int)fabs(floor(0.00001f + x / sz)); - int yi = (int)fabs(floor(0.00001f + y / sz)); - int zi = (int)fabs(floor(0.00001f + z / sz)); - - if( (xi % 2 == yi % 2) == (zi % 2) ) { - tex_input_rgba(out, in[0], p, thread); - } else { - tex_input_rgba(out, in[1], p, thread); - } -} - -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &colorfn, data); -} - -void register_node_type_tex_checker(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN, NODE_PREVIEW|NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 100, 60, 150); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c deleted file mode 100644 index 6eae78ec3de..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_compose.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - int i; - for(i = 0; i < 4; i++) - out[i] = tex_input_value(in[i], p, thread); -} - -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &colorfn, data); -} - -void register_node_type_tex_compose(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_COMPOSE, "Compose RGBA", NODE_CLASS_OP_COLOR, 0, - inputs, outputs); - node_type_size(&ntype, 100, 60, 150); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c deleted file mode 100644 index 3c46971f0d4..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti@gmx.net>. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_coord.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.h" - -static bNodeSocketType outputs[]= { - { SOCK_VECTOR, 0, "Coordinates", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, - { -1, 0, "" } -}; - -static void vectorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **UNUSED(in), short UNUSED(thread)) -{ - out[0] = p->co[0]; - out[1] = p->co[1]; - out[2] = p->co[2]; -} - -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &vectorfn, data); -} - -void register_node_type_tex_coord(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, NODE_OPTIONS, - NULL, outputs); - node_type_size(&ntype, 120, 110, 160); - node_type_storage(&ntype, "node_coord", NULL, NULL); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c deleted file mode 100644 index b7af6c748ff..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_curves.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread)) -{ - /* stack order output: fac */ - float fac= 0.0f; - - if(node->custom1 < node->custom2) - fac = (p->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, data); -} - - -static void time_init(bNode* node) -{ - node->custom1= 1; - node->custom2= 250; - node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); -} - -void register_node_type_tex_curve_time(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, NODE_OPTIONS, - NULL, time_outputs); - node_type_size(&ntype, 140, 100, 320); - node_type_init(&ntype, time_init); - node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_exec(&ntype, time_exec); - - nodeRegisterType(lb, &ntype); -} - -/* **************** 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, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float cin[4]; - tex_input_rgba(cin, in[0], p, 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, data); -} - -static void rgb_init(bNode *node) -{ - node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); -} - -void register_node_type_tex_curve_rgb(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, NODE_OPTIONS, - rgb_inputs, rgb_outputs); - node_type_size(&ntype, 200, 140, 320); - node_type_init(&ntype, rgb_init); - node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_exec(&ntype, rgb_exec); - - nodeRegisterType(lb, &ntype); -} - diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c deleted file mode 100644 index f27d8c98716..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_decompose.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.h" -#include <math.h> - -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_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, "" } -}; - -static void valuefn_r(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[0]; -} - -static void valuefn_g(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[1]; -} - -static void valuefn_b(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[2]; -} - -static void valuefn_a(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[3]; -} - -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &valuefn_r, data); - tex_output(node, in, out[1], &valuefn_g, data); - tex_output(node, in, out[2], &valuefn_b, data); - tex_output(node, in, out[3], &valuefn_a, data); -} - -void register_node_type_tex_decompose(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_DECOMPOSE, "Decompose RGBA", NODE_CLASS_OP_COLOR, 0, - inputs, outputs); - node_type_size(&ntype, 100, 60, 150); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c deleted file mode 100644 index b460844ba4a..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti@gmx.net>. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_distance.c - * \ingroup texnodes - */ - - -#include <math.h> -#include "BLI_math.h" -#include "../TEX_util.h" -#include "TEX_node.h" - -static bNodeSocketType inputs[]= { - { SOCK_VECTOR, 1, "Coordinate 1", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, - { SOCK_VECTOR, 1, "Coordinate 2", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float co1[3], co2[3]; - - tex_input_vec(co1, in[0], p, thread); - tex_input_vec(co2, in[1], p, thread); - - *out = len_v3v3(co2, co1); -} - -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &valuefn, data); -} - -void register_node_type_tex_distance(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTOR, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 120, 110, 160); - node_type_storage(&ntype, "node_distance", NULL, NULL); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c deleted file mode 100644 index 471d8db2c03..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.h" - - -static bNodeSocketType inputs[]= { - { 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, "" } -}; - -static void do_hue_sat_fac(bNode *UNUSED(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.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f; - hsv[1]*= sat; - if(hsv[1]>1.0f) hsv[1]= 1.0f; else if(hsv[1]<0.0f) hsv[1]= 0.0f; - hsv[2]*= val; - if(hsv[2]>1.0f) hsv[2]= 1.0f; else if(hsv[2]<0.0f) hsv[2]= 0.0f; - 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, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float hue = tex_input_value(in[0], p, thread); - float sat = tex_input_value(in[1], p, thread); - float val = tex_input_value(in[2], p, thread); - float fac = tex_input_value(in[3], p, thread); - - float col[4]; - tex_input_rgba(col, in[4], p, thread); - - 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) -{ - tex_output(node, in, out[0], &colorfn, data); -} - -void register_node_type_tex_hue_sat(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 150, 80, 250); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c deleted file mode 100644 index a54ca4bb119..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * $Id$ - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_image.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread)) -{ - float x = p->co[0]; - float y = p->co[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 ) { - BLI_lock_thread(LOCK_IMAGE); - if( !ibuf->rect_float ) - IMB_float_from_rect(ibuf); - BLI_unlock_thread(LOCK_IMAGE); - } - - 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, 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; -} - -void register_node_type_tex_image(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW|NODE_OPTIONS, - NULL, outputs); - node_type_size(&ntype, 120, 80, 300); - node_type_init(&ntype, init); - node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c deleted file mode 100644 index e908bdcff07..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_invert.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float col[4]; - - tex_input_rgba(col, in[0], p, 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, data); -} - -void register_node_type_tex_invert(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 90, 80, 100); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} - diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c deleted file mode 100644 index 18468bdd55c..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_math.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float in0 = tex_input_value(in[0], p, thread); - float in1 = tex_input_value(in[1], p, 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 */ - { - /* Only raise negative numbers by full integers */ - if( in0 >= 0 ) { - out[0]= pow(in0, in1); - } else { - float y_mod_1 = fmod(in1, 1); - if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { - *out = pow(in0, floor(in1 + 0.5f)); - } 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= (in0<0)?(int)(in0 - 0.5f):(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); - } -} - -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &valuefn, data); -} - -void register_node_type_tex_math(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 120, 110, 160); - node_type_label(&ntype, node_math_label); - node_type_storage(&ntype, "node_math", NULL, NULL); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} - diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c deleted file mode 100644 index c7668c27b99..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_mixRgb.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float fac = tex_input_value(in[0], p, thread); - float col1[4], col2[4]; - - tex_input_rgba(col1, in[1], p, thread); - tex_input_rgba(col2, in[2], p, 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, data); -} - -void register_node_type_tex_mix_rgb(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 100, 60, 150); - node_type_label(&ntype, node_blend_label); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c deleted file mode 100644 index 046ad724507..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_output.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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 **UNUSED(out)) -{ - TexCallData *cdata = (TexCallData *)data; - TexResult *target = cdata->target; - - if(cdata->do_preview) { - TexParams params; - params_from_cdata(¶ms, cdata); - - if(in[1] && in[1]->hasinput && !in[0]->hasinput) - tex_input_rgba(&target->tr, in[1], ¶ms, cdata->thread); - else - tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); - tex_do_preview(node, params.co, &target->tr); - } - else { - /* 0 means don't care, so just use first */ - if(cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) { - TexParams params; - params_from_cdata(¶ms, cdata); - - tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); - - target->tin = (target->tr + target->tg + target->tb) / 3.0f; - target->talpha = 1; - - if(target->nor) { - if(in[1] && in[1]->hasinput) - tex_input_vec(target->nor, in[1], ¶ms, cdata->thread); - else - target->nor = NULL; - } - } - } -} - -static void unique_name(bNode *node) -{ - TexNodeOutput *tno = (TexNodeOutput *)node->storage; - char *new_name = NULL; - int new_len = 0; - int suffix; - bNode *i; - char *name = tno->name; - - i = node; - while(i->prev) i = i->prev; - for(; i; i=i->next) { - if( - i == node || - i->type != TEX_NODE_OUTPUT || - strcmp(name, ((TexNodeOutput*)(i->storage))->name) - ) - continue; - - if(!new_name) { - int len = strlen(name); - if(len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { - new_len = len; - } else { - suffix = 0; - new_len = len + 4; - if(new_len > 31) - new_len = 31; - } - - new_name = MEM_mallocN(new_len + 1, "new_name"); - strcpy(new_name, name); - name = new_name; - } - sprintf(new_name + new_len - 4, ".%03d", ++suffix); - } - - if(new_name) { - strcpy(tno->name, new_name); - MEM_freeN(new_name); - } -} - -static void assign_index(struct bNode *node) -{ - bNode *tnode; - int index = 1; - - tnode = node; - while(tnode->prev) - tnode = tnode->prev; - - check_index: - for(; tnode; tnode= tnode->next) - if(tnode->type == TEX_NODE_OUTPUT && tnode != node) - if(tnode->custom1 == index) { - index ++; - goto check_index; - } - - node->custom1 = index; -} - -static void init(bNode *node) -{ - TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); - node->storage= tno; - - strcpy(tno->name, "Default"); - unique_name(node); - assign_index(node); -} - -static void copy(bNode *orig, bNode *new) -{ - node_copy_standard_storage(orig, new); - unique_name(new); - assign_index(new); -} - -void register_node_type_tex_output(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW|NODE_OPTIONS, - inputs, NULL); - node_type_size(&ntype, 150, 60, 200); - node_type_init(&ntype, init); - node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c deleted file mode 100644 index 294c1f7322f..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_proc.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, 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_nodes(tex, p->co, p->dxt, p->dyt, p->osatex, - &texres, thread, 0, p->shi, p->mtex); - - 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, TexParams *p, short thread); - -static void texfn( - float *result, - TexParams *p, - 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], p, thread); - tex_input_rgba(col2, in[1], p, thread); - - map_inputs(&tex, in, p, thread); - - do_proc(result, p, 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 *UNUSED(tex), bNodeStack **UNUSED(in), TexParams *UNUSED(p), short UNUSED(thread)) \ - {} - -#define ProcDef(name) \ - static void name##_colorfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ - { \ - texfn(result, p, node, in, 0, &name##_map_inputs, thread); \ - } \ - static void name##_normalfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ - { \ - texfn(result, p, 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, data); \ - if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn, 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, TexParams *p, short thread) -{ - tex->vn_w1 = tex_input_value(in[I+0], p, thread); - tex->vn_w2 = tex_input_value(in[I+1], p, thread); - tex->vn_w3 = tex_input_value(in[I+2], p, thread); - tex->vn_w4 = tex_input_value(in[I+3], p, thread); - - tex->ns_outscale = tex_input_value(in[I+4], p, thread); - tex->noisesize = tex_input_value(in[I+5], p, 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, TexParams *p, short thread) -{ - tex->turbul = tex_input_value(in[I+0], p, 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, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I+0], p, thread); - tex->turbul = tex_input_value(in[I+1], p, 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, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I+0], p, 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, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I+0], p, thread); - tex->dist_amount = tex_input_value(in[I+1], p, 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, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I+0], p, thread); - tex->turbul = tex_input_value(in[I+1], p, 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, TexParams *p, short thread) -{ - tex->mg_H = tex_input_value(in[I+0], p, thread); - tex->mg_lacunarity = tex_input_value(in[I+1], p, thread); - tex->mg_octaves = tex_input_value(in[I+2], p, thread); - tex->ns_outscale = tex_input_value(in[I+3], p, thread); - tex->noisesize = tex_input_value(in[I+4], p, 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, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I+0], p, thread); - tex->turbul = tex_input_value(in[I+1], p, 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) \ -void register_node_type_tex_proc_##name(ListBase *lb) \ -{ \ - static bNodeType ntype; \ - \ - node_type_base(&ntype, TEX_NODE_PROC+TEXTYPE, Name, NODE_CLASS_TEXTURE, NODE_PREVIEW|NODE_OPTIONS, name##_inputs, outputs); \ - node_type_size(&ntype, 140, 80, 140); \ - node_type_init(&ntype, init); \ - node_type_storage(&ntype, "Tex", node_free_standard_storage, node_copy_standard_storage); \ - node_type_exec(&ntype, name##_exec); \ - \ - nodeRegisterType(lb, &ntype); \ -} - -#define C outputs_color_only -#define CV outputs_both - -TexDef(TEX_VORONOI, CV, voronoi, "Voronoi" ) -TexDef(TEX_BLEND, C, blend, "Blend" ) -TexDef(TEX_MAGIC, C, magic, "Magic" ) -TexDef(TEX_MARBLE, CV, marble, "Marble" ) -TexDef(TEX_CLOUDS, CV, clouds, "Clouds" ) -TexDef(TEX_WOOD, CV, wood, "Wood" ) -TexDef(TEX_MUSGRAVE, CV, musgrave, "Musgrave" ) -TexDef(TEX_NOISE, C, noise, "Noise" ) -TexDef(TEX_STUCCI, CV, stucci, "Stucci" ) -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 deleted file mode 100644 index 1be6152a2b3..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_rotate.c - * \ingroup texnodes - */ - - -#include <math.h> - -#include "../TEX_util.h" -#include "TEX_node.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 rotate(float new_co[3], float a, float ax[3], float co[3]) -{ - float para[3]; - float perp[3]; - float cp[3]; - - float cos_a = cos(a * (float)(2*M_PI)); - float sin_a = sin(a * (float)(2*M_PI)); - - // x' = xcosa + n(n.x)(1-cosa) + (x*n)sina - - mul_v3_v3fl(perp, co, cos_a); - mul_v3_v3fl(para, ax, dot_v3v3(co, ax)*(1 - cos_a)); - - cross_v3_v3v3(cp, ax, co); - mul_v3_fl(cp, sin_a); - - new_co[0] = para[0] + perp[0] + cp[0]; - new_co[1] = para[1] + perp[1] + cp[1]; - new_co[2] = para[2] + perp[2] + cp[2]; -} - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float new_co[3], new_dxt[3], new_dyt[3], a, ax[3]; - - a= tex_input_value(in[1], p, thread); - tex_input_vec(ax, in[2], p, thread); - - rotate(new_co, a, ax, p->co); - if (p->osatex) { - rotate(new_dxt, a, ax, p->dxt); - rotate(new_dyt, a, ax, p->dyt); - } - - { - TexParams np = *p; - np.co = new_co; - np.dxt = new_dxt; - np.dyt = new_dyt; - tex_input_rgba(out, in[0], &np, thread); - } -} -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &colorfn, data); -} - -void register_node_type_tex_rotate(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 140, 100, 320); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c deleted file mode 100644 index cfffcfda2e5..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_scale.c - * \ingroup texnodes - */ - - -#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, "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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float scale[3], new_co[3], new_dxt[3], new_dyt[3]; - TexParams np = *p; - - np.co = new_co; - np.dxt = new_dxt; - np.dyt = new_dyt; - - tex_input_vec(scale, in[1], p, thread); - - mul_v3_v3v3(new_co, p->co, scale); - if (p->osatex) { - mul_v3_v3v3(new_dxt, p->dxt, scale); - mul_v3_v3v3(new_dyt, p->dyt, scale); - } - - tex_input_rgba(out, in[0], &np, thread); -} -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &colorfn, data); -} - -void register_node_type_tex_scale(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 90, 80, 100); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c deleted file mode 100644 index c58595866af..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_texture.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - Tex *nodetex = (Tex *)node->id; - static float red[] = {1,0,0,1}; - static float white[] = {1,1,1,1}; - float co[3], dxt[3], dyt[3]; - - copy_v3_v3(co, p->co); - copy_v3_v3(dxt, p->dxt); - copy_v3_v3(dyt, p->dyt); - - if(node->custom2 || node->need_exec==0) { - /* this node refers to its own texture tree! */ - QUATCOPY(out, (fabs(co[0] - co[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], p, thread); - tex_input_rgba(col2, in[1], p, thread); - - texres.nor = nor; - textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex, - &texres, thread, 0, p->shi, p->mtex); - - 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, data); -} - -void register_node_type_tex_texture(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW|NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 120, 80, 240); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c deleted file mode 100644 index 8f7d6d837d7..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_translate.c - * \ingroup texnodes - */ - - -#include <math.h> -#include "../TEX_util.h" -#include "TEX_node.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, -10000.0f, 10000.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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float offset[3], new_co[3]; - TexParams np = *p; - np.co = new_co; - - tex_input_vec(offset, in[1], p, thread); - - new_co[0] = p->co[0] + offset[0]; - new_co[1] = p->co[1] + offset[1]; - new_co[2] = p->co[2] + offset[2]; - - tex_input_rgba(out, in[0], &np, thread); -} -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, in, out[0], &colorfn, data); -} - -void register_node_type_tex_translate(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 90, 80, 100); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c deleted file mode 100644 index e430c0c9a95..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_valToNor.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float new_co[3]; - float *co = p->co; - - float nabla = tex_input_value(in[1], p, thread); - float val; - float nor[3]; - - TexParams np = *p; - np.co = new_co; - - val = tex_input_value(in[0], p, thread); - - new_co[0] = co[0] + nabla; - new_co[1] = co[1]; - new_co[2] = co[2]; - nor[0] = tex_input_value(in[0], &np, thread); - - new_co[0] = co[0]; - new_co[1] = co[1] + nabla; - nor[1] = tex_input_value(in[0], &np, thread); - - new_co[1] = co[1]; - new_co[2] = co[2] + nabla; - nor[2] = tex_input_value(in[0], &np, 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, data); -} - -void register_node_type_tex_valtonor(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTOR, NODE_OPTIONS, - inputs, outputs); - node_type_size(&ntype, 90, 80, 100); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c deleted file mode 100644 index 8f59828081c..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * $Id$ - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_valToRgb.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - if(node->storage) { - float fac = tex_input_value(in[0], p, 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, data); -} - -static void valtorgb_init(bNode *node) -{ - node->storage = add_colorband(1); -} - -void register_node_type_tex_valtorgb(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, NODE_OPTIONS, - valtorgb_in, valtorgb_out); - node_type_size(&ntype, 240, 200, 300); - node_type_init(&ntype, valtorgb_init); - node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, valtorgb_exec); - - nodeRegisterType(lb, &ntype); -} - -/* **************** 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, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float cin[4]; - tex_input_rgba(cin, in[0], p, 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, data); -} - -void register_node_type_tex_rgbtobw(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0, - rgbtobw_in, rgbtobw_out); - node_type_size(&ntype, 80, 40, 120); - node_type_exec(&ntype, rgbtobw_exec); - - nodeRegisterType(lb, &ntype); -} - diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c deleted file mode 100644 index e917e525e17..00000000000 --- a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/intern/TEX_nodes/TEX_viewer.c - * \ingroup texnodes - */ - - -#include "../TEX_util.h" -#include "TEX_node.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 **UNUSED(out)) -{ - TexCallData *cdata = (TexCallData *)data; - - if(cdata->do_preview) { - TexParams params; - float col[4]; - params_from_cdata(¶ms, cdata); - - tex_input_rgba(col, in[0], ¶ms, cdata->thread); - tex_do_preview(node, params.previewco, col); - } -} - -void register_node_type_tex_viewer(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW, - inputs, outputs); - node_type_size(&ntype, 100, 60, 150); - node_type_exec(&ntype, exec); - - nodeRegisterType(lb, &ntype); -} |