[Bf-blender-cvs] [a252e27] master: Fix T38633: glsl not working well with mixed cycles/blender material nodes.
Brecht Van Lommel
noreply at git.blender.org
Fri Feb 14 15:12:09 CET 2014
Commit: a252e27fec16e09efe873a6bbbd29b3ad5d4c67f
Author: Brecht Van Lommel
Date: Fri Feb 14 15:11:19 2014 +0100
https://developer.blender.org/rBa252e27fec16e09efe873a6bbbd29b3ad5d4c67f
Fix T38633: glsl not working well with mixed cycles/blender material nodes.
===================================================================
M source/blender/blenkernel/BKE_node.h
M source/blender/gpu/intern/gpu_material.c
M source/blender/nodes/shader/node_shader_tree.c
M source/blender/nodes/shader/node_shader_util.c
M source/blender/nodes/shader/node_shader_util.h
M source/blender/nodes/shader/nodes/node_shader_common.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index d219c1c..59ea921 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -770,7 +770,7 @@ void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short
extern void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
-void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
+void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat, short compatibility);
/* ************** COMPOSITE NODES *************** */
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 2781437..608c498 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1592,7 +1592,10 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma)
if (!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) {
/* create nodes */
- ntreeGPUMaterialNodes(ma->nodetree, mat);
+ if (BKE_scene_use_new_shading_nodes(scene))
+ ntreeGPUMaterialNodes(ma->nodetree, mat, NODE_NEW_SHADING);
+ else
+ ntreeGPUMaterialNodes(ma->nodetree, mat, NODE_OLD_SHADING);
}
else {
if (BKE_scene_use_new_shading_nodes(scene)) {
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 1e828ea..2186eb7 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -187,14 +187,14 @@ void register_node_tree_type_sh(void)
/* GPU material from shader nodes */
-void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat)
+void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, short compatibility)
{
/* localize tree to create links for reroute and mute */
bNodeTree *localtree = ntreeLocalize(ntree);
bNodeTreeExec *exec;
exec = ntreeShaderBeginExecTree(localtree);
- ntreeExecGPUNodes(exec, mat, 1);
+ ntreeExecGPUNodes(exec, mat, 1, compatibility);
ntreeShaderEndExecTree(exec);
ntreeFreeTree_ex(localtree, false);
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 86e59cd..8e83140 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -219,7 +219,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
return inactivenode;
}
-void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
+void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, short compatibility)
{
bNodeExec *nodeexec;
bNode *node;
@@ -238,8 +238,9 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
do_it = FALSE;
/* for groups, only execute outputs for edited group */
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
- if (do_outputs && (node->flag & NODE_DO_OUTPUT))
- do_it = TRUE;
+ if (node->typeinfo->compatibility & compatibility)
+ if (do_outputs && (node->flag & NODE_DO_OUTPUT))
+ do_it = TRUE;
}
else
do_it = TRUE;
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index cfd97ab..8a79603 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -98,6 +98,6 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeSta
void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs);
void node_shader_gpu_tex_mapping(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
-void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
+void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs, short compatibility);
#endif
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index 0ea4f94..3f03bb4 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -218,7 +218,7 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd
#if 0 /* XXX NODE_GROUP_EDIT is deprecated, depends on node space */
ntreeExecGPUNodes(exec, mat, (node->flag & NODE_GROUP_EDIT));
#else
- ntreeExecGPUNodes(exec, mat, 0);
+ ntreeExecGPUNodes(exec, mat, 0, NODE_NEW_SHADING|NODE_OLD_SHADING);
#endif
group_gpu_move_outputs(node, out, exec->stack);
More information about the Bf-blender-cvs
mailing list