2.5: merge with trunk, previous merge was only up to yesterday.
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r17416:HEAD
This commit is contained in:
48
source/blender/nodes/intern/TEX_nodes/Makefile
Normal file
48
source/blender/nodes/intern/TEX_nodes/Makefile
Normal file
@@ -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)
|
||||
123
source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
Normal file
123
source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
Normal file
@@ -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
|
||||
|
||||
};
|
||||
85
source/blender/nodes/intern/TEX_nodes/TEX_checker.c
Normal file
85
source/blender/nodes/intern/TEX_nodes/TEX_checker.c
Normal file
@@ -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
|
||||
|
||||
};
|
||||
127
source/blender/nodes/intern/TEX_nodes/TEX_curves.c
Normal file
127
source/blender/nodes/intern/TEX_nodes/TEX_curves.c
Normal file
@@ -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
|
||||
};
|
||||
|
||||
104
source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
Normal file
104
source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
Normal file
@@ -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
|
||||
|
||||
};
|
||||
|
||||
|
||||
106
source/blender/nodes/intern/TEX_nodes/TEX_image.c
Normal file
106
source/blender/nodes/intern/TEX_nodes/TEX_image.c
Normal file
@@ -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
|
||||
};
|
||||
|
||||
79
source/blender/nodes/intern/TEX_nodes/TEX_invert.c
Normal file
79
source/blender/nodes/intern/TEX_nodes/TEX_invert.c
Normal file
@@ -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
|
||||
};
|
||||
|
||||
172
source/blender/nodes/intern/TEX_nodes/TEX_math.c
Normal file
172
source/blender/nodes/intern/TEX_nodes/TEX_math.c
Normal file
@@ -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
|
||||
};
|
||||
|
||||
81
source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c
Normal file
81
source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c
Normal file
@@ -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
|
||||
|
||||
};
|
||||
90
source/blender/nodes/intern/TEX_nodes/TEX_output.c
Normal file
90
source/blender/nodes/intern/TEX_nodes/TEX_output.c
Normal file
@@ -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
|
||||
};
|
||||
310
source/blender/nodes/intern/TEX_nodes/TEX_proc.c
Normal file
310
source/blender/nodes/intern/TEX_nodes/TEX_proc.c
Normal file
@@ -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" );
|
||||
|
||||
114
source/blender/nodes/intern/TEX_nodes/TEX_rotate.c
Normal file
114
source/blender/nodes/intern/TEX_nodes/TEX_rotate.c
Normal file
@@ -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
|
||||
};
|
||||
|
||||
103
source/blender/nodes/intern/TEX_nodes/TEX_texture.c
Normal file
103
source/blender/nodes/intern/TEX_nodes/TEX_texture.c
Normal file
@@ -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
|
||||
|
||||
};
|
||||
|
||||
78
source/blender/nodes/intern/TEX_nodes/TEX_translate.c
Normal file
78
source/blender/nodes/intern/TEX_nodes/TEX_translate.c
Normal file
@@ -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
|
||||
};
|
||||
|
||||
122
source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c
Normal file
122
source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c
Normal file
@@ -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
|
||||
|
||||
};
|
||||
|
||||
61
source/blender/nodes/intern/TEX_nodes/TEX_viewer.c
Normal file
61
source/blender/nodes/intern/TEX_nodes/TEX_viewer.c
Normal file
@@ -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
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user