36 #include "RNA_prototypes.h"
49 #include "node_util.h"
80 *r_id =
static_cast<ID *
>(ob->
data);
168 strcpy(tt->
idname,
"ShaderNodeTree");
169 strcpy(tt->
ui_name,
N_(
"Shader Editor"));
170 tt->
ui_icon = ICON_NODE_MATERIAL;
195 bNode *output_node =
nullptr;
203 if (output_node ==
nullptr) {
212 else if (
node->custom1 == target) {
213 if (output_node ==
nullptr) {
232 if (
STREQ(sock->identifier, identifier)) {
275 switch (socket->
type) {
283 dst_rgba->
value[3] = 1.0f;
320 bool removed_link =
false;
354 bool link_added =
false;
365 if (is_group || is_group_output) {
367 if (socket->link !=
nullptr && !(socket->link->flag &
NODE_LINK_MUTED)) {
420 if (
node->id !=
nullptr) {
434 LinkNode *group_interface_nodes =
nullptr;
465 if (glinks_first !=
nullptr) {
472 tlink != glinks_first->
next;
473 tlink = tlink->
next) {
474 if (tlink->tonode == gnode &&
STREQ(tlink->tosock->identifier, identifier)) {
475 nodeAddLink(
ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock);
484 tlink != glinks_first->
next;
485 tlink = tlink->
next) {
486 if (tlink->fromnode == gnode) {
492 if (
STREQ(link->tosock->identifier, identifier)) {
493 nodeAddLink(
ntree, link->fromnode, link->fromsock, tlink->tonode, tlink->tosock);
501 while (group_interface_nodes) {
519 node_next =
node->next;
528 node_next =
node->next;
576 if (
node->tmp_flag >= 0) {
577 int id =
node->tmp_flag;
580 nodes_copy[
id]->tmp_flag = -2;
583 sock->link =
nullptr;
586 sock->link =
nullptr;
592 if (link->tonode->tmp_flag >= 0) {
593 bool from_node_copied = link->fromnode->tmp_flag >= 0;
594 bNode *fromnode = from_node_copied ? nodes_copy[link->fromnode->tmp_flag] : link->fromnode;
595 bNode *tonode = nodes_copy[link->tonode->tmp_flag];
603 for (
int i = 0; i < iter_data.
node_count; i++) {
608 return start_node_copy;
616 bool modified =
false;
629 fprintf(stderr,
"Shader Nodetree Error: Invalid implicit socket conversion\n");
658 *tosock = addsock_out;
663 int *node_count = (
int *)userdata;
664 bool to_node_from_weight_tree =
ELEM(tonode->
type,
670 if (tonode->
tmp_flag == -1 && to_node_from_weight_tree) {
678 return to_node_from_weight_tree;
687 if (displace_output && displace_output->
link) {
689 displace_link = displace_output->
link;
694 if (thickness_output && thickness_output->
link) {
696 thickness_link = thickness_output->
link;
710 if (
node->tmp_flag >= 0) {
711 int id =
node->tmp_flag;
713 switch (
node->type) {
720 nodes_copy[
id]->tmp_flag = -2;
730 nodes_copy[
id]->tmp_flag = -2;
737 bNode *fromnode, *tonode;
743 nodes_copy[
id]->tmp_flag = -2;
748 nodes_copy[
id]->tmp_flag = -2;
754 nodes_copy[
id]->tmp_flag = -2;
759 if (!fac_sock->
link) {
769 nodes_copy[
id]->tmp_flag = -2;
774 fromnode = nodes_copy[id_start];
775 tonode = nodes_copy[id_start + 1];
780 fromnode = nodes_copy[id_start + 2];
781 tonode = nodes_copy[id_start];
786 fromnode = nodes_copy[id_start + 3];
788 tonode = nodes_copy[id_start];
791 tonode = nodes_copy[id_start + 1];
804 if (
node->tmp_flag >= 0) {
812 switch (
node->type) {
818 tonode = nodes_copy[
node->tmp_flag];
823 if (socket_index == 0) {
825 tonode = nodes_copy[
node->tmp_flag + 2];
828 else if (socket_index == 1) {
830 tonode = nodes_copy[
node->tmp_flag + 1];
835 tonode = nodes_copy[
node->tmp_flag];
847 bNode *fromnode = sock->link->fromnode;
849 switch (fromnode->
type) {
851 fromnode = nodes_copy[fromnode->
tmp_flag];
853 if (fromsock->
link) {
859 fromnode = nodes_copy[fromnode->
tmp_flag + 3];
861 if (fromsock->
link) {
887 if (fromsock->
link) {
909 if (thickness_link) {
918 switch (
node->type) {
952 shader_to_rgba_nodes.
append(tonode);
968 for (
bNode *shader_to_rgba : shader_to_rgba_nodes) {
970 if (closure_input->
link ==
nullptr) {
980 nodeAddLink(
ntree, start_node_copy, closure_output, shader_to_rgba, closure_input);
999 bool changed =
false;
1018 if (
node->tmp_flag == 0) {
1073 node->need_exec = 1;
1105 if (
exec->threadstack) {
1116 exec->threadstack =
nullptr;
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
struct SpaceNode * CTX_wm_space_node(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
Blender kernel freestyle line style functionality.
FreestyleLineStyle * BKE_linestyle_active_from_view_layer(struct ViewLayer *view_layer)
struct Material * BKE_object_material_get(struct Object *ob, short act)
#define SH_NODE_MIX_SHADER
void ntreeTypeAdd(struct bNodeTreeType *nt)
#define NODE_CLASS_OUTPUT
#define NODE_CLASS_INTERFACE
void nodeInternalRelink(struct bNodeTree *ntree, struct bNode *node)
const bNodeInstanceKey NODE_INSTANCE_KEY_BASE
#define NODE_CUSTOM_GROUP
#define SH_NODE_BSDF_PRINCIPLED
#define NODE_CLASS_CONVERTER
void ntreeFreeLocalNode(struct bNodeTree *ntree, struct bNode *node)
#define SH_NODE_ADD_SHADER
#define SH_NODE_SUBSURFACE_SCATTERING
void(* bNodeClassCallback)(void *calldata, int nclass, const char *name)
#define SH_NODE_VOLUME_ABSORPTION
#define SH_NODE_BSDF_VELVET
void ntreeFreeTree(struct bNodeTree *ntree)
void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link)
#define SH_NODE_BSDF_TOON
#define SH_NODE_BSDF_TRANSPARENT
#define SH_NODE_BSDF_DIFFUSE
#define SH_NODE_SHADERTORGB
#define SH_NODE_OUTPUT_MATERIAL
bool nodeIsStaticSocketType(const struct bNodeSocketType *stype)
#define SH_NODE_BSDF_TRANSLUCENT
void ntreeSetOutput(struct bNodeTree *ntree)
#define SH_NODE_BSDF_HAIR_PRINCIPLED
#define SH_NODE_BSDF_HAIR
struct bNodeLink * nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock)
#define SH_NODE_BACKGROUND
#define SH_NODE_BSDF_ANISOTROPIC
#define SH_NODE_BSDF_GLOSSY
#define NODE_CLASS_OP_VECTOR
#define NODE_CLASS_LAYOUT
#define NODE_CLASS_OP_COLOR
#define SH_NODE_BSDF_GLASS
void nodeChainIterBackwards(const bNodeTree *ntree, const bNode *node_start, bool(*callback)(bNode *, bNode *, void *), void *userdata, int recursion_lvl)
struct bNode * nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type)
#define SH_NODE_VOLUME_PRINCIPLED
#define NODE_CLASS_TEXTURE
#define SH_NODE_BSDF_REFRACTION
#define SH_NODE_OUTPUT_LIGHT
#define NODE_CLASS_SHADER
#define SH_NODE_VOLUME_SCATTER
#define SH_NODE_OUTPUT_AOV
#define NODE_CLASS_SCRIPT
void BKE_ntree_update_tag_all(struct bNodeTree *ntree)
void BKE_ntree_update_main_tree(struct Main *bmain, struct bNodeTree *ntree, struct NodeTreeUpdateExtraParams *params)
bool BKE_scene_use_shading_nodes_custom(struct Scene *scene)
void void void * BLI_linklist_pop(LinkNode **listp) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_linklist_prepend(LinkNode **listp, void *ptr) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl(float r[3], float f)
#define BLENDER_MAX_THREADS
@ NODE_VECTOR_MATH_DOT_PRODUCT
#define OBACT(_view_layer)
Group Output data from inside of a node group A color picker Mix two input colors SH_NODE_RGBTOBW
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue Hue Saturation Apply a color transformation in the HSV color model SH_NODE_EEVEE_SPECULAR
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue Hue Saturation Apply a color transformation in the HSV color model Specular Similar to the Principled BSDF node but uses the specular workflow instead of which functions by specifying the so the result may not be physically accurate SH_NODE_OUTPUT_WORLD
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum SH_NODE_VECTOR_MATH
Group Output data from inside of a node group SH_NODE_RGB
void append(const T &value)
FreestyleLineStyle linestyle
DEGForeachIDComponentCallback callback
ccl_global KernelShaderEvalInput ccl_global float * output
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
bNode * node_copy(bNodeTree *dst_tree, const bNode &src_node, const int flag, const bool unique_name)
void ntree_update_reroute_nodes(bNodeTree *ntree)
bNodeTreeExec * ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key)
void ntree_exec_end(bNodeTreeExec *exec)
static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
static bool shader_node_tree_socket_type_valid(bNodeTreeType *UNUSED(ntreetype), bNodeSocketType *socket_type)
static bool ntree_shader_implicit_closure_cast(bNodeTree *ntree)
static bool ntree_branch_node_tag(bNode *fromnode, bNode *tonode, void *UNUSED(userdata))
bNodeTreeExec * ntreeShaderBeginExecTree(bNodeTree *ntree)
static bool ntree_branch_count_and_tag_nodes(bNode *fromnode, bNode *tonode, void *userdata)
static bool ntree_weight_tree_tag_nodes(bNode *fromnode, bNode *tonode, void *userdata)
static bool ntree_shader_expand_socket_default(bNodeTree *localtree, bNode *node, bNodeSocket *socket)
static bool shader_to_rgba_node_gather(bNode *UNUSED(fromnode), bNode *tonode, void *userdata)
static bNodeSocket * ntree_shader_node_find_output(bNode *node, const char *identifier)
static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
bNodeTreeExec * ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key)
static void ntree_shader_groups_flatten(bNodeTree *localtree)
void ntreeGPUMaterialNodes(bNodeTree *localtree, GPUMaterial *mat)
static void ntree_weight_tree_merge_weight(bNodeTree *ntree, bNode *UNUSED(fromnode), bNodeSocket *fromsock, bNode **tonode, bNodeSocket **tosock)
static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))
static bNodeSocket * ntree_shader_node_output_get(bNode *node, int n)
static bool closure_node_filter(const bNode *node)
static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
static void ntree_shader_weight_tree_invert(bNodeTree *ntree, bNode *output_node)
void register_node_tree_type_sh()
static bNode * ntree_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 void update(bNodeTree *ntree)
static bNodeSocket * ntree_shader_node_find_socket(ListBase *sockets, const char *identifier)
static bNodeSocket * ntree_shader_node_input_get(bNode *node, int n)
static bool shader_validate_link(eNodeSocketDatatype from, eNodeSocketDatatype to)
static void ntree_shader_pruned_unused(bNodeTree *ntree, bNode *output_node)
static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSocket *isock)
static void ntree_shader_shader_to_rgba_branch(bNodeTree *ntree, bNode *output_node)
bNodeTreeType * ntreeType_Shader
static void flatten_group_do(bNodeTree *ntree, bNode *gnode)
static bool shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype))
static void ntree_shader_groups_remove_muted_links(bNodeTree *ntree)
void ntreeShaderEndExecTree(bNodeTreeExec *exec)
bNode * ntreeShaderOutputNode(bNodeTree *ntree, int target)
void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec)
static bNodeSocket * ntree_shader_node_find_input(bNode *node, const char *identifier)
void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node)
static bNodeSocketTemplate outputs[]
static bNodeSocketTemplate inputs[]
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
const char * RE_engine_id_CYCLES
struct bNodeTree * nodetree
struct bNodeTree * nodetree
struct bNodeTree * nodetree
struct bNodeSocket * next
bool(* validate_link)(eNodeSocketDatatype from, eNodeSocketDatatype to)
bool(* poll)(const struct bContext *C, struct bNodeTreeType *ntreetype)
void(* update)(struct bNodeTree *ntree)
void(* get_from_context)(const struct bContext *C, struct bNodeTreeType *ntreetype, struct bNodeTree **r_ntree, struct ID **r_id, struct ID **r_from)
void(* localize)(struct bNodeTree *localtree, struct bNodeTree *ntree)
bool(* valid_socket_type)(struct bNodeTreeType *ntreetype, struct bNodeSocketType *socket_type)
void(* foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func)
struct bNodeInstanceHash * previews
struct bNodeTreeExec * execdata
bool(* node_filter)(const bNode *node)