Revision: 37054
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37054
Author: lukastoenne
Date: 2011-05-31 17:54:48 +0000 (Tue, 31 May 2011)
Log Message:
-----------
Material nodes were checking the nodestack->hasinput flag to determin whether
the original material settings or the node input data would be used. This
causes trouble when the input data is not the direct input constant of the node
nor a direct link in the same tree (i.e. a group socket). Just checks if
sockets are linked now (not very nice, but not hackier than the rest of that
node).
Fixes bug #27511.
Modified Paths:
--------------
trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c
trunk/blender/source/blender/nodes/intern/SHD_util.h
Modified: trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c
2011-05-31 16:21:30 UTC (rev 37053)
+++ trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c
2011-05-31 17:54:48 UTC (rev 37054)
@@ -85,7 +85,18 @@
ShadeInput *shi;
ShaderCallData *shcd= data;
float col[4];
+ bNodeSocket *sock;
+ char hasinput[NUM_MAT_IN];
+ 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 @@
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 @@
}
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]);
}
@@ -203,21 +214,31 @@
if(node->id) {
GPUShadeInput shi;
GPUShadeResult shr;
+ bNodeSocket *sock;
+ char hasinput[NUM_MAT_IN];
+ 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)
+ if(hasinput[MAT_IN_COLOR])
shi.rgb = in[MAT_IN_COLOR].link;
- if(in[MAT_IN_SPEC].hasinput)
+ if(hasinput[MAT_IN_SPEC])
shi.specrgb = in[MAT_IN_SPEC].link;
- if(in[MAT_IN_REFL].hasinput)
+ if(hasinput[MAT_IN_REFL])
shi.refl = in[MAT_IN_REFL].link;
/* retrieve normal */
- if(in[MAT_IN_NORMAL].hasinput) {
+ if(hasinput[MAT_IN_NORMAL]) {
GPUNodeLink *tmp;
shi.vn = in[MAT_IN_NORMAL].link;
GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn,
&tmp);
@@ -228,11 +249,11 @@
GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
if (node->type == SH_NODE_MATERIAL_EXT) {
- if(in[MAT_IN_AMB].hasinput)
+ if(hasinput[MAT_IN_AMB])
shi.amb= in[MAT_IN_AMB].link;
- if(in[MAT_IN_EMIT].hasinput)
+ if(hasinput[MAT_IN_EMIT])
shi.emit= in[MAT_IN_EMIT].link;
- if(in[MAT_IN_ALPHA].hasinput)
+ if(hasinput[MAT_IN_ALPHA])
shi.alpha= in[MAT_IN_ALPHA].link;
}
Modified: trunk/blender/source/blender/nodes/intern/SHD_util.h
===================================================================
--- trunk/blender/source/blender/nodes/intern/SHD_util.h 2011-05-31
16:21:30 UTC (rev 37053)
+++ trunk/blender/source/blender/nodes/intern/SHD_util.h 2011-05-31
17:54:48 UTC (rev 37054)
@@ -108,6 +108,7 @@
#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
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs