From f61a8a2abd07ee879f9bc860230e0dd3e6ee6a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 10 Oct 2019 00:31:47 +0200 Subject: Fix T70614 EEVEE: Bump with texture connected to other branches don't work Was caused by the bump node not being evaluated because the other branch was evaluated before. To fix this, we use fromnode instead of tonode. Also we fix a potential issue with recursiveness because ntree_shader_copy_branch() also use nodeChainIterBackwards() which would reset the iter_flag in the middle of the parent iteration. Use iter_flag as a bitflag for each iteration to fix this. --- source/blender/nodes/shader/node_shader_tree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index b2d979074fe..4bcd77496c1 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -629,7 +629,7 @@ static bNode *ntree_shader_copy_branch(bNodeTree *ntree, /* Count and tag all nodes inside the displacement branch of the tree. */ start_node->tmp_flag = 0; int node_count = 1; - nodeChainIterBackwards(ntree, start_node, ntree_branch_count_and_tag_nodes, &node_count); + nodeChainIterBackwards(ntree, start_node, ntree_branch_count_and_tag_nodes, &node_count, 1); /* Make a full copy of the branch */ bNode **nodes_copy = MEM_mallocN(sizeof(bNode *) * node_count, __func__); LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { @@ -763,13 +763,13 @@ static void node_tag_branch_as_derivative(bNode *node, int dx) } } -static bool ntree_shader_bump_branches(bNode *UNUSED(fromnode), bNode *tonode, void *userdata) +static bool ntree_shader_bump_branches(bNode *fromnode, bNode *UNUSED(tonode), void *userdata) { bNodeTree *ntree = (bNodeTree *)userdata; - if (tonode->type == SH_NODE_BUMP) { + if (fromnode->type == SH_NODE_BUMP) { bNodeSocket *height_dx_sock, *height_dy_sock, *bump_socket, *bump_dx_socket, *bump_dy_socket; - bNode *bump = tonode; + bNode *bump = fromnode; bump_socket = ntree_shader_node_find_input(bump, "Height"); bump_dx_socket = ntree_shader_node_find_input(bump, "Height_dx"); bump_dy_socket = ntree_shader_node_find_input(bump, "Height_dy"); @@ -832,7 +832,7 @@ void ntree_shader_tag_nodes(bNodeTree *ntree, bNode *output_node, nTreeTags *tag /* Make sure sockets links pointers are correct. */ ntreeUpdateTree(G.main, ntree); - nodeChainIterBackwards(ntree, output_node, ntree_tag_bsdf_cb, tags); + nodeChainIterBackwards(ntree, output_node, ntree_tag_bsdf_cb, tags, 0); } /* This one needs to work on a local tree. */ @@ -861,7 +861,7 @@ void ntreeGPUMaterialNodes(bNodeTree *localtree, /* Duplicate bump height branches for manual derivatives. */ - nodeChainIterBackwards(localtree, output, ntree_shader_bump_branches, localtree); + nodeChainIterBackwards(localtree, output, ntree_shader_bump_branches, localtree, 0); /* TODO(fclem): consider moving this to the gpu shader tree evaluation. */ nTreeTags tags = { -- cgit v1.2.3