diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2011-07-29 10:32:30 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2011-07-29 10:32:30 +0400 |
commit | b46d8955509e805f06b76a6fd800ecb4edee113b (patch) | |
tree | 7ed0b1a3b5d04ab48d3e9062ff02ce54961ecb06 /source/blender/nodes | |
parent | 6960127d2609620d52620539388ada5cb466bab2 (diff) | |
parent | 26589497529ca3c8da85391d4976d286a371e258 (diff) |
Merging r36529-38806bge_components
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 13 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_blur.c | 2 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c | 1 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c | 16 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_glare.c | 1 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_image.c | 7 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_math.c | 7 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_rgb.c | 2 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_rotate.c | 1 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_util.c | 8 | ||||
-rw-r--r-- | source/blender/nodes/intern/SHD_nodes/SHD_material.c | 82 | ||||
-rw-r--r-- | source/blender/nodes/intern/SHD_util.c | 9 | ||||
-rw-r--r-- | source/blender/nodes/intern/SHD_util.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/intern/TEX_nodes/TEX_texture.c | 18 |
14 files changed, 120 insertions, 48 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index efd5523f5b2..c3bd37c18ee 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -34,6 +34,9 @@ set(INC ../makesrna ../render/extern/include ../../../intern/guardedalloc +) + +set(INC_SYS ${GLEW_INCLUDE_PATH} ) @@ -149,9 +152,13 @@ set(SRC ) if(WITH_PYTHON) - set(INC ${INC} ../python ${PYTHON_INCLUDE_DIRS}) + list(APPEND INC + ../python + ) + list(APPEND INC_SYS + ${PYTHON_INCLUDE_DIRS} + ) add_definitions(-DWITH_PYTHON) endif() -blender_add_lib(bf_nodes "${SRC}" "${INC}") - +blender_add_lib(bf_nodes "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c index 2b33126b3a7..718578a921b 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c @@ -387,7 +387,7 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa float dist= sqrt(fj*fj + fi*fi); //*dgauss= hexagon_filter(fi, fj); - *dgauss= RE_filter_value(nbd->filtertype, 2.0f*dist - 1.0f); + *dgauss= RE_filter_value(nbd->filtertype, dist); val+= *dgauss; } diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c index b32c531d8f9..e395716f36d 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c @@ -97,6 +97,7 @@ static void do_channel_matte(bNode *node, float *out, float *in) default: break; } + break; } default: break; diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c index 151850105b7..55d77a902b9 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c @@ -49,16 +49,24 @@ static bNodeSocketType cmp_node_color_out[]={ static void do_color_key(bNode *node, float *out, float *in) { + float h_wrap; NodeChroma *c; c=node->storage; VECCOPY(out, in); - if(fabs(in[0]-c->key[0]) < c->t1 && - fabs(in[1]-c->key[1]) < c->t2 && - fabs(in[2]-c->key[2]) < c->t3) - { + if( + /* do hue last because it needs to wrap, and does some more checks */ + + /* sat */ (fabs(in[1]-c->key[1]) < c->t2) && + /* val */ (fabs(in[2]-c->key[2]) < c->t3) && + + /* multiply by 2 because it wraps on both sides of the hue, + * otherwise 0.5 would key all hue's */ + + /* hue */ ((h_wrap= 2.0f * fabs(in[0]-c->key[0])) < c->t1 || (2.0f - h_wrap) < c->t1) + ) { out[3]=0.0; /*make transparent*/ } diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_glare.c b/source/blender/nodes/intern/CMP_nodes/CMP_glare.c index 1a339b45a05..2e0822a4511 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_glare.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_glare.c @@ -467,6 +467,7 @@ static void node_composit_exec_glare(void *UNUSED(data), bNode *node, bNodeStack case 2: default: streaks(ndg, new, src); + break; } free_compbuf(src); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c index 3caaad26bae..a5f256054cd 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c @@ -53,6 +53,7 @@ static bNodeSocketType cmp_node_rlayers_out[]= { { SOCK_RGBA, 0, "Refract", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 0, "Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VALUE, 0, "IndexOB", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 0, "IndexMA", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VALUE, 0, "Mist", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 0, "Emit", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 0, "Environment",0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, @@ -211,6 +212,8 @@ static void outputs_multilayer_get(RenderData *rd, RenderLayer *rl, bNodeStack * out[RRES_OUT_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_INDIRECT); if(out[RRES_OUT_INDEXOB]->hasoutput) out[RRES_OUT_INDEXOB]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_INDEXOB); + if(out[RRES_OUT_INDEXMA]->hasoutput) + out[RRES_OUT_INDEXMA]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_INDEXMA); if(out[RRES_OUT_MIST]->hasoutput) out[RRES_OUT_MIST]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_MIST); if(out[RRES_OUT_EMIT]->hasoutput) @@ -326,7 +329,7 @@ static CompBuf *compbuf_from_pass(RenderData *rd, RenderLayer *rl, int rectx, in CompBuf *buf; int buftype= CB_VEC3; - if(ELEM3(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, SCE_PASS_MIST)) + if(ELEM4(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, SCE_PASS_MIST, SCE_PASS_INDEXMA)) buftype= CB_VAL; else if(passcode==SCE_PASS_VECTOR) buftype= CB_VEC4; @@ -373,6 +376,8 @@ static void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStac out[RRES_OUT_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDIRECT); if(out[RRES_OUT_INDEXOB]->hasoutput) out[RRES_OUT_INDEXOB]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDEXOB); + if(out[RRES_OUT_INDEXMA]->hasoutput) + out[RRES_OUT_INDEXMA]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDEXMA); if(out[RRES_OUT_MIST]->hasoutput) out[RRES_OUT_MIST]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_MIST); if(out[RRES_OUT_EMIT]->hasoutput) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_math.c b/source/blender/nodes/intern/CMP_nodes/CMP_math.c index 4348fd18759..b7a67f3563b 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_math.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_math.c @@ -140,7 +140,12 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 14: /* Round */ { - out[0]= (out[0]<0)?(int)(in[0] - 0.5f):(int)(in[0] + 0.5f); + /* round by the second value */ + if( in2[0] != 0.0f ) + out[0]= floorf(in[0] / in2[0] + 0.5f) * in2[0]; + else + out[0]= floorf(in[0] + 0.5f); + } break; case 15: /* Less Than */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c b/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c index a6ce77b64f0..36b7988c4e0 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c @@ -45,7 +45,7 @@ static void node_composit_exec_rgb(void *UNUSED(data), bNode *node, bNodeStack * { bNodeSocket *sock= node->outputs.first; - VECCOPY(out[0]->vec, sock->ns.vec); + QUATCOPY(out[0]->vec, sock->ns.vec); } void register_node_type_cmp_rgb(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c b/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c index b6b1764ff0f..eccac4f0e6d 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c @@ -97,6 +97,7 @@ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStac break; case 2: bicubic_interpolation(ibuf, obuf, u, v, xo, yo); + break; } } diff --git a/source/blender/nodes/intern/CMP_util.c b/source/blender/nodes/intern/CMP_util.c index 78025f4d964..a763f34a644 100644 --- a/source/blender/nodes/intern/CMP_util.c +++ b/source/blender/nodes/intern/CMP_util.c @@ -132,7 +132,7 @@ void compbuf_set_node(CompBuf *cbuf, bNode *node) if (cbuf) cbuf->node = node; } -/* used for disabling node (similar code in drawnode.c for disable line) */ +/* used for disabling node (similar code in node_draw.c for disable line and node_edit for untangling nodes) */ void node_compo_pass_on(bNode *node, bNodeStack **nsin, bNodeStack **nsout) { CompBuf *valbuf= NULL, *colbuf= NULL, *vecbuf= NULL; @@ -1320,6 +1320,12 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy) if ((xy < 1) || (xy > 3)) xy = 3; + // XXX The YVV macro defined below explicitely expects sources of at least 3x3 pixels, + // so just skiping blur along faulty direction if src's def is below that limit! + if (src->x < 3) xy &= ~(int) 1; + if (src->y < 3) xy &= ~(int) 2; + if (xy < 1) return; + // see "Recursive Gabor Filtering" by Young/VanVliet // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200 if (sigma >= 3.556) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c index 40dfbc0edea..f78dd9ec727 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c @@ -85,6 +85,17 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, ShadeInput *shi; ShaderCallData *shcd= data; float col[4]; + bNodeSocket *sock; + char hasinput[NUM_MAT_IN]= {'\0'}; + int i; + + /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily + * the constant input stack values (e.g. in case material node is inside a group). + * we just want to know if a node input uses external data or the material setting. + * this is an ugly hack, but so is this node as a whole. + */ + for (sock=node->inputs.first, i=0; sock; sock=sock->next, ++i) + hasinput[i] = (sock->link != NULL); shi= shcd->shi; shi->mat= (Material *)node->id; @@ -94,17 +105,17 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, shi->har= shi->mat->har; /* write values */ - if(in[MAT_IN_COLOR]->hasinput) + if(hasinput[MAT_IN_COLOR]) nodestack_get_vec(&shi->r, SOCK_VECTOR, in[MAT_IN_COLOR]); - if(in[MAT_IN_SPEC]->hasinput) + if(hasinput[MAT_IN_SPEC]) nodestack_get_vec(&shi->specr, SOCK_VECTOR, in[MAT_IN_SPEC]); - if(in[MAT_IN_REFL]->hasinput) + if(hasinput[MAT_IN_REFL]) nodestack_get_vec(&shi->refl, SOCK_VALUE, in[MAT_IN_REFL]); /* retrieve normal */ - if(in[MAT_IN_NORMAL]->hasinput) { + if(hasinput[MAT_IN_NORMAL]) { nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]); normalize_v3(shi->vn); } @@ -119,19 +130,19 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, } if (node->type == SH_NODE_MATERIAL_EXT) { - if(in[MAT_IN_MIR]->hasinput) + if(hasinput[MAT_IN_MIR]) nodestack_get_vec(&shi->mirr, SOCK_VECTOR, in[MAT_IN_MIR]); - if(in[MAT_IN_AMB]->hasinput) + if(hasinput[MAT_IN_AMB]) nodestack_get_vec(&shi->amb, SOCK_VALUE, in[MAT_IN_AMB]); - if(in[MAT_IN_EMIT]->hasinput) + if(hasinput[MAT_IN_EMIT]) nodestack_get_vec(&shi->emit, SOCK_VALUE, in[MAT_IN_EMIT]); - if(in[MAT_IN_SPECTRA]->hasinput) + if(hasinput[MAT_IN_SPECTRA]) nodestack_get_vec(&shi->spectra, SOCK_VALUE, in[MAT_IN_SPECTRA]); - if(in[MAT_IN_RAY_MIRROR]->hasinput) + if(hasinput[MAT_IN_RAY_MIRROR]) nodestack_get_vec(&shi->ray_mirror, SOCK_VALUE, in[MAT_IN_RAY_MIRROR]); - if(in[MAT_IN_ALPHA]->hasinput) + if(hasinput[MAT_IN_ALPHA]) nodestack_get_vec(&shi->alpha, SOCK_VALUE, in[MAT_IN_ALPHA]); - if(in[MAT_IN_TRANSLUCENCY]->hasinput) + if(hasinput[MAT_IN_TRANSLUCENCY]) nodestack_get_vec(&shi->translucency, SOCK_VALUE, in[MAT_IN_TRANSLUCENCY]); } @@ -198,28 +209,49 @@ static void node_shader_init_material(bNode* node) node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC; } +/* XXX this is also done as a local static function in gpu_codegen.c, + * but we need this to hack around the crappy material node. + */ +static GPUNodeLink *gpu_get_input_link(GPUNodeStack *in) +{ + if (in->link) + return in->link; + else + return GPU_uniform(in->vec); +} + static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { if(node->id) { GPUShadeInput shi; GPUShadeResult shr; + bNodeSocket *sock; + char hasinput[NUM_MAT_IN]= {'\0'}; + int i; + + /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily + * the constant input stack values (e.g. in case material node is inside a group). + * we just want to know if a node input uses external data or the material setting. + */ + for (sock=node->inputs.first, i=0; sock; sock=sock->next, ++i) + hasinput[i] = (sock->link != NULL); GPU_shadeinput_set(mat, (Material*)node->id, &shi); /* write values */ - if(in[MAT_IN_COLOR].hasinput) - shi.rgb = in[MAT_IN_COLOR].link; + if(hasinput[MAT_IN_COLOR]) + shi.rgb = gpu_get_input_link(&in[MAT_IN_COLOR]); - if(in[MAT_IN_SPEC].hasinput) - shi.specrgb = in[MAT_IN_SPEC].link; + if(hasinput[MAT_IN_SPEC]) + shi.specrgb = gpu_get_input_link(&in[MAT_IN_SPEC]); - if(in[MAT_IN_REFL].hasinput) - shi.refl = in[MAT_IN_REFL].link; + if(hasinput[MAT_IN_REFL]) + shi.refl = gpu_get_input_link(&in[MAT_IN_REFL]); /* retrieve normal */ - if(in[MAT_IN_NORMAL].hasinput) { + if(hasinput[MAT_IN_NORMAL]) { GPUNodeLink *tmp; - shi.vn = in[MAT_IN_NORMAL].link; + shi.vn = gpu_get_input_link(&in[MAT_IN_NORMAL]); GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp); } @@ -228,12 +260,12 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn); if (node->type == SH_NODE_MATERIAL_EXT) { - if(in[MAT_IN_AMB].hasinput) - shi.amb= in[MAT_IN_AMB].link; - if(in[MAT_IN_EMIT].hasinput) - shi.emit= in[MAT_IN_EMIT].link; - if(in[MAT_IN_ALPHA].hasinput) - shi.alpha= in[MAT_IN_ALPHA].link; + if(hasinput[MAT_IN_AMB]) + shi.amb= gpu_get_input_link(&in[MAT_IN_AMB]); + if(hasinput[MAT_IN_EMIT]) + shi.emit= gpu_get_input_link(&in[MAT_IN_EMIT]); + if(hasinput[MAT_IN_ALPHA]) + shi.alpha= gpu_get_input_link(&in[MAT_IN_ALPHA]); } GPU_shaderesult_set(&shi, &shr); /* clears shr */ diff --git a/source/blender/nodes/intern/SHD_util.c b/source/blender/nodes/intern/SHD_util.c index cf7c64c9d5e..190f68ce19a 100644 --- a/source/blender/nodes/intern/SHD_util.c +++ b/source/blender/nodes/intern/SHD_util.c @@ -83,7 +83,11 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) { ShaderCallData scd; - + /* + @note: preserve material from ShadeInput for material id, nodetree execs change it + fix for bug "[#28012] Mat ID messy with shader nodes" + */ + Material *mat = shi->mat; /* convert caller data to struct */ scd.shi= shi; scd.shr= shr; @@ -92,7 +96,8 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) memset(shr, 0, sizeof(ShadeResult)); ntreeExecTree(ntree, &scd, shi->thread); /* threads */ - + // @note: set material back to preserved material + shi->mat = mat; /* better not allow negative for now */ if(shr->combined[0]<0.0f) shr->combined[0]= 0.0f; if(shr->combined[1]<0.0f) shr->combined[1]= 0.0f; diff --git a/source/blender/nodes/intern/SHD_util.h b/source/blender/nodes/intern/SHD_util.h index 4c5d56776da..e6b1377067d 100644 --- a/source/blender/nodes/intern/SHD_util.h +++ b/source/blender/nodes/intern/SHD_util.h @@ -108,6 +108,7 @@ typedef struct ShaderCallData { #define MAT_IN_RAY_MIRROR 8 #define MAT_IN_ALPHA 9 #define MAT_IN_TRANSLUCENCY 10 +#define NUM_MAT_IN 11 /* for array size */ /* output socket defines */ #define MAT_OUT_COLOR 0 diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c index d4d77b5fd5a..c58595866af 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c @@ -49,18 +49,18 @@ static bNodeSocketType outputs[]= { static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { + Tex *nodetex = (Tex *)node->id; static float red[] = {1,0,0,1}; static float white[] = {1,1,1,1}; - float *co = p->co; - - Tex *nodetex = (Tex *)node->id; + float co[3], dxt[3], dyt[3]; + + copy_v3_v3(co, p->co); + copy_v3_v3(dxt, p->dxt); + copy_v3_v3(dyt, p->dyt); if(node->custom2 || node->need_exec==0) { /* this node refers to its own texture tree! */ - QUATCOPY( - out, - (fabs(co[0] - co[1]) < .01) ? white : red - ); + QUATCOPY(out, (fabs(co[0] - co[1]) < .01) ? white : red ); } else if(nodetex) { TexResult texres; @@ -70,9 +70,9 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor tex_input_rgba(col1, in[0], p, thread); tex_input_rgba(col2, in[1], p, thread); - + texres.nor = nor; - textype = multitex_nodes(nodetex, co, p->dxt, p->dyt, p->osatex, + textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex, &texres, thread, 0, p->shi, p->mtex); if(textype & TEX_RGB) { |