diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-06-09 20:05:34 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-06-09 20:05:34 +0400 |
commit | 55c488abf055897a1d55a694f2b460e94ac17c6b (patch) | |
tree | 67a5021619b1e4ea6b36a2d37599d9c0eb0bc40a /source/blender/nodes | |
parent | 3a51735fbe083016baf2c74ee2efdbbc01e0249c (diff) |
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.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/intern/SHD_nodes/SHD_material.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c index 8b477af0689..f66df9bba90 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c @@ -209,6 +209,17 @@ 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) { @@ -229,18 +240,18 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, /* 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 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, 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 */ |