Blender  V3.3
Classes | Functions | Variables
node_shader_tree.cc File Reference
#include <cstring>
#include "DNA_light_types.h"
#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_workspace_types.h"
#include "DNA_world_types.h"
#include "BLI_array.hh"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_lib_id.h"
#include "BKE_linestyle.h"
#include "BKE_node.h"
#include "BKE_node_tree_update.h"
#include "BKE_scene.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "GPU_material.h"
#include "RE_texture.h"
#include "UI_resources.h"
#include "NOD_common.h"
#include "node_common.h"
#include "node_exec.h"
#include "node_shader_util.hh"
#include "node_util.h"

Go to the source code of this file.

Classes

struct  branchIterData
 

Functions

static bool shader_tree_poll (const bContext *C, bNodeTreeType *UNUSED(treetype))
 
static void shader_get_from_context (const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
 
static void foreach_nodeclass (Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
 
static void localize (bNodeTree *localtree, bNodeTree *UNUSED(ntree))
 
static void update (bNodeTree *ntree)
 
static bool shader_validate_link (eNodeSocketDatatype from, eNodeSocketDatatype to)
 
static bool shader_node_tree_socket_type_valid (bNodeTreeType *UNUSED(ntreetype), bNodeSocketType *socket_type)
 
void register_node_tree_type_sh ()
 
bNodentreeShaderOutputNode (bNodeTree *ntree, int target)
 
static bNodeSocketntree_shader_node_find_socket (ListBase *sockets, const char *identifier)
 
static bNodeSocketntree_shader_node_find_input (bNode *node, const char *identifier)
 
static bNodeSocketntree_shader_node_find_output (bNode *node, const char *identifier)
 
static bNodeSocketntree_shader_node_input_get (bNode *node, int n)
 
static bNodeSocketntree_shader_node_output_get (bNode *node, int n)
 
static bool ntree_shader_expand_socket_default (bNodeTree *localtree, bNode *node, bNodeSocket *socket)
 
static void ntree_shader_unlink_hidden_value_sockets (bNode *group_node, bNodeSocket *isock)
 
static void ntree_shader_groups_expand_inputs (bNodeTree *localtree)
 
static void ntree_shader_groups_remove_muted_links (bNodeTree *ntree)
 
static void flatten_group_do (bNodeTree *ntree, bNode *gnode)
 
static void ntree_shader_groups_flatten (bNodeTree *localtree)
 
static bool ntree_branch_count_and_tag_nodes (bNode *fromnode, bNode *tonode, void *userdata)
 
static bNodentree_shader_copy_branch (bNodeTree *ntree, bNode *start_node, bool(*node_filter)(const bNode *node), void(*callback)(bNode *node, int user_data), int user_data)
 
static bool ntree_shader_implicit_closure_cast (bNodeTree *ntree)
 
static void ntree_weight_tree_merge_weight (bNodeTree *ntree, bNode *UNUSED(fromnode), bNodeSocket *fromsock, bNode **tonode, bNodeSocket **tosock)
 
static bool ntree_weight_tree_tag_nodes (bNode *fromnode, bNode *tonode, void *userdata)
 
static void ntree_shader_weight_tree_invert (bNodeTree *ntree, bNode *output_node)
 
static bool closure_node_filter (const bNode *node)
 
static bool shader_to_rgba_node_gather (bNode *UNUSED(fromnode), bNode *tonode, void *userdata)
 
static void ntree_shader_shader_to_rgba_branch (bNodeTree *ntree, bNode *output_node)
 
static bool ntree_branch_node_tag (bNode *fromnode, bNode *tonode, void *UNUSED(userdata))
 
static void ntree_shader_pruned_unused (bNodeTree *ntree, bNode *output_node)
 
void ntreeGPUMaterialNodes (bNodeTree *localtree, GPUMaterial *mat)
 
bNodeTreeExecntreeShaderBeginExecTree_internal (bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key)
 
bNodeTreeExecntreeShaderBeginExecTree (bNodeTree *ntree)
 
void ntreeShaderEndExecTree_internal (bNodeTreeExec *exec)
 
void ntreeShaderEndExecTree (bNodeTreeExec *exec)
 

Variables

bNodeTreeTypentreeType_Shader
 

Function Documentation

◆ closure_node_filter()

static bool closure_node_filter ( const bNode node)
static

◆ flatten_group_do()

static void flatten_group_do ( bNodeTree ntree,
bNode gnode 
)
static

◆ foreach_nodeclass()

static void foreach_nodeclass ( Scene UNUSEDscene,
void calldata,
bNodeClassCallback  func 
)
static

◆ localize()

static void localize ( bNodeTree localtree,
bNodeTree UNUSEDntree 
)
static

◆ ntree_branch_count_and_tag_nodes()

static bool ntree_branch_count_and_tag_nodes ( bNode fromnode,
bNode tonode,
void userdata 
)
static

◆ ntree_branch_node_tag()

static bool ntree_branch_node_tag ( bNode fromnode,
bNode tonode,
void UNUSEDuserdata 
)
static

Definition at line 987 of file node_shader_tree.cc.

References bNode::tmp_flag.

Referenced by ntree_shader_pruned_unused().

◆ ntree_shader_copy_branch()

static bNode* ntree_shader_copy_branch ( bNodeTree ntree,
bNode start_node,
bool(*)(const bNode *node node_filter,
void(*)(bNode *node, int user_data callback,
int  user_data 
)
static

◆ ntree_shader_expand_socket_default()

static bool ntree_shader_expand_socket_default ( bNodeTree localtree,
bNode node,
bNodeSocket socket 
)
static

◆ ntree_shader_groups_expand_inputs()

static void ntree_shader_groups_expand_inputs ( bNodeTree localtree)
static

◆ ntree_shader_groups_flatten()

static void ntree_shader_groups_flatten ( bNodeTree localtree)
static

◆ ntree_shader_groups_remove_muted_links()

static void ntree_shader_groups_remove_muted_links ( bNodeTree ntree)
static

◆ ntree_shader_implicit_closure_cast()

static bool ntree_shader_implicit_closure_cast ( bNodeTree ntree)
static

◆ ntree_shader_node_find_input()

static bNodeSocket* ntree_shader_node_find_input ( bNode node,
const char *  identifier 
)
static

◆ ntree_shader_node_find_output()

static bNodeSocket* ntree_shader_node_find_output ( bNode node,
const char *  identifier 
)
static

◆ ntree_shader_node_find_socket()

static bNodeSocket* ntree_shader_node_find_socket ( ListBase sockets,
const char *  identifier 
)
static

Definition at line 229 of file node_shader_tree.cc.

References LISTBASE_FOREACH, and STREQ.

Referenced by ntree_shader_node_find_input(), and ntree_shader_node_find_output().

◆ ntree_shader_node_input_get()

static bNodeSocket* ntree_shader_node_input_get ( bNode node,
int  n 
)
static

◆ ntree_shader_node_output_get()

static bNodeSocket* ntree_shader_node_output_get ( bNode node,
int  n 
)
static

◆ ntree_shader_pruned_unused()

static void ntree_shader_pruned_unused ( bNodeTree ntree,
bNode output_node 
)
static

◆ ntree_shader_shader_to_rgba_branch()

static void ntree_shader_shader_to_rgba_branch ( bNodeTree ntree,
bNode output_node 
)
static

◆ ntree_shader_unlink_hidden_value_sockets()

static void ntree_shader_unlink_hidden_value_sockets ( bNode group_node,
bNodeSocket isock 
)
static

◆ ntree_shader_weight_tree_invert()

static void ntree_shader_weight_tree_invert ( bNodeTree ntree,
bNode output_node 
)
static

◆ ntree_weight_tree_merge_weight()

static void ntree_weight_tree_merge_weight ( bNodeTree ntree,
bNode UNUSEDfromnode,
bNodeSocket fromsock,
bNode **  tonode,
bNodeSocket **  tosock 
)
static

◆ ntree_weight_tree_tag_nodes()

static bool ntree_weight_tree_tag_nodes ( bNode fromnode,
bNode tonode,
void userdata 
)
static

◆ ntreeGPUMaterialNodes()

void ntreeGPUMaterialNodes ( struct bNodeTree localtree,
struct GPUMaterial mat 
)

◆ ntreeShaderBeginExecTree()

bNodeTreeExec* ntreeShaderBeginExecTree ( bNodeTree ntree)

◆ ntreeShaderBeginExecTree_internal()

bNodeTreeExec* ntreeShaderBeginExecTree_internal ( bNodeExecContext context,
bNodeTree ntree,
bNodeInstanceKey  parent_key 
)

◆ ntreeShaderEndExecTree()

void ntreeShaderEndExecTree ( bNodeTreeExec exec)

◆ ntreeShaderEndExecTree_internal()

void ntreeShaderEndExecTree_internal ( bNodeTreeExec exec)

◆ ntreeShaderOutputNode()

bNode* ntreeShaderOutputNode ( struct bNodeTree ntree,
int  target 
)

Find an output node of the shader tree.

Note
it will only return output which is NOT in the group, which isn't how render engines works but it's how the GPU shader compilation works. This we can change in the future and make it a generic function, but for now it stays private here.

Definition at line 188 of file node_shader_tree.cc.

References bNode::custom1, ELEM, bNode::flag, LISTBASE_FOREACH, node, NODE_DO_OUTPUT, bNodeTree::nodes, ntree, ntreeSetOutput(), SH_NODE_OUTPUT_LIGHT, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, and SHD_OUTPUT_ALL.

Referenced by light_emission_node_to_energy(), and ntreeGPUMaterialNodes().

◆ register_node_tree_type_sh()

void register_node_tree_type_sh ( void  )

◆ shader_get_from_context()

static void shader_get_from_context ( const bContext C,
bNodeTreeType UNUSEDtreetype,
bNodeTree **  r_ntree,
ID **  r_id,
ID **  r_from 
)
static

◆ shader_node_tree_socket_type_valid()

static bool shader_node_tree_socket_type_valid ( bNodeTreeType UNUSEDntreetype,
bNodeSocketType socket_type 
)
static

◆ shader_to_rgba_node_gather()

static bool shader_to_rgba_node_gather ( bNode UNUSEDfromnode,
bNode tonode,
void userdata 
)
static

◆ shader_tree_poll()

static bool shader_tree_poll ( const bContext C,
bNodeTreeType UNUSEDtreetype 
)
static

◆ shader_validate_link()

static bool shader_validate_link ( eNodeSocketDatatype  from,
eNodeSocketDatatype  to 
)
static

Definition at line 144 of file node_shader_tree.cc.

References from, and SOCK_SHADER.

Referenced by register_node_tree_type_sh().

◆ update()

static void update ( bNodeTree ntree)
static

Definition at line 137 of file node_shader_tree.cc.

References ntree, ntree_update_reroute_nodes(), and ntreeSetOutput().

Referenced by register_node_tree_type_sh().

Variable Documentation

◆ ntreeType_Shader

bNodeTreeType* ntreeType_Shader