diff options
author | Robin Allen <roblovski@gmail.com> | 2009-08-18 00:30:11 +0400 |
---|---|---|
committer | Robin Allen <roblovski@gmail.com> | 2009-08-18 00:30:11 +0400 |
commit | f9ceeeede672a634913188c775e020c23170f4e1 (patch) | |
tree | 1f1068e7d4b118dd44795bc6412b46d36230fd28 /source/blender/nodes/intern/TEX_nodes | |
parent | 9f5d25748397aad6a4347f40c7ec6c025dc93129 (diff) |
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.
Diffstat (limited to 'source/blender/nodes/intern/TEX_nodes')
22 files changed, 169 insertions, 149 deletions
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_at.c b/source/blender/nodes/intern/TEX_nodes/TEX_at.c index 80f232ccd0c..4d714d91130 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_at.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_at.c @@ -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) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c index 80cbd6188ee..f1f3b0919ae 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c @@ -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); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c index 60357782e25..b889f1e2164 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c @@ -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); } } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c index 26576befa3e..9fc4b2ff7c2 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c @@ -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) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c index da487c190af..e5c2b309fb3 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c @@ -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) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c index 7d1366b5b18..61ebcea7360 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c @@ -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]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c index c08eb12a18f..f7a409f0230 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c @@ -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]; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c index d23eb6bc589..4e145e26b72 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c @@ -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); } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c index bb1a49fb235..192c7a39ee8 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c @@ -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] */ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c index b84088da154..0a55af70b52 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c @@ -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; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c index 09716951009..5663f897ff5 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c @@ -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]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index bac91fc0901..4ee04140fca 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -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){ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c index b1ccb7a3d07..24bdde70127 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c @@ -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); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index d0538d11900..355de796c7e 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -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(¶ms, cdata); + + tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); target->tin = (target->tr + target->tg + target->tb) / 3.0f; target->talpha = 1.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], ¶ms, cdata->thread); else target->nor = 0; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c index ec65cf186a8..ce7324e2085 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c @@ -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) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c index 3a2c2b1def1..0fd95642be6 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c @@ -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) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c index 792c3468e9f..3d4415365aa 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c @@ -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) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c index 30492b84764..0ca80a82271 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c @@ -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); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c index cadd27612f4..ba3dcfa27a2 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c @@ -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) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c index 0d24652a8f6..75b88c3a460 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c @@ -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]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c index 71d9cb07e18..90a444bcff0 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c @@ -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; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c index acdaacf873c..2d29b03b38c 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ |