Slight refactor of texture nodes.

Delegates now receive a TexParams* instead of float *coords. This gives texture nodes access to dxt, dyt, cfra as well as coords. This fixes the time node and allows nice sampling to be implemented.
This commit is contained in:
Robin Allen
2009-08-17 20:30:11 +00:00
parent 9f5d257483
commit f9ceeeede6
26 changed files with 231 additions and 176 deletions

View File

@@ -422,7 +422,7 @@ extern struct ListBase node_all_textures;
/* API */
int ntreeTexTagAnimated(struct bNodeTree *ntree);
void ntreeTexUpdatePreviews( struct bNodeTree* nodetree );
void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra);
void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, char do_preview, short thread, struct Tex *tex, short which_output, int cfra);
void ntreeTexCheckCyclics(struct bNodeTree *ntree);
void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node);
char* ntreeTexOutputMenu(struct bNodeTree *ntree);

View File

@@ -38,12 +38,14 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
TexParams np = *p;
float new_coord[3];
np.coord = new_coord;
tex_input_vec(new_coord, in[1], coord, thread);
tex_input_rgba(out, in[0], new_coord, thread);
tex_input_vec(new_coord, in[1], p, thread);
tex_input_rgba(out, in[0], &np, thread);
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -57,8 +57,10 @@ static float noise(int n) /* fast integer noise */
return 0.5f * ((float)nn / 1073741824.0f);
}
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float *coord = p->coord;
float x = coord[0];
float y = coord[1];
@@ -71,14 +73,14 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor
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);
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], coord, thread);
tex_input_rgba(bricks2, in[1], coord, thread);
tex_input_rgba(mortar, in[2], coord, 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);

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -40,12 +40,12 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, 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);
float x = p->coord[0];
float y = p->coord[1];
float z = p->coord[2];
float sz = tex_input_value(in[2], p, thread);
/* 0.00001 because of unit sized stuff */
int xi = (int)fabs(floor(0.00001 + x / sz));
@@ -53,9 +53,9 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor
int zi = (int)fabs(floor(0.00001 + z / sz));
if( (xi % 2 == yi % 2) == (zi % 2) ) {
tex_input_rgba(out, in[0], coord, thread);
tex_input_rgba(out, in[0], p, thread);
} else {
tex_input_rgba(out, in[1], coord, thread);
tex_input_rgba(out, in[1], p, thread);
}
}

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -40,11 +40,11 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
int i;
for(i = 0; i < 4; i++)
out[i] = tex_input_value(in[i], coord, thread);
out[i] = tex_input_value(in[i], p, thread);
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)

View File

@@ -33,11 +33,11 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void vectorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void vectorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
out[0] = coord[0];
out[1] = coord[1];
out[2] = coord[2];
out[0] = p->coord[0];
out[1] = p->coord[1];
out[2] = p->coord[2];
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -36,14 +36,13 @@ static bNodeSocketType time_outputs[]= {
{ -1, 0, "" }
};
static void time_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
/* stack order output: fac */
float fac= 0.0f;
// XXX SOLVE! these functions should get the TexCallData pointer
// if(node->custom1 < node->custom2)
// fac = (scene->r.cfra - node->custom1)/(float)(node->custom2-node->custom1);
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);
@@ -90,10 +89,10 @@ static bNodeSocketType rgb_outputs[]= {
{ -1, 0, "" }
};
static void rgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float cin[4];
tex_input_rgba(cin, in[0], coord, thread);
tex_input_rgba(cin, in[0], p, thread);
curvemapping_evaluateRGBF(node->storage, out, cin);
out[3] = cin[3];

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -41,27 +41,27 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void valuefn_r(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void valuefn_r(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
tex_input_rgba(out, in[0], coord, thread);
tex_input_rgba(out, in[0], p, thread);
*out = out[0];
}
static void valuefn_g(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void valuefn_g(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
tex_input_rgba(out, in[0], coord, thread);
tex_input_rgba(out, in[0], p, thread);
*out = out[1];
}
static void valuefn_b(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
tex_input_rgba(out, in[0], coord, thread);
tex_input_rgba(out, in[0], p, thread);
*out = out[2];
}
static void valuefn_a(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void valuefn_a(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
tex_input_rgba(out, in[0], coord, thread);
tex_input_rgba(out, in[0], p, thread);
*out = out[3];
}

View File

@@ -41,12 +41,12 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float coord1[3], coord2[3];
tex_input_vec(coord1, in[0], coord, thread);
tex_input_vec(coord2, in[1], coord, thread);
tex_input_vec(coord1, in[0], p, thread);
tex_input_vec(coord2, in[1], p, thread);
*out = VecLenf(coord2, coord1);
}

View File

@@ -65,15 +65,15 @@ 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)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short 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 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], coord, thread);
tex_input_rgba(col, in[4], p, thread);
hue += 0.5f; /* [-.5, .5] -> [0, 1] */

