diff options
Diffstat (limited to 'source/blender/nodes/shader')
-rw-r--r-- | source/blender/nodes/shader/node_shader_tree.c | 67 | ||||
-rw-r--r-- | source/blender/nodes/shader/node_shader_util.c | 4 | ||||
-rw-r--r-- | source/blender/nodes/shader/node_shader_util.h | 2 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_common.c | 6 |
4 files changed, 24 insertions, 55 deletions
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 301fd3c35a8..329e850d19e 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -258,11 +258,11 @@ static bNodeSocket *ntree_shader_node_find_output(bNode *node, * also returned. */ static bool ntree_shader_has_displacement(bNodeTree *ntree, + bNode *output_node, bNode **r_node, bNodeSocket **r_socket, bNodeLink **r_link) { - bNode *output_node = ntree_shader_output_node(ntree); if (output_node == NULL) { /* We can't have displacement without output node, apparently. */ return false; @@ -426,17 +426,13 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree, /* Re-link displacement output to unconnected normal sockets via bump node. * This way material with have proper displacement in the viewport. */ -static void ntree_shader_relink_displacement(bNodeTree *ntree, - short compatibility) +static void ntree_shader_relink_displacement(bNodeTree *ntree, bNode *output_node) { - if ((compatibility & NODE_NEW_SHADING) == 0) { - /* We can only deal with new shading system here. */ - return; - } bNode *displacement_node; bNodeSocket *displacement_socket; bNodeLink *displacement_link; if (!ntree_shader_has_displacement(ntree, + output_node, &displacement_node, &displacement_socket, &displacement_link)) @@ -514,14 +510,8 @@ static bool ntree_tag_ssr_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void * /* EEVEE: Scan the ntree to set the Screen Space Reflection * layer id of every specular node. */ -static void ntree_shader_tag_ssr_node(bNodeTree *ntree, short compatibility) +static void ntree_shader_tag_ssr_node(bNodeTree *ntree, bNode *output_node) { - if ((compatibility & NODE_NEWER_SHADING) == 0) { - /* We can only deal with new shading system here. */ - return; - } - - bNode *output_node = ntree_shader_output_node(ntree); if (output_node == NULL) { return; } @@ -549,14 +539,8 @@ static bool ntree_tag_sss_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void * /* EEVEE: Scan the ntree to set the Subsurface Scattering id of every SSS node. */ -static void ntree_shader_tag_sss_node(bNodeTree *ntree, short compatibility) +static void ntree_shader_tag_sss_node(bNodeTree *ntree, bNode *output_node) { - if ((compatibility & NODE_NEWER_SHADING) == 0) { - /* We can only deal with new shading system here. */ - return; - } - - bNode *output_node = ntree_shader_output_node(ntree); if (output_node == NULL) { return; } @@ -567,15 +551,26 @@ static void ntree_shader_tag_sss_node(bNodeTree *ntree, short compatibility) nodeChainIter(ntree, output_node, ntree_tag_sss_bsdf_cb, &sss_id, true); } -/* EEVEE: Find which material domain are used (volume, surface ...). - */ -void ntreeGPUMaterialDomain(bNodeTree *ntree, bool *has_surface_output, bool *has_volume_output) +void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, bool *has_surface_output, bool *has_volume_output) { /* localize tree to create links for reroute and mute */ bNodeTree *localtree = ntreeLocalize(ntree); + bNode *output = ntree_shader_output_node(localtree); + bNodeTreeExec *exec; + + /* Perform all needed modifications on the tree in order to support + * displacement/bump mapping. + */ + ntree_shader_relink_displacement(localtree, output); + + ntree_shader_tag_ssr_node(localtree, output); + ntree_shader_tag_sss_node(localtree, output); - struct bNode *output = ntree_shader_output_node(localtree); + exec = ntreeShaderBeginExecTree(localtree); + ntreeExecGPUNodes(exec, mat, 1); + ntreeShaderEndExecTree(exec); + /* EEVEE: Find which material domain was used (volume, surface ...). */ *has_surface_output = false; *has_volume_output = false; @@ -596,28 +591,6 @@ void ntreeGPUMaterialDomain(bNodeTree *ntree, bool *has_surface_output, bool *ha MEM_freeN(localtree); } -void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, short compatibility) -{ - /* localize tree to create links for reroute and mute */ - bNodeTree *localtree = ntreeLocalize(ntree); - bNodeTreeExec *exec; - - /* Perform all needed modifications on the tree in order to support - * displacement/bump mapping. - */ - ntree_shader_relink_displacement(localtree, compatibility); - - ntree_shader_tag_ssr_node(localtree, compatibility); - ntree_shader_tag_sss_node(localtree, compatibility); - - exec = ntreeShaderBeginExecTree(localtree); - ntreeExecGPUNodes(exec, mat, 1, compatibility); - ntreeShaderEndExecTree(exec); - - ntreeFreeTree(localtree); - MEM_freeN(localtree); -} - bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key) { bNodeTreeExec *exec; diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 5cc7d14bc8b..1ae50dab358 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -207,7 +207,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree) return inactivenode; } -void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, short compatibility) +void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs) { bNodeExec *nodeexec; bNode *node; @@ -226,7 +226,7 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, sh do_it = false; /* for groups, only execute outputs for edited group */ if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { - if (node->typeinfo->compatibility & compatibility) + if (node->typeinfo->compatibility & NODE_NEW_SHADING) if (do_outputs && (node->flag & NODE_DO_OUTPUT)) do_it = true; } diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h index 4fb18b1a9d8..7fce5ed9927 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, short compatibility); +void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs); #endif diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index 24de03dbda4..09fc10a4c71 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -215,11 +215,7 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd return 0; group_gpu_copy_inputs(node, in, exec->stack); -#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, NODE_NEW_SHADING | NODE_OLD_SHADING); -#endif + ntreeExecGPUNodes(exec, mat, 0); group_gpu_move_outputs(node, out, exec->stack); return 1; |