Blender V5.0
node_shader_tree.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2007 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10
11#include "DNA_light_types.h"
12#include "DNA_linestyle_types.h"
13#include "DNA_material_types.h"
14#include "DNA_node_types.h"
15#include "DNA_scene_types.h"
16#include "DNA_space_types.h"
17#include "DNA_world_types.h"
18
19#include "BLI_array.hh"
20#include "BLI_linklist.h"
21#include "BLI_listbase.h"
22#include "BLI_map.hh"
23#include "BLI_math_vector.h"
24#include "BLI_set.hh"
25#include "BLI_stack.hh"
26#include "BLI_threads.h"
27#include "BLI_utildefines.h"
28#include "BLI_vector.hh"
29
30#include "BKE_context.hh"
31#include "BKE_global.hh"
32#include "BKE_layer.hh"
33#include "BKE_lib_id.hh"
34#include "BKE_linestyle.h"
35#include "BKE_material.hh"
36#include "BKE_node.hh"
38#include "BKE_node_runtime.hh"
40#include "BKE_scene.hh"
41
42#include "RNA_prototypes.hh"
43
44#include "UI_resources.hh"
45
46#include "NOD_shader.h"
47
48#include "node_common.h"
49#include "node_exec.hh"
50#include "node_shader_util.hh"
51#include "node_util.hh"
52
53using blender::Array;
54using blender::Vector;
55
56static bool shader_tree_poll(const bContext *C, blender::bke::bNodeTreeType * /*treetype*/)
57{
58 Scene *scene = CTX_data_scene(C);
59 const char *engine_id = scene->r.engine;
60
61 /* Allow empty engine string too,
62 * this is from older versions that didn't have registerable engines yet. */
63 return (engine_id[0] == '\0' || STREQ(engine_id, RE_engine_id_CYCLES) ||
65}
66
68 blender::bke::bNodeTreeType * /*treetype*/,
69 bNodeTree **r_ntree,
70 ID **r_id,
71 ID **r_from)
72{
74 Scene *scene = CTX_data_scene(C);
75 ViewLayer *view_layer = CTX_data_view_layer(C);
76 BKE_view_layer_synced_ensure(scene, view_layer);
78
79 if (snode->shaderfrom == SNODE_SHADER_OBJECT) {
80 if (ob) {
81 *r_from = &ob->id;
82 if (ob->type == OB_LAMP) {
83 *r_id = static_cast<ID *>(ob->data);
84 *r_ntree = ((Light *)ob->data)->nodetree;
85 }
86 else {
88 if (ma) {
89 *r_id = &ma->id;
90 *r_ntree = ma->nodetree;
91 }
92 }
93 }
94 }
95#ifdef WITH_FREESTYLE
96 else if (snode->shaderfrom == SNODE_SHADER_LINESTYLE) {
98 if (linestyle) {
99 *r_from = nullptr;
100 *r_id = &linestyle->id;
101 *r_ntree = linestyle->nodetree;
102 }
103 }
104#endif
105 else { /* SNODE_SHADER_WORLD */
106 if (scene->world) {
107 *r_from = nullptr;
108 *r_id = &scene->world->id;
109 *r_ntree = scene->world->nodetree;
110 }
111 }
112}
113
115{
116 func(calldata, NODE_CLASS_INPUT, N_("Input"));
117 func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
118 func(calldata, NODE_CLASS_SHADER, N_("Shader"));
119 func(calldata, NODE_CLASS_TEXTURE, N_("Texture"));
120 func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
121 func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
122 func(calldata, NODE_CLASS_CONVERTER, N_("Converter"));
123 func(calldata, NODE_CLASS_SCRIPT, N_("Script"));
124 func(calldata, NODE_CLASS_GROUP, N_("Group"));
125 func(calldata, NODE_CLASS_INTERFACE, N_("Interface"));
126 func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
127}
128
129static void localize(bNodeTree *localtree, bNodeTree * /*ntree*/)
130{
131 /* replace muted nodes and reroute nodes by internal links */
132 LISTBASE_FOREACH_MUTABLE (bNode *, node, &localtree->nodes) {
133 if (node->is_muted() || node->is_reroute()) {
134 if (node->is_group() && node->id) {
135 /* Free the group like in #ntree_shader_groups_flatten. */
136 bNodeTree *group = reinterpret_cast<bNodeTree *>(node->id);
138 MEM_freeN(group);
139 node->id = nullptr;
140 }
141
142 blender::bke::node_internal_relink(*localtree, *node);
144 }
145 }
146}
147
148static void update(bNodeTree *ntree)
149{
151
153}
154
156{
157 /* Can't connect shader into other socket types, other way around is fine
158 * since it will be interpreted as emission. */
159 if (from == SOCK_SHADER) {
160 return to == SOCK_SHADER;
161 }
164 {
165 return from == to;
166 }
167 return true;
168}
169
172{
173 return blender::bke::node_is_static_socket_type(*socket_type) && ELEM(socket_type->type,
175 SOCK_INT,
178 SOCK_RGBA,
182 SOCK_MENU);
183}
184
186
188{
189 blender::bke::bNodeTreeType *tt = ntreeType_Shader = MEM_new<blender::bke::bNodeTreeType>(
190 __func__);
191
192 tt->type = NTREE_SHADER;
193 tt->idname = "ShaderNodeTree";
194 tt->group_idname = "ShaderNodeGroup";
195 tt->ui_name = N_("Shader Editor");
196 tt->ui_icon = ICON_NODE_MATERIAL;
197 tt->ui_description = N_("Edit materials, lights, and world shading using nodes");
198
200 tt->localize = localize;
201 tt->update = update;
206
207 tt->rna_ext.srna = &RNA_ShaderNodeTree;
208
210}
211
212/* GPU material from shader nodes */
213
215{
216 /* Make sure we only have single node tagged as output. */
218
219 /* Find output node that matches type and target. If there are
220 * multiple, we prefer exact target match and active nodes. */
221 bNode *output_node = nullptr;
222
223 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
224 if (!ELEM(node->type_legacy,
228 {
229 continue;
230 }
231
232 if (node->custom1 == SHD_OUTPUT_ALL) {
233 if (output_node == nullptr) {
234 output_node = node;
235 }
236 else if (output_node->custom1 == SHD_OUTPUT_ALL) {
237 if ((node->flag & NODE_DO_OUTPUT) && !(output_node->flag & NODE_DO_OUTPUT)) {
238 output_node = node;
239 }
240 }
241 }
242 else if (node->custom1 == target) {
243 if (output_node == nullptr) {
244 output_node = node;
245 }
246 else if (output_node->custom1 == SHD_OUTPUT_ALL) {
247 output_node = node;
248 }
249 else if ((node->flag & NODE_DO_OUTPUT) && !(output_node->flag & NODE_DO_OUTPUT)) {
250 output_node = node;
251 }
252 }
253 }
254
255 return output_node;
256}
257
258/* Find socket with a specified identifier. */
259static bNodeSocket *ntree_shader_node_find_socket(ListBase *sockets, const char *identifier)
260{
261 LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
262 if (STREQ(sock->identifier, identifier)) {
263 return sock;
264 }
265 }
266 return nullptr;
267}
268
269/* Find input socket with a specified identifier. */
270static bNodeSocket *ntree_shader_node_find_input(bNode *node, const char *identifier)
271{
272 return ntree_shader_node_find_socket(&node->inputs, identifier);
273}
274
275/* Find output socket with a specified identifier. */
276static bNodeSocket *ntree_shader_node_find_output(bNode *node, const char *identifier)
277{
278 return ntree_shader_node_find_socket(&node->outputs, identifier);
279}
280
281/* Find input socket at a specific position. */
283{
284 return reinterpret_cast<bNodeSocket *>(BLI_findlink(&node->inputs, n));
285}
286
287/* Find output socket at a specific position. */
289{
290 return reinterpret_cast<bNodeSocket *>(BLI_findlink(&node->outputs, n));
291}
292
294{
295 /* To avoid more trouble in the node tree processing (especially inside
296 * `ntree_shader_weight_tree_invert()`) we disconnect the script node since they are not
297 * supported in EEVEE (see #101702). */
298 LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
299 if ((link->tonode->type_legacy == SH_NODE_SCRIPT) ||
300 (link->fromnode->type_legacy == SH_NODE_SCRIPT))
301 {
302 blender::bke::node_remove_link(ntree, *link);
303 }
304 }
305}
306
308 bool (*node_filter)(const bNode *node);
310};
311
312static bool ntree_branch_count_and_tag_nodes(bNode *fromnode, bNode *tonode, void *userdata)
313{
314 branchIterData *iter = (branchIterData *)userdata;
315 if (fromnode->runtime->tmp_flag == -1 &&
316 (iter->node_filter == nullptr || iter->node_filter(fromnode)))
317 {
318 fromnode->runtime->tmp_flag = iter->node_count;
319 iter->node_count++;
320 }
321 if (tonode->runtime->tmp_flag == -1 &&
322 (iter->node_filter == nullptr || iter->node_filter(tonode)))
323 {
324 tonode->runtime->tmp_flag = iter->node_count;
325 iter->node_count++;
326 }
327 return true;
328}
329
330/* Create a copy of a branch starting from a given node. */
332 bNode *start_node,
333 bool (*node_filter)(const bNode *node))
334{
335 auto gather_branch_nodes = [](bNode *fromnode, bNode * /*tonode*/, void *userdata) {
336 blender::Set<bNode *> *set = static_cast<blender::Set<bNode *> *>(userdata);
337 set->add(fromnode);
338 return true;
339 };
340 blender::Set<bNode *> branch_nodes = {start_node};
342 ntree, start_node, gather_branch_nodes, &branch_nodes, 0);
343
344 /* Initialize `runtime->tmp_flag`. */
345 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
346 node->runtime->tmp_flag = -1;
347 }
348 /* Count and tag all nodes inside the displacement branch of the tree. */
349 branchIterData iter_data;
350 iter_data.node_filter = node_filter;
351 iter_data.node_count = 0;
353 ntree, start_node, ntree_branch_count_and_tag_nodes, &iter_data, 1);
354 /* Copies of the non-filtered nodes on the branch. */
355 Array<bNode *> nodes_copy(iter_data.node_count);
356
357 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
358 if (node->runtime->tmp_flag >= 0) {
359 int id = node->runtime->tmp_flag;
360 /* Avoid creating unique names in the new tree, since it is very slow.
361 * The names on the new nodes will be invalid. */
363 nodes_copy[id] = blender::bke::node_copy_with_mapping(ntree,
364 *node,
367 std::nullopt,
368 std::nullopt,
369 socket_map,
370 true);
371
372 bNode *copy = nodes_copy[id];
373 copy->runtime->tmp_flag = -2; /* Copy */
374 copy->runtime->original = node->runtime->original;
375 /* Make sure to clear all sockets links as they are invalid. */
376 LISTBASE_FOREACH (bNodeSocket *, sock, &copy->inputs) {
377 sock->link = nullptr;
378 }
379 LISTBASE_FOREACH (bNodeSocket *, sock, &copy->outputs) {
380 sock->link = nullptr;
381 }
382 }
383 }
384
385 /* Unlink the original nodes from this branch and link the copies. */
386 LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
387 bool from_copy = link->fromnode->runtime->tmp_flag >= 0;
388 bool to_copy = link->tonode->runtime->tmp_flag >= 0;
389 if (from_copy && to_copy) {
390 bNode *from_node = nodes_copy[link->fromnode->runtime->tmp_flag];
391 bNode *to_node = nodes_copy[link->tonode->runtime->tmp_flag];
393 *ntree,
394 *from_node,
395 *ntree_shader_node_find_output(from_node, link->fromsock->identifier),
396 *to_node,
397 *ntree_shader_node_find_input(to_node, link->tosock->identifier));
398 }
399 else if (to_copy) {
400 bNode *to_node = nodes_copy[link->tonode->runtime->tmp_flag];
402 *ntree,
403 *link->fromnode,
404 *link->fromsock,
405 *to_node,
406 *ntree_shader_node_find_input(to_node, link->tosock->identifier));
407 }
408 else if (from_copy && branch_nodes.contains(link->tonode)) {
409 bNode *from_node = nodes_copy[link->fromnode->runtime->tmp_flag];
411 *ntree,
412 *from_node,
413 *ntree_shader_node_find_output(from_node, link->fromsock->identifier),
414 *link->tonode,
415 *link->tosock);
416 blender::bke::node_remove_link(ntree, *link);
417 }
418 }
419}
420
421/* Generate emission node to convert regular data to closure sockets.
422 * Returns validity of the tree.
423 */
425{
426 bool modified = false;
427 LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
428 if ((link->fromsock->type != SOCK_SHADER) && (link->tosock->type == SOCK_SHADER)) {
429 bNode *emission_node = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_EMISSION);
430 bNodeSocket *in_sock = ntree_shader_node_find_input(emission_node, "Color");
431 bNodeSocket *out_sock = ntree_shader_node_find_output(emission_node, "Emission");
433 *ntree, *link->fromnode, *link->fromsock, *emission_node, *in_sock);
434 blender::bke::node_add_link(*ntree, *emission_node, *out_sock, *link->tonode, *link->tosock);
435 blender::bke::node_remove_link(ntree, *link);
436 modified = true;
437 }
438 else if ((link->fromsock->type == SOCK_SHADER) && (link->tosock->type != SOCK_SHADER)) {
439 blender::bke::node_remove_link(ntree, *link);
441 modified = true;
442 }
443 }
444 if (modified) {
446 }
447 return true;
448}
449
450/* Socket already has a link to it. Add weights together. */
452 bNode * /*fromnode*/,
453 bNodeSocket *fromsock,
454 bNode **tonode,
455 bNodeSocket **tosock)
456{
457 bNode *addnode = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
458 addnode->custom1 = NODE_MATH_ADD;
459 addnode->runtime->tmp_flag = -2; /* Copy */
460 bNodeSocket *addsock_out = ntree_shader_node_output_get(addnode, 0);
461 bNodeSocket *addsock_in0 = ntree_shader_node_input_get(addnode, 0);
462 bNodeSocket *addsock_in1 = ntree_shader_node_input_get(addnode, 1);
463 bNodeLink *oldlink = fromsock->link;
465 *ntree, *oldlink->fromnode, *oldlink->fromsock, *addnode, *addsock_in0);
466 blender::bke::node_add_link(*ntree, **tonode, **tosock, *addnode, *addsock_in1);
467 blender::bke::node_remove_link(ntree, *oldlink);
468 *tonode = addnode;
469 *tosock = addsock_out;
470}
471
472static bool ntree_weight_tree_tag_nodes(bNode *fromnode, bNode *tonode, void *userdata)
473{
474 int *node_count = (int *)userdata;
475 bool to_node_from_weight_tree = ELEM(tonode->type_legacy,
481 if (tonode->runtime->tmp_flag == -1 && to_node_from_weight_tree) {
482 tonode->runtime->tmp_flag = *node_count;
483 *node_count += (tonode->type_legacy == SH_NODE_MIX_SHADER) ? 4 : 1;
484 }
485 if (fromnode->runtime->tmp_flag == -1 &&
487 {
488 fromnode->runtime->tmp_flag = *node_count;
489 *node_count += (fromnode->type_legacy == SH_NODE_MIX_SHADER) ? 4 : 1;
490 }
491 return to_node_from_weight_tree;
492}
493
494/* Invert evaluation order of the weight tree (add & mix closure nodes) to feed the closure nodes
495 * with their respective weights. */
496static void ntree_shader_weight_tree_invert(bNodeTree *ntree, bNode *output_node)
497{
498 bNodeLink *displace_link = nullptr;
499 bNodeSocket *displace_output = ntree_shader_node_find_input(output_node, "Displacement");
500 if (displace_output && displace_output->link) {
501 /* Remove any displacement link to avoid tagging it later on. */
502 displace_link = displace_output->link;
503 displace_output->link = nullptr;
504 }
505 bNodeLink *thickness_link = nullptr;
506 bNodeSocket *thickness_output = ntree_shader_node_find_input(output_node, "Thickness");
507 if (thickness_output && thickness_output->link) {
508 /* Remove any thickness link to avoid tagging it later on. */
509 thickness_link = thickness_output->link;
510 thickness_output->link = nullptr;
511 }
512 /* Init tmp flag. */
513 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
514 node->runtime->tmp_flag = -1;
515 }
516 /* Tag nodes from the weight tree. Only tag output node and mix/add shader nodes. */
517 output_node->runtime->tmp_flag = 0;
518 int node_count = 1;
520 ntree, output_node, ntree_weight_tree_tag_nodes, &node_count, 0);
521 /* Make a mirror copy of the weight tree. */
522 Array<bNode *> nodes_copy(node_count);
523 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
524 if (node->runtime->tmp_flag >= 0) {
525 int id = node->runtime->tmp_flag;
526
527 switch (node->type_legacy) {
532 /* Start the tree with full weight. */
533 nodes_copy[id] = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_VALUE);
534 nodes_copy[id]->runtime->tmp_flag = -2; /* Copy */
535 ((bNodeSocketValueFloat *)ntree_shader_node_output_get(nodes_copy[id], 0)->default_value)
536 ->value = 1.0f;
537 break;
538 }
539 case SH_NODE_ADD_SHADER: {
540 /* Simple passthrough node. Each original inputs will get the same weight. */
541 /* TODO(fclem): Better use some kind of reroute node? */
542 nodes_copy[id] = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
543 nodes_copy[id]->custom1 = NODE_MATH_ADD;
544 nodes_copy[id]->runtime->tmp_flag = -2; /* Copy */
545 ((bNodeSocketValueFloat *)ntree_shader_node_input_get(nodes_copy[id], 0)->default_value)
546 ->value = 0.0f;
547 break;
548 }
549 case SH_NODE_MIX_SHADER: {
550 /* We need multiple nodes to emulate the mix node in reverse. */
551 bNode *fromnode, *tonode;
552 bNodeSocket *fromsock, *tosock;
553 int id_start = id;
554 /* output = (factor * input_weight) */
555 nodes_copy[id] = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
556 nodes_copy[id]->custom1 = NODE_MATH_MULTIPLY;
557 nodes_copy[id]->runtime->tmp_flag = -2; /* Copy */
558 id++;
559 /* output = ((1.0 - factor) * input_weight) <=> (input_weight - factor * input_weight) */
560 nodes_copy[id] = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
561 nodes_copy[id]->custom1 = NODE_MATH_SUBTRACT;
562 nodes_copy[id]->runtime->tmp_flag = -2; /* Copy */
563 id++;
564 /* Node sanitizes the input mix factor by clamping it. */
565 nodes_copy[id] = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
566 nodes_copy[id]->custom1 = NODE_MATH_ADD;
567 nodes_copy[id]->custom2 = SHD_MATH_CLAMP;
568 nodes_copy[id]->runtime->tmp_flag = -2; /* Copy */
569 ((bNodeSocketValueFloat *)ntree_shader_node_input_get(nodes_copy[id], 0)->default_value)
570 ->value = 0.0f;
571 /* Copy default value if no link present. */
572 bNodeSocket *fac_sock = ntree_shader_node_find_input(node, "Fac");
573 if (!fac_sock->link) {
574 float default_value = ((bNodeSocketValueFloat *)fac_sock->default_value)->value;
575 bNodeSocket *dst_sock = ntree_shader_node_input_get(nodes_copy[id], 1);
576 ((bNodeSocketValueFloat *)dst_sock->default_value)->value = default_value;
577 }
578 id++;
579 /* Reroute the weight input to the 3 processing nodes. Simplify linking later-on. */
580 /* TODO(fclem): Better use some kind of reroute node? */
581 nodes_copy[id] = blender::bke::node_add_static_node(nullptr, *ntree, SH_NODE_MATH);
582 nodes_copy[id]->custom1 = NODE_MATH_ADD;
583 nodes_copy[id]->runtime->tmp_flag = -2; /* Copy */
584 ((bNodeSocketValueFloat *)ntree_shader_node_input_get(nodes_copy[id], 0)->default_value)
585 ->value = 0.0f;
586 id++;
587 /* Link between nodes for the subtraction. */
588 fromnode = nodes_copy[id_start];
589 tonode = nodes_copy[id_start + 1];
590 fromsock = ntree_shader_node_output_get(fromnode, 0);
591 tosock = ntree_shader_node_input_get(tonode, 1);
592 blender::bke::node_add_link(*ntree, *fromnode, *fromsock, *tonode, *tosock);
593 /* Link mix input to first node. */
594 fromnode = nodes_copy[id_start + 2];
595 tonode = nodes_copy[id_start];
596 fromsock = ntree_shader_node_output_get(fromnode, 0);
597 tosock = ntree_shader_node_input_get(tonode, 1);
598 blender::bke::node_add_link(*ntree, *fromnode, *fromsock, *tonode, *tosock);
599 /* Link weight input to both multiply nodes. */
600 fromnode = nodes_copy[id_start + 3];
601 fromsock = ntree_shader_node_output_get(fromnode, 0);
602 tonode = nodes_copy[id_start];
603 tosock = ntree_shader_node_input_get(tonode, 0);
604 blender::bke::node_add_link(*ntree, *fromnode, *fromsock, *tonode, *tosock);
605 tonode = nodes_copy[id_start + 1];
606 tosock = ntree_shader_node_input_get(tonode, 0);
607 blender::bke::node_add_link(*ntree, *fromnode, *fromsock, *tonode, *tosock);
608 break;
609 }
610 default:
611 BLI_assert(0);
612 break;
613 }
614 }
615 }
616 /* Recreate links between copied nodes. */
617 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
618 if (node->runtime->tmp_flag >= 0) {
619 /* Naming can be confusing here. We use original node-link name for from/to prefix.
620 * The final link is in reversed order. */
621 int socket_index;
622 LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->inputs, socket_index) {
623 bNodeSocket *tosock;
624 bNode *tonode;
625
626 switch (node->type_legacy) {
631 case SH_NODE_ADD_SHADER: {
632 tonode = nodes_copy[node->runtime->tmp_flag];
633 tosock = ntree_shader_node_output_get(tonode, 0);
634 break;
635 }
636 case SH_NODE_MIX_SHADER: {
637 if (socket_index == 0) {
638 /* Mix Factor. */
639 tonode = nodes_copy[node->runtime->tmp_flag + 2];
640 tosock = ntree_shader_node_input_get(tonode, 1);
641 }
642 else if (socket_index == 1) {
643 /* Shader 1. */
644 tonode = nodes_copy[node->runtime->tmp_flag + 1];
645 tosock = ntree_shader_node_output_get(tonode, 0);
646 }
647 else {
648 /* Shader 2. */
649 tonode = nodes_copy[node->runtime->tmp_flag];
650 tosock = ntree_shader_node_output_get(tonode, 0);
651 }
652 break;
653 }
654 default:
655 BLI_assert(0);
656 break;
657 }
658
659 if (sock->link) {
660 bNodeSocket *fromsock;
661 bNode *fromnode = sock->link->fromnode;
662
663 switch (fromnode->type_legacy) {
664 case SH_NODE_ADD_SHADER: {
665 fromnode = nodes_copy[fromnode->runtime->tmp_flag];
666 fromsock = ntree_shader_node_input_get(fromnode, 1);
667 if (fromsock->link) {
668 ntree_weight_tree_merge_weight(ntree, fromnode, fromsock, &tonode, &tosock);
669 }
670 break;
671 }
672 case SH_NODE_MIX_SHADER: {
673 fromnode = nodes_copy[fromnode->runtime->tmp_flag + 3];
674 fromsock = ntree_shader_node_input_get(fromnode, 1);
675 if (fromsock->link) {
676 ntree_weight_tree_merge_weight(ntree, fromnode, fromsock, &tonode, &tosock);
677 }
678 break;
679 }
695 case SH_NODE_EMISSION:
696 case SH_NODE_HOLDOUT:
702 fromsock = ntree_shader_node_find_input(fromnode, "Weight");
703 /* Make "weight" sockets available so that links to it are available as well and are
704 * not ignored in other places. */
705 fromsock->flag &= ~SOCK_UNAVAIL;
706 if (fromsock->link) {
707 ntree_weight_tree_merge_weight(ntree, fromnode, fromsock, &tonode, &tosock);
708 }
709 break;
710 default:
711 fromsock = sock->link->fromsock;
712 break;
713 }
714
715 /* Manually add the link to the socket to avoid calling:
716 * `BKE_ntree_update(G.main, oop)`. */
718 *ntree, *fromnode, *fromsock, *tonode, *tosock);
719 BLI_assert(fromsock->link);
720 }
721 }
722 }
723 }
724 /* Restore displacement & thickness link. */
725 if (displace_link) {
727 *displace_link->fromnode,
728 *displace_link->fromsock,
729 *output_node,
730 *displace_output);
731 }
732 if (thickness_link) {
734 *thickness_link->fromnode,
735 *thickness_link->fromsock,
736 *output_node,
737 *thickness_output);
738 }
740}
741
742static bool closure_node_filter(const bNode *node)
743{
744 switch (node->type_legacy) {
762 case SH_NODE_EMISSION:
763 case SH_NODE_HOLDOUT:
769 return true;
770 default:
771 return false;
772 }
773}
774
775/* Shader to rgba needs their associated closure duplicated and the weight tree generated for. */
777{
778 Vector<bNode *> shader_to_rgba_nodes;
779 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
780 if (node->type_legacy == SH_NODE_SHADERTORGB) {
781 shader_to_rgba_nodes.append(node);
782 }
783 }
784
785 for (bNode *shader_to_rgba : shader_to_rgba_nodes) {
786 bNodeSocket *closure_input = ntree_shader_node_input_get(shader_to_rgba, 0);
787 if (closure_input->link == nullptr) {
788 continue;
789 }
790 ntree_shader_copy_branch(ntree, shader_to_rgba, closure_node_filter);
792
793 ntree_shader_weight_tree_invert(ntree, shader_to_rgba);
794 }
795}
796
798 bNode *node_start,
799 int16_t &max_depth)
800{
801 struct StackNode {
802 bNode *node;
803 int16_t depth;
804 };
805
807 blender::Stack<StackNode> zone_stack;
808 stack.push({node_start, 0});
809
810 while (!stack.is_empty() || !zone_stack.is_empty()) {
811 StackNode s_node = !stack.is_empty() ? stack.pop() : zone_stack.pop();
812
813 bNode *node = s_node.node;
814 int16_t depth_level = s_node.depth;
815
816 if (node->runtime->tmp_flag >= depth_level) {
817 /* We already iterated this branch at this or a greater depth. */
818 continue;
819 }
820
821 if (node->type_legacy == SH_NODE_SHADERTORGB) {
822 depth_level++;
823 max_depth = std::max(max_depth, depth_level);
824 }
825
826 node->runtime->tmp_flag = std::max(node->runtime->tmp_flag, depth_level);
827
828 LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
829 bNodeLink *link = sock->link;
830 if (link == nullptr) {
831 continue;
832 }
833 if ((link->flag & NODE_LINK_VALID) == 0) {
834 /* Skip links marked as cyclic. */
835 continue;
836 }
837 stack.push({link->fromnode, depth_level});
838 }
839
840 /* Zone input nodes are linked to their corresponding zone output nodes, even if there is no
841 * bNodeLink between them. */
843 node->type_legacy))
844 {
845 if (zone_type->output_type == node->type_legacy) {
846 if (bNode *zone_input_node = zone_type->get_corresponding_input(*ntree, *node)) {
847 zone_stack.push({zone_input_node, depth_level});
848 }
849 }
850 }
851 }
852}
853
854static void shader_node_disconnect_input(bNodeTree *ntree, bNode *node, int index)
855{
856 bNodeLink *link = ntree_shader_node_input_get(node, index)->link;
857 if (link) {
858 blender::bke::node_remove_link(ntree, *link);
859 }
860}
861
863 bNode *node,
864 int factor_socket_index,
865 int a_socket_index,
866 int b_socket_index,
867 bool clamp_factor)
868{
869 bNodeSocket *factor_socket = ntree_shader_node_input_get(node, factor_socket_index);
870 if (factor_socket->link == nullptr) {
871 float factor = 0.5;
872
873 if (factor_socket->type == SOCK_FLOAT) {
874 factor = factor_socket->default_value_typed<bNodeSocketValueFloat>()->value;
875 if (clamp_factor) {
876 factor = clamp_f(factor, 0.0f, 1.0f);
877 }
878 }
879 else if (factor_socket->type == SOCK_VECTOR) {
880 const float *vfactor = factor_socket->default_value_typed<bNodeSocketValueVector>()->value;
881 float vfactor_copy[3];
882 for (int i = 0; i < 3; i++) {
883 if (clamp_factor) {
884 vfactor_copy[i] = clamp_f(vfactor[i], 0.0f, 1.0f);
885 }
886 else {
887 vfactor_copy[i] = vfactor[i];
888 }
889 }
890 if (vfactor_copy[0] == vfactor_copy[1] && vfactor_copy[0] == vfactor_copy[2]) {
891 factor = vfactor_copy[0];
892 }
893 }
894
895 if (factor == 1.0f && a_socket_index >= 0) {
896 shader_node_disconnect_input(ntree, node, a_socket_index);
897 }
898 else if (factor == 0.0f && b_socket_index >= 0) {
899 shader_node_disconnect_input(ntree, node, b_socket_index);
900 }
901 }
902}
903
905{
906 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
907 if (node->typeinfo->type_legacy == SH_NODE_MIX_SHADER) {
908 shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 1, 2, true);
909 }
910 else if (node->typeinfo->type_legacy == SH_NODE_MIX) {
911 const NodeShaderMix *storage = static_cast<NodeShaderMix *>(node->storage);
912 if (storage->data_type == SOCK_FLOAT) {
913 shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 2, 3, storage->clamp_factor);
914 /* Disconnect links from data_type-specific sockets that are not currently in use */
915 for (int i : {1, 4, 5, 6, 7}) {
916 shader_node_disconnect_input(ntree, node, i);
917 }
918 }
919 else if (storage->data_type == SOCK_VECTOR) {
920 int factor_socket = storage->factor_mode == NODE_MIX_MODE_UNIFORM ? 0 : 1;
922 ntree, node, factor_socket, 4, 5, storage->clamp_factor);
923 /* Disconnect links from data_type-specific sockets that are not currently in use */
924 int unused_factor_socket = factor_socket == 0 ? 1 : 0;
925 for (int i : {unused_factor_socket, 2, 3, 6, 7}) {
926 shader_node_disconnect_input(ntree, node, i);
927 }
928 }
929 else if (storage->data_type == SOCK_RGBA) {
930 /* Branch A can't be optimized-out, since its alpha is always used regardless of factor */
931 shader_node_disconnect_inactive_mix_branch(ntree, node, 0, -1, 7, storage->clamp_factor);
932 /* Disconnect links from data_type-specific sockets that are not currently in use */
933 for (int i : {1, 2, 3, 4, 5}) {
934 shader_node_disconnect_input(ntree, node, i);
935 }
936 }
937 }
938 }
939}
940
941static bool ntree_branch_node_tag(bNode *fromnode, bNode *tonode, void * /*userdata*/)
942{
943 fromnode->runtime->tmp_flag = 1;
944 tonode->runtime->tmp_flag = 1;
945 return true;
946}
947
948/* Avoid adding more node execution when multiple outputs are present. */
949/* NOTE(@fclem): This is also a workaround for the old EEVEE SSS implementation where only the
950 * first executed SSS node gets a SSS profile. */
951static void ntree_shader_pruned_unused(bNodeTree *ntree, bNode *output_node)
952{
954
955 bool changed = false;
956
957 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
958 node->runtime->tmp_flag = 0;
959 }
960
961 /* Avoid deleting the output node if it is the only node in the tree. */
962 if (output_node) {
963 output_node->runtime->tmp_flag = 1;
965 ntree, output_node, ntree_branch_node_tag, nullptr, 0);
966 }
967
968 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
969 if (node->type_legacy == SH_NODE_OUTPUT_AOV) {
970 node->runtime->tmp_flag = 1;
972 }
973 }
974
975 LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
976 if (node->runtime->tmp_flag == 0) {
977 blender::bke::node_unlink_node(*ntree, *node);
978 blender::bke::node_free_node(ntree, *node);
979 changed = true;
980 }
981 }
982
983 if (changed) {
985 }
986}
987
989{
991
994
995 /* Tree is valid if it contains no undefined implicit socket type cast. */
996 bool valid_tree = ntree_shader_implicit_closure_cast(localtree);
997
998 if (valid_tree) {
1000 if (output != nullptr) {
1003 }
1004 }
1005
1006 exec = ntreeShaderBeginExecTree(localtree);
1007 /* Execute nodes ordered by the number of ShaderToRGB nodes found in their path,
1008 * so all closures can be properly evaluated. */
1009 int16_t max_depth = 0;
1010 LISTBASE_FOREACH (bNode *, node, &localtree->nodes) {
1011 node->runtime->tmp_flag = -1;
1012 }
1013 if (output != nullptr) {
1014 iter_shader_to_rgba_depth_count(localtree, output, max_depth);
1015 }
1016 LISTBASE_FOREACH (bNode *, node, &localtree->nodes) {
1017 if (node->type_legacy == SH_NODE_OUTPUT_AOV) {
1018 iter_shader_to_rgba_depth_count(localtree, node, max_depth);
1019 }
1020 }
1021 for (int depth = max_depth; depth >= 0; depth--) {
1022 ntreeExecGPUNodes(exec, mat, output, &depth);
1023 LISTBASE_FOREACH (bNode *, node, &localtree->nodes) {
1024 if (node->type_legacy == SH_NODE_OUTPUT_AOV) {
1025 ntreeExecGPUNodes(exec, mat, node, &depth);
1026 }
1027 }
1028 }
1030}
1031
1033 bNodeTree *ntree,
1034 bNodeInstanceKey parent_key)
1035{
1036 /* ensures only a single output node is enabled */
1038
1039 /* common base initialization */
1040 bNodeTreeExec *exec = ntree_exec_begin(context, ntree, parent_key);
1041
1042 /* allocate the thread stack listbase array */
1043 exec->threadstack = MEM_calloc_arrayN<ListBase>(BLENDER_MAX_THREADS, "thread stack array");
1044
1045 LISTBASE_FOREACH (bNode *, node, &exec->nodetree->nodes) {
1046 node->runtime->need_exec = 1;
1047 }
1048
1049 return exec;
1050}
1051
1053{
1054 bNodeExecContext context;
1056
1057 /* XXX hack: prevent exec data from being generated twice.
1058 * this should be handled by the renderer!
1059 */
1060 if (ntree->runtime->execdata) {
1061 return ntree->runtime->execdata;
1062 }
1063
1065
1066 /* XXX: this should not be necessary, but is still used for compositor/shader/texture nodes,
1067 * which only store the `ntree` pointer. Should be fixed at some point!
1068 */
1069 ntree->runtime->execdata = exec;
1070
1071 return exec;
1072}
1073
1075{
1076 if (exec->threadstack) {
1077 for (int a = 0; a < BLENDER_MAX_THREADS; a++) {
1078 LISTBASE_FOREACH (bNodeThreadStack *, nts, &exec->threadstack[a]) {
1079 if (nts->stack) {
1080 MEM_freeN(nts->stack);
1081 }
1082 }
1083 BLI_freelistN(&exec->threadstack[a]);
1084 }
1085
1086 MEM_freeN(exec->threadstack);
1087 exec->threadstack = nullptr;
1088 }
1089
1091}
1092
1094{
1095 if (exec) {
1096 /* exec may get freed, so assign ntree */
1097 bNodeTree *ntree = exec->nodetree;
1099
1100 /* XXX: clear node-tree back-pointer to exec data,
1101 * same problem as noted in #ntreeBeginExecTree. */
1102 ntree->runtime->execdata = nullptr;
1103 }
1104}
SpaceNode * CTX_wm_space_node(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
@ LIB_ID_CREATE_NO_MAIN
Blender kernel freestyle line style functionality.
FreestyleLineStyle * BKE_linestyle_active_from_view_layer(struct ViewLayer *view_layer)
Definition linestyle.cc:714
General operations, lookup, etc. for materials.
Material * BKE_object_material_get(Object *ob, short act)
#define NODE_CLASS_OUTPUT
Definition BKE_node.hh:448
#define NODE_CLASS_INTERFACE
Definition BKE_node.hh:459
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:453
#define NODE_CLASS_OP_VECTOR
Definition BKE_node.hh:450
#define NODE_CLASS_LAYOUT
Definition BKE_node.hh:463
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:449
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define NODE_CLASS_GROUP
Definition BKE_node.hh:452
#define NODE_CLASS_TEXTURE
Definition BKE_node.hh:457
#define NODE_CLASS_SHADER
Definition BKE_node.hh:460
#define NODE_CLASS_SCRIPT
Definition BKE_node.hh:458
#define SH_NODE_MIX_SHADER
#define SH_NODE_BSDF_METALLIC
#define SH_NODE_HOLDOUT
#define SH_NODE_VOLUME_COEFFICIENTS
#define SH_NODE_OUTPUT_WORLD
#define SH_NODE_BSDF_PRINCIPLED
#define SH_NODE_EMISSION
#define SH_NODE_BSDF_SHEEN
#define SH_NODE_ADD_SHADER
#define SH_NODE_SUBSURFACE_SCATTERING
#define SH_NODE_VOLUME_ABSORPTION
#define SH_NODE_VALUE
#define SH_NODE_MATH
#define SH_NODE_BSDF_TOON
#define SH_NODE_BSDF_TRANSPARENT
#define SH_NODE_BSDF_DIFFUSE
#define SH_NODE_SHADERTORGB
#define SH_NODE_OUTPUT_MATERIAL
#define SH_NODE_BSDF_TRANSLUCENT
#define SH_NODE_BSDF_HAIR_PRINCIPLED
#define SH_NODE_BSDF_HAIR
#define SH_NODE_BACKGROUND
#define SH_NODE_BSDF_RAY_PORTAL
#define SH_NODE_BSDF_GLOSSY
#define SH_NODE_MIX
#define SH_NODE_EEVEE_SPECULAR
#define SH_NODE_BSDF_GLASS
#define SH_NODE_VOLUME_PRINCIPLED
#define SH_NODE_BSDF_REFRACTION
#define SH_NODE_OUTPUT_LIGHT
#define SH_NODE_VOLUME_SCATTER
#define SH_NODE_OUTPUT_AOV
#define SH_NODE_SCRIPT
void BKE_ntree_update_without_main(bNodeTree &tree)
bool BKE_scene_use_shading_nodes_custom(Scene *scene)
Definition scene.cc:2812
#define BLI_assert(a)
Definition BLI_assert.h:46
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:534
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:497
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
MINLINE float clamp_f(float value, float min, float max)
#define BLENDER_MAX_THREADS
Definition BLI_threads.h:16
#define ELEM(...)
#define STREQ(a, b)
@ SHD_MATH_CLAMP
@ NODE_MATH_ADD
@ NODE_MATH_MULTIPLY
@ NODE_MATH_SUBTRACT
@ SHD_OUTPUT_ALL
@ SHD_OUTPUT_EEVEE
@ NODE_DO_OUTPUT
@ NTREE_SHADER
@ NODE_LINK_VALID
@ NODE_MIX_MODE_UNIFORM
@ SOCK_UNAVAIL
eNodeSocketDatatype
@ SOCK_INT
@ SOCK_VECTOR
@ SOCK_CLOSURE
@ SOCK_BOOLEAN
@ SOCK_SHADER
@ SOCK_FLOAT
@ SOCK_BUNDLE
@ SOCK_RGBA
@ SOCK_MENU
@ OB_LAMP
@ SNODE_SHADER_LINESTYLE
@ SNODE_SHADER_OBJECT
struct blender::bke::bNodeTreeType * ntreeType_Shader
#define C
Definition RandGen.cpp:29
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
bool is_empty() const
Definition BLI_stack.hh:308
void push(const T &value)
Definition BLI_stack.hh:213
void append(const T &value)
#define output
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
void node_chain_iterator_backwards(const bNodeTree *ntree, bNode *node_start, bool(*callback)(bNode *, bNode *, void *), void *userdata, int recursion_lvl)
Definition node.cc:3421
void node_tree_free_local_node(bNodeTree &ntree, bNode &node)
Definition node.cc:4372
void node_tree_set_output(bNodeTree &ntree)
Definition node.cc:4469
const bNodeZoneType * zone_type_by_node_type(const int node_type)
void node_unlink_node(bNodeTree &ntree, bNode &node)
Definition node.cc:4255
void node_tree_free_tree(bNodeTree &ntree)
Definition node.cc:4455
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
Definition node.cc:3847
void node_tree_type_add(bNodeTreeType &nt)
Definition node.cc:2340
void node_internal_relink(bNodeTree &ntree, bNode &node)
Definition node.cc:3908
const bNodeInstanceKey NODE_INSTANCE_KEY_BASE
Definition node.cc:4846
void node_free_node(bNodeTree *tree, bNode &node)
Definition node.cc:4302
void(*)(void *calldata, int nclass, StringRefNull name) bNodeClassCallback
Definition BKE_node.hh:492
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:3500
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:3810
bNode * node_copy_with_mapping(bNodeTree *dst_tree, const bNode &node_src, int flag, std::optional< StringRefNull > dst_unique_name, std::optional< int > dst_unique_identifier, Map< const bNodeSocket *, bNodeSocket * > &new_socket_map, bool allow_duplicate_names=false)
Definition node.cc:3553
bool node_is_static_socket_type(const bNodeSocketType &stype)
Definition node.cc:2826
void ntree_update_reroute_nodes(bNodeTree *ntree)
static void localize(bNodeTree *localtree, bNodeTree *ntree)
static void update(bNodeTree *ntree)
static void foreach_nodeclass(void *calldata, blender::bke::bNodeClassCallback func)
bNodeTreeExec * ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key)
Definition node_exec.cc:183
void ntree_exec_end(bNodeTreeExec *exec)
Definition node_exec.cc:277
static bNodeSocket * ntree_shader_node_input_get(bNode *node, int n)
static bool ntree_shader_implicit_closure_cast(bNodeTree *ntree)
static bool ntree_branch_count_and_tag_nodes(bNode *fromnode, bNode *tonode, void *userdata)
bNodeTreeExec * ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key)
static bool ntree_weight_tree_tag_nodes(bNode *fromnode, bNode *tonode, void *userdata)
static bNodeSocket * ntree_shader_node_find_output(bNode *node, const char *identifier)
static void ntree_weight_tree_merge_weight(bNodeTree *ntree, bNode *, bNodeSocket *fromsock, bNode **tonode, bNodeSocket **tosock)
static void ntree_shader_disconnect_inactive_mix_branches(bNodeTree *ntree)
static void ntree_shader_shader_to_rgba_branches(bNodeTree *ntree)
static bNodeSocket * ntree_shader_node_find_input(bNode *node, const char *identifier)
static void shader_node_disconnect_inactive_mix_branch(bNodeTree *ntree, bNode *node, int factor_socket_index, int a_socket_index, int b_socket_index, bool clamp_factor)
static bool closure_node_filter(const bNode *node)
static void ntree_shader_weight_tree_invert(bNodeTree *ntree, bNode *output_node)
static bool shader_node_tree_socket_type_valid(blender::bke::bNodeTreeType *, blender::bke::bNodeSocketType *socket_type)
static void iter_shader_to_rgba_depth_count(bNodeTree *ntree, bNode *node_start, int16_t &max_depth)
void register_node_tree_type_sh()
static void update(bNodeTree *ntree)
static void ntree_shader_unlink_script_nodes(bNodeTree *ntree)
bNode * ntreeShaderOutputNode(bNodeTree *ntree, int target)
static bNodeSocket * ntree_shader_node_find_socket(ListBase *sockets, const char *identifier)
static void shader_get_from_context(const bContext *C, blender::bke::bNodeTreeType *, bNodeTree **r_ntree, ID **r_id, ID **r_from)
static bool shader_validate_link(eNodeSocketDatatype from, eNodeSocketDatatype to)
static void ntree_shader_pruned_unused(bNodeTree *ntree, bNode *output_node)
static bool ntree_branch_node_tag(bNode *fromnode, bNode *tonode, void *)
static void ntree_shader_copy_branch(bNodeTree *ntree, bNode *start_node, bool(*node_filter)(const bNode *node))
bNodeTreeExec * ntreeShaderBeginExecTree(bNodeTree *ntree)
static bool shader_tree_poll(const bContext *C, blender::bke::bNodeTreeType *)
void ntreeShaderEndExecTree(bNodeTreeExec *exec)
static void shader_node_disconnect_input(bNodeTree *ntree, bNode *node, int index)
static bNodeSocket * ntree_shader_node_output_get(bNode *node, int n)
static void localize(bNodeTree *localtree, bNodeTree *)
void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec)
static void foreach_nodeclass(void *calldata, blender::bke::bNodeClassCallback func)
void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node, const int *depth_level)
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
const char * RE_engine_id_CYCLES
Definition scene.cc:1583
StructRNA * srna
struct bNodeTree * nodetree
Definition DNA_ID.h:414
struct bNodeTree * nodetree
char engine[32]
struct RenderData r
struct World * world
struct bNodeTree * nodetree
struct bNodeLink * link
void * default_value
bNodeTreeRuntimeHandle * runtime
ListBase nodes
ListBase links
int16_t custom1
ListBase inputs
int16_t type_legacy
bNodeRuntimeHandle * runtime
ListBase outputs
int32_t identifier
Defines a socket type.
Definition BKE_node.hh:158
eNodeSocketDatatype type
Definition BKE_node.hh:193
void(* update)(bNodeTree *ntree)
Definition BKE_node.hh:522
void(* foreach_nodeclass)(void *calldata, bNodeClassCallback func)
Definition BKE_node.hh:507
bool(* poll)(const bContext *C, bNodeTreeType *ntreetype)
Definition BKE_node.hh:509
void(* get_from_context)(const bContext *C, bNodeTreeType *ntreetype, bNodeTree **r_ntree, ID **r_id, ID **r_from)
Definition BKE_node.hh:511
void(* localize)(bNodeTree *localtree, bNodeTree *ntree)
Definition BKE_node.hh:518
bool(* validate_link)(eNodeSocketDatatype from, eNodeSocketDatatype to)
Definition BKE_node.hh:524
bool(* valid_socket_type)(bNodeTreeType *ntreetype, bNodeSocketType *socket_type)
Definition BKE_node.hh:529
bool(* node_filter)(const bNode *node)
void * ntreeGPUMaterialNodes
Definition stubs.c:42
i
Definition text_draw.cc:230
#define N_(msgid)