View File

@@ -22,7 +22,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -34,10 +34,10 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float x = coord[0];
float y = coord[1];
float x = p->coord[0];
float y = p->coord[1];
Image *ima= (Image *)node->id;
ImageUser *iuser= (ImageUser *)node->storage;

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -39,11 +39,11 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float col[4];
tex_input_rgba(col, in[0], coord, thread);
tex_input_rgba(col, in[0], p, thread);
col[0] = 1.0f - col[0];
col[1] = 1.0f - col[1];

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -42,10 +42,10 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void valuefn(float *out, TexParams *p, 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 in0 = tex_input_value(in[0], p, thread);
float in1 = tex_input_value(in[1], p, thread);
switch(node->custom1){

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -41,13 +41,13 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float fac = tex_input_value(in[0], coord, thread);
float fac = tex_input_value(in[0], p, thread);
float col1[4], col2[4];
tex_input_rgba(col1, in[1], coord, thread);
tex_input_rgba(col2, in[2], coord, thread);
tex_input_rgba(col1, in[1], p, thread);
tex_input_rgba(col2, in[2], p, thread);
CLAMP(fac, 0.0f, 1.0f);

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -49,14 +49,17 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
if(!cdata->do_preview) {
if(cdata->which_output == node->custom1)
{
tex_input_rgba(&target->tr, in[0], cdata->coord, cdata->thread);
TexParams params;
params_from_cdata(&params, cdata);
tex_input_rgba(&target->tr, in[0], &params, 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);
tex_input_vec(target->nor, in[1], &params, cdata->thread);
else
target->nor = 0;
}

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -51,7 +51,7 @@ static bNodeSocketType outputs_color_only[]= {
{ 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)
static void do_proc(float *result, TexParams *p, float *col1, float *col2, char is_normal, Tex *tex, short thread)
{
TexResult texres;
int textype;
@@ -62,7 +62,7 @@ static void do_proc(float *result, float *coord, float *col1, float *col2, char
else
texres.nor = NULL;
textype = multitex_thread(tex, coord, 0, 0, 0, &texres, thread, 0);
textype = multitex_thread(tex, p->coord, p->dxt, p->dyt, 0, &texres, thread, 0);
if(is_normal)
return;
@@ -76,11 +76,11 @@ static void do_proc(float *result, float *coord, float *col1, float *col2, char
}
}
typedef void (*MapFn) (Tex *tex, bNodeStack **in, float *coord, short thread);
typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, short thread);
static void texfn(
float *result,
float *coord,
TexParams *p,
bNode *node,
bNodeStack **in,
char is_normal,
@@ -89,12 +89,12 @@ static void texfn(
{
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);
tex_input_rgba(col1, in[0], p, thread);
tex_input_rgba(col2, in[1], p, thread);
map_inputs(&tex, in, coord, thread);
map_inputs(&tex, in, p, thread);
do_proc(result, coord, col1, col2, is_normal, &tex, thread);
do_proc(result, p, col1, col2, is_normal, &tex, thread);
}
static int count_outputs(bNode *node)
@@ -110,17 +110,17 @@ 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, TexParams *p, short thread) \
{}
#define ProcDef(name) \
static void name##_colorfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \
static void name##_colorfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \
{ \
texfn(result, coord, node, in, 0, &name##_map_inputs, thread); \
texfn(result, p, node, in, 0, &name##_map_inputs, thread); \
} \
static void name##_normalfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \
static void name##_normalfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \
{ \
texfn(result, coord, node, in, 1, &name##_map_inputs, thread); \
texfn(result, p, node, in, 1, &name##_map_inputs, thread); \
} \
static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \
{ \
@@ -144,15 +144,15 @@ static bNodeSocketType voronoi_inputs[]= {
{ -1, 0, "" }
};
static void voronoi_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread)
static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, 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->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], coord, thread);
tex->noisesize = tex_input_value(in[I+5], coord, thread);
tex->ns_outscale = tex_input_value(in[I+4], p, thread);
tex->noisesize = tex_input_value(in[I+5], p, thread);
}
ProcDef(voronoi)
@@ -170,9 +170,9 @@ static bNodeSocketType magic_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)
static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
tex->turbul = tex_input_value(in[I+0], coord, thread);
tex->turbul = tex_input_value(in[I+0], p, thread);
}
ProcDef(magic)
@@ -183,10 +183,10 @@ static bNodeSocketType marble_inputs[]= {
{ 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)
static void marble_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
tex->noisesize = tex_input_value(in[I+0], coord, thread);
tex->turbul = tex_input_value(in[I+1], coord, thread);
tex->noisesize = tex_input_value(in[I+0], p, thread);
tex->turbul = tex_input_value(in[I+1], p, thread);
}
ProcDef(marble)
@@ -196,9 +196,9 @@ static bNodeSocketType clouds_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)
static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
tex->noisesize = tex_input_value(in[I+0], coord, thread);
tex->noisesize = tex_input_value(in[I+0], p, thread);
}
ProcDef(clouds)
@@ -209,10 +209,10 @@ static bNodeSocketType distnoise_inputs[]= {
{ 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)
static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
tex->noisesize = tex_input_value(in[I+0], coord, thread);
tex->dist_amount = tex_input_value(in[I+1], coord, thread);
tex->noisesize = tex_input_value(in[I+0], p, thread);
tex->dist_amount = tex_input_value(in[I+1], p, thread);
}
ProcDef(distnoise)
@@ -223,10 +223,10 @@ static bNodeSocketType wood_inputs[]= {
{ 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)
static void wood_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
tex->noisesize = tex_input_value(in[I+0], coord, thread);
tex->turbul = tex_input_value(in[I+1], coord, thread);
tex->noisesize = tex_input_value(in[I+0], p, thread);
tex->turbul = tex_input_value(in[I+1], p, thread);
}
ProcDef(wood)
@@ -241,13 +241,13 @@ static bNodeSocketType musgrave_inputs[]= {
{ 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)
static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, 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);
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)
@@ -266,10 +266,10 @@ static bNodeSocketType stucci_inputs[]= {
{ 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)
static void stucci_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
tex->noisesize = tex_input_value(in[I+0], coord, thread);
tex->turbul = tex_input_value(in[I+1], coord, thread);
tex->noisesize = tex_input_value(in[I+0], p, thread);
tex->turbul = tex_input_value(in[I+1], p, thread);
}
ProcDef(stucci)

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -42,9 +42,10 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float new_coord[3];
float *coord = p->coord;
float ax[4];
float para[3];
@@ -53,13 +54,13 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor
float magsq, ndx;
float a = tex_input_value(in[1], coord, thread);
float a = tex_input_value(in[1], p, 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);
tex_input_vec(ax, in[2], p, thread);
magsq = ax[0]*ax[0] + ax[1]*ax[1] + ax[2]*ax[2];
if(magsq == 0) magsq = 1;
@@ -86,7 +87,11 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor
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);
{
TexParams np = *p;
np.coord = new_coord;
tex_input_rgba(out, in[0], &np, thread);
}
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -40,17 +40,19 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float scale[3], new_coord[3];
TexParams np = *p;
np.coord = new_coord;
tex_input_vec(scale, in[1], coord, thread);
tex_input_vec(scale, in[1], p, thread);
new_coord[0] = coord[0] * scale[0];
new_coord[1] = coord[1] * scale[1];
new_coord[2] = coord[2] * scale[2];
new_coord[0] = p->coord[0] * scale[0];
new_coord[1] = p->coord[1] * scale[1];
new_coord[2] = p->coord[2] * scale[2];
tex_input_rgba(out, in[0], new_coord, thread);
tex_input_rgba(out, in[0], &np, thread);
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -40,10 +40,11 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
static float red[] = {1,0,0,1};
static float white[] = {1,1,1,1};
float *coord = p->coord;
Tex *nodetex = (Tex *)node->id;
@@ -60,8 +61,8 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor
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);
tex_input_rgba(col1, in[0], p, thread);
tex_input_rgba(col2, in[1], p, thread);
texres.nor = nor;
textype = multitex_ext(nodetex, coord, 0, 0, 0, &texres);

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -40,17 +40,19 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float offset[3], new_coord[3];
TexParams np = *p;
np.coord = new_coord;
tex_input_vec(offset, in[1], coord, thread);
tex_input_vec(offset, in[1], p, thread);
new_coord[0] = coord[0] + offset[0];
new_coord[1] = coord[1] + offset[1];
new_coord[2] = coord[2] + offset[2];
new_coord[0] = p->coord[0] + offset[0];
new_coord[1] = p->coord[1] + offset[1];
new_coord[2] = p->coord[2] + offset[2];
tex_input_rgba(out, in[0], new_coord, thread);
tex_input_rgba(out, in[0], &np, thread);
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{

View File

@@ -39,28 +39,32 @@ static bNodeSocketType outputs[]= {
{ -1, 0, "" }
};
static void normalfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void normalfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float new_coord[3];
float *coord = p->coord;
float nabla = tex_input_value(in[1], coord, thread);
float nabla = tex_input_value(in[1], p, thread);
float val;
float nor[3];
TexParams np = *p;
np.coord = new_coord;
val = tex_input_value(in[0], coord, thread);
val = tex_input_value(in[0], p, thread);
new_coord[0] = coord[0] + nabla;
new_coord[1] = coord[1];
new_coord[2] = coord[2];
nor[0] = tex_input_value(in[0], new_coord, thread);
nor[0] = tex_input_value(in[0], &np, thread);
new_coord[0] = coord[0];
new_coord[1] = coord[1] + nabla;
nor[1] = tex_input_value(in[0], new_coord, thread);
nor[1] = tex_input_value(in[0], &np, thread);
new_coord[1] = coord[1];
new_coord[2] = coord[2] + nabla;
nor[2] = tex_input_value(in[0], new_coord, thread);
nor[2] = tex_input_value(in[0], &np, thread);
out[0] = val-nor[0];
out[1] = val-nor[1];

View File

@@ -22,7 +22,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -39,10 +39,10 @@ static bNodeSocketType valtorgb_out[]= {
{ -1, 0, "" }
};
static void valtorgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
if(node->storage) {
float fac = tex_input_value(in[0], coord, thread);
float fac = tex_input_value(in[0], p, thread);
do_colorband(node->storage, fac, out);
}
@@ -87,10 +87,10 @@ static bNodeSocketType rgbtobw_out[]= {
};
static void rgbtobw_valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
static void rgbtobw_valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
float cin[4];
tex_input_rgba(cin, in[0], coord, thread);
tex_input_rgba(cin, in[0], p, thread);
*out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f;
}

