[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37341] trunk/blender/source/blender/nodes /intern/SHD_nodes/SHD_material.c: Fix for GLSL material node inside groups.
Lukas Toenne
lukas.toenne at googlemail.com
Thu Jun 9 18:05:36 CEST 2011
Revision: 37341
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37341
Author: lukastoenne
Date: 2011-06-09 16:05:34 +0000 (Thu, 09 Jun 2011)
Log Message:
-----------
Fix for GLSL material node inside groups. These were using the GPULink point from the input stack argument, but this only exists for directly linked nodes. If a node is linked directly to a group socket, which is not linked externally, the stack argument is actually the external group input.
Modified Paths:
--------------
trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c
Modified: trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c 2011-06-09 15:54:44 UTC (rev 37340)
+++ trunk/blender/source/blender/nodes/intern/SHD_nodes/SHD_material.c 2011-06-09 16:05:34 UTC (rev 37341)
@@ -209,6 +209,17 @@
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) {
@@ -229,18 +240,18 @@
/* write values */
if(hasinput[MAT_IN_COLOR])
- shi.rgb = in[MAT_IN_COLOR].link;
+ shi.rgb = gpu_get_input_link(&in[MAT_IN_COLOR]);
if(hasinput[MAT_IN_SPEC])
- shi.specrgb = in[MAT_IN_SPEC].link;
+ shi.specrgb = gpu_get_input_link(&in[MAT_IN_SPEC]);
if(hasinput[MAT_IN_REFL])
- shi.refl = in[MAT_IN_REFL].link;
+ shi.refl = gpu_get_input_link(&in[MAT_IN_REFL]);
/* retrieve normal */
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);
}
@@ -250,11 +261,11 @@
if (node->type == SH_NODE_MATERIAL_EXT) {
if(hasinput[MAT_IN_AMB])
- shi.amb= in[MAT_IN_AMB].link;
+ shi.amb= gpu_get_input_link(&in[MAT_IN_AMB]);
if(hasinput[MAT_IN_EMIT])
- shi.emit= in[MAT_IN_EMIT].link;
+ shi.emit= gpu_get_input_link(&in[MAT_IN_EMIT]);
if(hasinput[MAT_IN_ALPHA])
- shi.alpha= in[MAT_IN_ALPHA].link;
+ shi.alpha= gpu_get_input_link(&in[MAT_IN_ALPHA]);
}
GPU_shaderesult_set(&shi, &shr); /* clears shr */
More information about the Bf-blender-cvs
mailing list