forked from bartvdbraak/blender
Added compose/decompose, fixed bugs.
This commit is contained in:
parent
8837d69ed3
commit
fbdd75a475
@ -403,6 +403,8 @@ struct TexResult;
|
||||
#define TEX_NODE_TRANSLATE 116
|
||||
#define TEX_NODE_COORD 117
|
||||
#define TEX_NODE_DISTANCE 118
|
||||
#define TEX_NODE_COMPOSE 119
|
||||
#define TEX_NODE_DECOMPOSE 120
|
||||
|
||||
/* 201-299 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */
|
||||
#define TEX_NODE_PROC 200
|
||||
|
@ -2888,6 +2888,8 @@ static void registerTextureNodes(ListBase *ntypelist)
|
||||
nodeRegisterType(ntypelist, &tex_node_hue_sat);
|
||||
nodeRegisterType(ntypelist, &tex_node_coord);
|
||||
nodeRegisterType(ntypelist, &tex_node_distance);
|
||||
nodeRegisterType(ntypelist, &tex_node_compose);
|
||||
nodeRegisterType(ntypelist, &tex_node_decompose);
|
||||
|
||||
nodeRegisterType(ntypelist, &tex_node_output);
|
||||
nodeRegisterType(ntypelist, &tex_node_viewer);
|
||||
|
@ -58,6 +58,9 @@ extern bNodeType tex_node_distance;
|
||||
extern bNodeType tex_node_rotate;
|
||||
extern bNodeType tex_node_translate;
|
||||
|
||||
extern bNodeType tex_node_compose;
|
||||
extern bNodeType tex_node_decompose;
|
||||
|
||||
extern bNodeType tex_node_proc_voronoi;
|
||||
extern bNodeType tex_node_proc_blend;
|
||||
extern bNodeType tex_node_proc_magic;
|
||||
|
71
source/blender/nodes/intern/TEX_nodes/TEX_compose.c
Normal file
71
source/blender/nodes/intern/TEX_nodes/TEX_compose.c
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "../TEX_util.h"
|
||||
|
||||
static bNodeSocketType inputs[]= {
|
||||
{ SOCK_VALUE, 1, "Red", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ SOCK_VALUE, 1, "Green", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ SOCK_VALUE, 1, "Blue", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
static bNodeSocketType outputs[]= {
|
||||
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 4; i++)
|
||||
out[i] = tex_input_value(in[i], coord, thread);
|
||||
}
|
||||
|
||||
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
tex_output(node, in, out[0], &colorfn);
|
||||
}
|
||||
|
||||
bNodeType tex_node_compose= {
|
||||
/* *next,*prev */ NULL, NULL,
|
||||
/* type code */ TEX_NODE_COMPOSE,
|
||||
/* name */ "Compose RGBA",
|
||||
/* width+range */ 100, 60, 150,
|
||||
/* class+opts */ NODE_CLASS_OP_COLOR, 0,
|
||||
/* input sock */ inputs,
|
||||
/* output sock */ outputs,
|
||||
/* storage */ "",
|
||||
/* execfunc */ exec,
|
||||
/* butfunc */ NULL,
|
||||
/* initfunc */ NULL,
|
||||
/* freestoragefunc */ NULL,
|
||||
/* copystoragefunc */ NULL,
|
||||
/* id */ NULL
|
||||
|
||||
};
|
92
source/blender/nodes/intern/TEX_nodes/TEX_decompose.c
Normal file
92
source/blender/nodes/intern/TEX_nodes/TEX_decompose.c
Normal file
@ -0,0 +1,92 @@
|
||||
/**
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "../TEX_util.h"
|
||||
#include <math.h>
|
||||
|
||||
static bNodeSocketType inputs[]= {
|
||||
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
static bNodeSocketType outputs[]= {
|
||||
{ SOCK_VALUE, 1, "Red", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ SOCK_VALUE, 1, "Green", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ SOCK_VALUE, 1, "Blue", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void valuefn_r(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
|
||||
{
|
||||
tex_input_rgba(out, in[0], coord, thread);
|
||||
*out = out[0];
|
||||
}
|
||||
|
||||
static void valuefn_g(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
|
||||
{
|
||||
tex_input_rgba(out, in[0], coord, thread);
|
||||
*out = out[1];
|
||||
}
|
||||
|
||||
static void valuefn_b(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
|
||||
{
|
||||
tex_input_rgba(out, in[0], coord, thread);
|
||||
*out = out[2];
|
||||
}
|
||||
|
||||
static void valuefn_a(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
|
||||
{
|
||||
tex_input_rgba(out, in[0], coord, thread);
|
||||
*out = out[3];
|
||||
}
|
||||
|
||||
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
tex_output(node, in, out[0], &valuefn_r);
|
||||
tex_output(node, in, out[1], &valuefn_g);
|
||||
tex_output(node, in, out[2], &valuefn_b);
|
||||
tex_output(node, in, out[3], &valuefn_a);
|
||||
}
|
||||
|
||||
bNodeType tex_node_decompose= {
|
||||
/* *next,*prev */ NULL, NULL,
|
||||
/* type code */ TEX_NODE_DECOMPOSE,
|
||||
/* name */ "Decompose RGBA",
|
||||
/* width+range */ 100, 60, 150,
|
||||
/* class+opts */ NODE_CLASS_OP_COLOR, 0,
|
||||
/* input sock */ inputs,
|
||||
/* output sock */ outputs,
|
||||
/* storage */ "",
|
||||
/* execfunc */ exec,
|
||||
/* butfunc */ NULL,
|
||||
/* initfunc */ NULL,
|
||||
/* freestoragefunc */ NULL,
|
||||
/* copystoragefunc */ NULL,
|
||||
/* id */ NULL
|
||||
|
||||
};
|
@ -30,16 +30,16 @@
|
||||
|
||||
|
||||
static bNodeSocketType inputs[]= {
|
||||
{ SOCK_VALUE, 1, "Hue", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{ SOCK_VALUE, 1, "Saturation", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f},
|
||||
{ SOCK_VALUE, 1, "Value", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f},
|
||||
{ SOCK_VALUE, 1, "Fac", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{ SOCK_RGBA, 1, "Color", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
|
||||
{ -1, 0, "" }
|
||||
{ SOCK_VALUE, 1, "Hue", 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f },
|
||||
{ SOCK_VALUE, 1, "Saturation", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f },
|
||||
{ SOCK_VALUE, 1, "Value", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f },
|
||||
{ SOCK_VALUE, 1, "Factor", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ SOCK_RGBA, 1, "Color", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f },
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
static bNodeSocketType outputs[]= {
|
||||
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
||||
{ -1, 0, "" }
|
||||
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void do_hue_sat_fac(bNode *node, float *out, float hue, float sat, float val, float *in, float fac)
|
||||
@ -67,15 +67,19 @@ static void do_hue_sat_fac(bNode *node, float *out, float hue, float sat, float
|
||||
|
||||
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
|
||||
{
|
||||
float in0 = tex_input_value(in[0], coord, thread);
|
||||
float in1 = tex_input_value(in[1], coord, thread);
|
||||
float in2 = tex_input_value(in[2], coord, thread);
|
||||
float in3 = tex_input_value(in[3], coord, thread);
|
||||
float hue = tex_input_value(in[0], coord, thread);
|
||||
float sat = tex_input_value(in[1], coord, thread);
|
||||
float val = tex_input_value(in[2], coord, thread);
|
||||
float fac = tex_input_value(in[3], coord, thread);
|
||||
|
||||
float in4[4];
|
||||
tex_input_rgba(in4, in[4], coord, thread);
|
||||
float col[4];
|
||||
tex_input_rgba(col, in[4], coord, thread);
|
||||
|
||||
do_hue_sat_fac(node, out, in0, in1, in2, in4, in3);
|
||||
hue += 0.5f; /* [-.5, .5] -> [0, 1] */
|
||||
|
||||
do_hue_sat_fac(node, out, hue, sat, val, col, fac);
|
||||
|
||||
out[3] = col[3];
|
||||
}
|
||||
|
||||
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
|
@ -110,25 +110,25 @@ static int count_outputs(bNode *node)
|
||||
/* Boilerplate generators */
|
||||
|
||||
#define ProcNoInputs(name) \
|
||||
static void name##_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) \
|
||||
{}
|
||||
static void name##_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) \
|
||||
{}
|
||||
|
||||
#define ProcDef(name) \
|
||||
static void name##_colorfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \
|
||||
{ \
|
||||
texfn(result, coord, node, in, 0, &name##_map_inputs, thread); \
|
||||
} \
|
||||
static void name##_normalfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \
|
||||
{ \
|
||||
texfn(result, coord, node, in, 1, &name##_map_inputs, thread); \
|
||||
} \
|
||||
static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \
|
||||
{ \
|
||||
int outs = count_outputs(node); \
|
||||
if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn); \
|
||||
if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn); \
|
||||
if(outs >= 1) tex_do_preview(node, out[0], data); \
|
||||
}
|
||||
static void name##_colorfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \
|
||||
{ \
|
||||
texfn(result, coord, node, in, 0, &name##_map_inputs, thread); \
|
||||
} \
|
||||
static void name##_normalfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \
|
||||
{ \
|
||||
texfn(result, coord, node, in, 1, &name##_map_inputs, thread); \
|
||||
} \
|
||||
static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \
|
||||
{ \
|
||||
int outs = count_outputs(node); \
|
||||
if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn); \
|
||||
if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn); \
|
||||
if(outs >= 1) tex_do_preview(node, out[0], data); \
|
||||
}
|
||||
|
||||
|
||||
/* --- VORONOI -- */
|
||||
|
Loading…
Reference in New Issue
Block a user