View File

@@ -21,7 +21,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Robin Allen
*
* ***** END GPL LICENSE BLOCK *****
*/

View File

@@ -47,17 +47,17 @@
#define PREV_RES 128 /* default preview resolution */
void tex_call_delegate(TexDelegate *dg, float *out, float *coord, short thread)
void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread)
{
if(dg->node->need_exec)
dg->fn(out, coord, dg->node, dg->in, thread);
dg->fn(out, params, dg->node, dg->in, thread);
}
void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread)
void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread)
{
TexDelegate *dg = in->data;
if(dg) {
tex_call_delegate(dg, in->vec, coord, thread);
tex_call_delegate(dg, in->vec, params, thread);
if(in->hasoutput && in->sockettype == SOCK_VALUE)
in->vec[1] = in->vec[2] = in->vec[0];
@@ -65,14 +65,14 @@ void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread)
memcpy(out, in->vec, sz * sizeof(float));
}
void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread)
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
{
tex_input(out, 3, in, coord, thread);
tex_input(out, 3, in, params, thread);
}
void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
{
tex_input(out, 4, in, coord, thread);
tex_input(out, 4, in, params, thread);
if(in->hasoutput && in->sockettype == SOCK_VALUE)
{
@@ -88,10 +88,10 @@ void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread)
}
}
float tex_input_value(bNodeStack *in, float *coord, short thread)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
{
float out[4];
tex_input_vec(out, in, coord, thread);
tex_input_vec(out, in, params, thread);
return out[0];
}
@@ -121,11 +121,21 @@ static void init_preview(bNode *node)
}
}
void params_from_cdata(TexParams *out, TexCallData *in)
{
out->coord = in->coord;
out->dxt = in->dxt;
out->dyt = in->dyt;
out->cfra = in->cfra;
}
void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata)
{
int x, y;
float *result;
bNodePreview *preview;
float coord[3] = {0, 0, 0};
TexParams params;
if(!cdata->do_preview)
return;
@@ -137,15 +147,20 @@ void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata)
preview = node->preview;
params.dxt = 0;
params.dyt = 0;
params.cfra = 0; /* XXX Use current? */
params.coord = coord;
for(x=0; x<preview->xsize; x++)
for(y=0; y<preview->ysize; y++)
{
cdata->coord[0] = ((float) x / preview->xsize) * 2 - 1;
cdata->coord[1] = ((float) y / preview->ysize) * 2 - 1;
params.coord[0] = ((float) x / preview->xsize) * 2 - 1;
params.coord[1] = ((float) y / preview->ysize) * 2 - 1;
result = preview->rect + 4 * (preview->xsize*y + x);
tex_input_rgba(result, ns, cdata->coord, cdata->thread);
tex_input_rgba(result, ns, &params, cdata->thread);
}
}
@@ -192,8 +207,17 @@ void ntreeTexCheckCyclics(struct bNodeTree *ntree)
}
}
void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, Tex *tex, short which_output, int cfra)
{
void ntreeTexExecTree(
bNodeTree *nodes,
TexResult *texres,
float *coord,
float *dxt, float *dyt,
char do_preview,
short thread,
Tex *tex,
short which_output,
int cfra
){
TexResult dummy_texres;
TexCallData data;
@@ -203,6 +227,8 @@ void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do
if(!texres) texres = &dummy_texres;
data.coord = coord;
data.dxt = dxt;
data.dyt = dyt;
data.target = texres;
data.do_preview = do_preview;
data.thread = thread;
@@ -225,7 +251,7 @@ void ntreeTexUpdatePreviews(bNodeTree* nodetree)
dummy_texres.nor = 0;
ntreeBeginExecTree(nodetree);
ntreeTexExecTree(nodetree, &dummy_texres, coord, 1, 0, tex, 0, 0);
ntreeTexExecTree(nodetree, &dummy_texres, coord, 0, 0, 1, 0, tex, 0, 0);
ntreeEndExecTree(nodetree);
}

View File

@@ -71,13 +71,20 @@
typedef struct TexCallData {
TexResult *target;
float *coord;
float *dxt, *dyt;
char do_preview;
short thread;
short which_output;
int cfra;
} TexCallData;
typedef void(*TexFn) (float *out, float *coord, bNode *node, bNodeStack **in, short thread);
typedef struct TexParams {
float *coord;
float *dxt, *dyt;
int cfra;
} TexParams;
typedef void(*TexFn) (float *out, TexParams *params, bNode *node, bNodeStack **in, short thread);
typedef struct TexDelegate {
TexFn fn;
@@ -86,16 +93,18 @@ typedef struct TexDelegate {
int type;
} TexDelegate;
void tex_call_delegate(TexDelegate*, float *out, float *coord, short thread);
void tex_call_delegate(TexDelegate*, float *out, TexParams *params, short thread);
void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread);
void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread);
float tex_input_value(bNodeStack *in, float *coord, short thread);
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread);
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread);
float tex_input_value(bNodeStack *in, TexParams *params, short thread);
void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn);
void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata);
void ntreeTexUpdatePreviews( bNodeTree* nodetree );
void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra);
void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, float *dxt, float *dyt, char do_preview, short thread, struct Tex *tex, short which_output, int cfra);
void params_from_cdata(TexParams *out, TexCallData *in);
#endif

View File

@@ -714,12 +714,12 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres)
/* ------------------------------------------------------------------------- */
static int evalnodes(Tex *tex, float *texvec, TexResult *texres, short thread, short which_output)
static int evalnodes(Tex *tex, float *texvec, float *dxt, float *dyt, TexResult *texres, short thread, short which_output)
{
short rv = TEX_INT;
bNodeTree *nodes = tex->nodetree;
ntreeTexExecTree(nodes, texres, texvec, 0, thread, tex, which_output, R.r.cfra);
ntreeTexExecTree(nodes, texres, texvec, dxt, dyt, 0, thread, tex, which_output, R.r.cfra);
if(texres->nor) rv |= TEX_NOR;
rv |= TEX_RGB;
@@ -1180,7 +1180,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
texres->talpha= 0; /* is set when image texture returns alpha (considered premul) */
if(tex->use_nodes && tex->nodetree) {
retval = evalnodes(tex, texvec, texres, thread, which_output);
retval = evalnodes(tex, texvec, dxt, dyt, texres, thread, which_output);
}
else
switch(tex->type) {