2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2005 Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): Bob Holcomb.
25 * ***** END GPL LICENSE BLOCK *****
28 #ifndef __BKE_NODE_H__
29 #define __BKE_NODE_H__
35 #include "DNA_listBase.h"
37 #include "RNA_types.h"
39 /* not very important, but the stack solver likes to know a maximum */
53 struct ImageFormatData;
68 /* ************** NODE TYPE DEFINITIONS ***** */
70 /** Compact definition of a node socket.
71 * Can be used to quickly define a list of static sockets for a node,
72 * which are added to each new node of that type.
74 * \deprecated New nodes should add default sockets in the initialization
75 * function instead. This struct is mostly kept for old nodes and should
76 * be removed some time.
78 typedef struct bNodeSocketTemplate {
80 char name[64]; /* MAX_NAME */
81 float val1, val2, val3, val4; /* default alloc value for inputs */
83 PropertySubType subtype;
86 /* after this line is used internal only */
87 struct bNodeSocket *sock; /* used to hold verified socket */
88 } bNodeSocketTemplate;
90 typedef void (*NodeSocketButtonFunction)(const struct bContext *C, struct uiBlock *block,
91 struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock,
92 const char *name, int x, int y, int width);
94 /** Defines a socket type.
95 * Defines the appearance and behavior of a socket in the UI.
97 typedef struct bNodeSocketType {
99 char ui_name[64]; /* MAX_NAME */
100 char ui_description[128];
104 const char *value_structname;
105 int value_structsize;
107 NodeSocketButtonFunction buttonfunc;
110 /** Template for creating a node.
111 * Stored required parameters to make a new node of a specific type.
113 typedef struct bNodeTemplate {
118 struct bNodeTree *ngroup; /* group tree */
121 /** Defines a node type.
122 * Initial attributes and constants for a node as well as callback functions
123 * implementing the node behavior.
125 typedef struct bNodeType {
127 short needs_free; /* set for allocated types that need to be freed */
130 char name[64]; /* MAX_NAME */
131 float width, minwidth, maxwidth;
132 float height, minheight, maxheight;
133 short nclass, flag, compatibility;
135 /* templates for static sockets */
136 bNodeSocketTemplate *inputs, *outputs;
138 char storagename[64]; /* struct name for DNA */
140 /// Main draw function for the node.
141 void (*drawfunc)(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode, struct bNodeTree *ntree, struct bNode *node);
142 /// Updates the node geometry attributes according to internal state before actual drawing.
143 void (*drawupdatefunc)(const struct bContext *C, struct bNodeTree *ntree, struct bNode *node);
144 /// Draw the option buttons on the node.
145 void (*uifunc)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
146 /// Additional parameters in the side panel.
147 void (*uifuncbut)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
148 /// Additional drawing on backdrop.
149 void (*uibackdropfunc)(struct SpaceNode* snode, struct ImBuf* backdrop, struct bNode* node, int x, int y);
151 /// Draw a node socket. Default draws the input value button.
152 NodeSocketButtonFunction drawinputfunc;
153 NodeSocketButtonFunction drawoutputfunc;
155 /// Optional custom label function for the node header.
156 const char *(*labelfunc)(struct bNode *);
157 /// Optional custom resize handle polling.
158 int (*resize_area_func)(struct bNode *node, int x, int y);
159 /// Optional selection area polling.
160 int (*select_area_func)(struct bNode *node, int x, int y);
161 /// Optional tweak area polling (for grabbing).
162 int (*tweak_area_func)(struct bNode *node, int x, int y);
164 /// Called when the node is updated in the editor.
165 void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node);
166 /// Check and update if internal ID data has changed.
167 void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
169 /// Initialize a new node instance of this type after creation.
170 void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
171 /// Free the custom storage data.
172 void (*freestoragefunc)(struct bNode *node);
173 /// Make a copy of the custom storage data.
174 void (*copystoragefunc)(struct bNode *node, struct bNode *target);
176 /// Create a template from an existing node.
177 struct bNodeTemplate (*templatefunc)(struct bNode *);
178 /** If a node can be made from the template in the given node tree.
179 * \note Node groups can not be created inside their own node tree.
181 int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
183 /// Initialize a node tree associated to this node type.
184 void (*inittreefunc)(struct bNodeTree *ntree);
185 /// Update a node tree associated to this node type.
186 void (*updatetreefunc)(struct bNodeTree *ntree);
188 /* group edit callbacks for operators */
189 /* XXX this is going to be changed as required by the UI */
190 struct bNodeTree *(*group_edit_get)(struct bNode *node);
191 struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit);
192 void (*group_edit_clear)(struct bNode *node);
194 /* Generate a temporary list of internal links (bNodeLink), for muting and disconnect operators.
195 * Result must be freed by caller!
197 ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node);
199 /* **** execution callbacks **** */
200 void *(*initexecfunc)(struct bNode *node);
201 void (*freeexecfunc)(struct bNode *node, void *nodedata);
202 void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **);
203 /* XXX this alternative exec function has been added to avoid changing all node types.
204 * when a final generic version of execution code is defined, this will be changed anyway
206 void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **);
208 int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
209 /* extended gpu function */
210 int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out);
213 /* node->exec, now in use for composites (#define for break is same as ready yes) */
214 #define NODE_PROCESSING 1
217 #define NODE_FINISHED 4
218 #define NODE_FREEBUFS 8
219 #define NODE_SKIPPED 16
221 /* sim_exec return value */
222 #define NODE_EXEC_FINISHED 0
223 #define NODE_EXEC_SUSPEND 1
225 /* nodetype->nclass, for add-menu and themes */
226 #define NODE_CLASS_INPUT 0
227 #define NODE_CLASS_OUTPUT 1
228 #define NODE_CLASS_OP_COLOR 3
229 #define NODE_CLASS_OP_VECTOR 4
230 #define NODE_CLASS_OP_FILTER 5
231 #define NODE_CLASS_GROUP 6
232 #define NODE_CLASS_FILE 7
233 #define NODE_CLASS_CONVERTOR 8
234 #define NODE_CLASS_MATTE 9
235 #define NODE_CLASS_DISTORT 10
236 #define NODE_CLASS_OP_DYNAMIC 11 /* deprecated */
237 #define NODE_CLASS_PATTERN 12
238 #define NODE_CLASS_TEXTURE 13
239 #define NODE_CLASS_EXECUTION 14
240 #define NODE_CLASS_GETDATA 15
241 #define NODE_CLASS_SETDATA 16
242 #define NODE_CLASS_MATH 17
243 #define NODE_CLASS_MATH_VECTOR 18
244 #define NODE_CLASS_MATH_ROTATION 19
245 #define NODE_CLASS_PARTICLES 25
246 #define NODE_CLASS_TRANSFORM 30
247 #define NODE_CLASS_COMBINE 31
248 #define NODE_CLASS_SHADER 40
249 #define NODE_CLASS_LAYOUT 100
251 /* nodetype->compatibility */
252 #define NODE_OLD_SHADING 1
253 #define NODE_NEW_SHADING 2
255 /* node resize directions */
256 #define NODE_RESIZE_TOP 1
257 #define NODE_RESIZE_BOTTOM 2
258 #define NODE_RESIZE_RIGHT 4
259 #define NODE_RESIZE_LEFT 8
261 /* enum values for input/output */
265 struct bNodeTreeExec;
267 typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
268 typedef void (*bNodeClassCallback)(void *calldata, int nclass, const char *name);
269 typedef struct bNodeTreeType {
270 int type; /* type identifier */
271 char idname[64]; /* id name for RNA identification */
273 ListBase node_types; /* type definitions */
276 void (*free_cache)(struct bNodeTree *ntree);
277 void (*free_node_cache)(struct bNodeTree *ntree, struct bNode *node);
278 void (*foreach_nodetree)(struct Main *main, void *calldata, bNodeTreeCallback func); /* iteration over all node trees */
279 void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func); /* iteration over all node classes */
281 /* calls allowing threaded composite */
282 void (*localize)(struct bNodeTree *localtree, struct bNodeTree *ntree);
283 void (*local_sync)(struct bNodeTree *localtree, struct bNodeTree *ntree);
284 void (*local_merge)(struct bNodeTree *localtree, struct bNodeTree *ntree);
286 /* Tree update. Overrides nodetype->updatetreefunc! */
287 void (*update)(struct bNodeTree *ntree);
288 /* Node update. Overrides nodetype->updatefunc! */
289 void (*update_node)(struct bNodeTree *ntree, struct bNode *node);
291 int (*validate_link)(struct bNodeTree *ntree, struct bNodeLink *link);
293 /* Default internal linking. */
294 ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node);
297 /* ************** GENERIC API, TREES *************** */
299 struct bNodeTreeType *ntreeGetType(int type);
300 struct bNodeType *ntreeGetNodeType(struct bNodeTree *ntree);
301 struct bNodeSocketType *ntreeGetSocketType(int type);
303 struct bNodeTree *ntreeAddTree(const char *name, int type, int nodetype);
304 void ntreeInitTypes(struct bNodeTree *ntree);
306 void ntreeFreeTree(struct bNodeTree *ntree);
307 struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree);
308 void ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
309 void ntreeMakeLocal(struct bNodeTree *ntree);
310 int ntreeHasType(struct bNodeTree *ntree, int type);
312 void ntreeUpdateTree(struct bNodeTree *ntree);
313 /* XXX Currently each tree update call does call to ntreeVerifyNodes too.
314 * Some day this should be replaced by a decent depsgraph automatism!
316 void ntreeVerifyNodes(struct Main *main, struct ID *id);
318 void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
320 /* XXX old trees handle output flags automatically based on special output node types and last active selection.
321 * new tree types have a per-output socket flag to indicate the final output to use explicitly.
323 void ntreeSetOutput(struct bNodeTree *ntree);
324 void ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
325 void ntreeClearPreview(struct bNodeTree *ntree);
327 void ntreeFreeCache(struct bNodeTree *ntree);
329 int ntreeNodeExists(struct bNodeTree *ntree, struct bNode *testnode);
330 int ntreeOutputExists(struct bNode *node, struct bNodeSocket *testsock);
331 struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree);
332 void ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree);
333 void ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree);
335 /* ************** GENERIC API, NODES *************** */
337 struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, struct bNode *node, int in_out, const char *name, int type);
338 struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode *node, int in_out, struct bNodeSocket *next_sock, const char *name, int type);
339 void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock);
340 void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node);
342 void nodeAddToPreview(struct bNode *node, float col[4], int x, int y, int do_manage);
344 struct bNode *nodeAddNode(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
345 void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
346 void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
348 void nodeRegisterType(struct bNodeTreeType *ttype, struct bNodeType *ntype);
349 void nodeMakeDynamicType(struct bNode *node);
350 int nodeDynamicUnlinkText(struct ID *txtid);
352 void nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
353 struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node);
355 struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
356 void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
357 void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
358 void nodeInternalRelink(struct bNodeTree *ntree, struct bNode *node);
360 void nodeToView(struct bNode *node, float x, float y, float *rx, float *ry);
361 void nodeFromView(struct bNode *node, float x, float y, float *rx, float *ry);
362 int nodeAttachNodeCheck(struct bNode *node, struct bNode *parent);
363 void nodeAttachNode(struct bNode *node, struct bNode *parent);
364 void nodeDetachNode(struct bNode *node);
366 struct bNode *nodeFindNodebyName(struct bNodeTree *ntree, const char *name);
367 int nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **nodep, int *sockindex, int *in_out);
369 struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
370 int nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
372 void nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
373 struct bNode *nodeGetActive(struct bNodeTree *ntree);
374 struct bNode *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
375 int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
376 void nodeClearActive(struct bNodeTree *ntree);
377 void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
378 struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree);
380 void nodeUpdate(struct bNodeTree *ntree, struct bNode *node);
381 int nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
383 void nodeFreePreview(struct bNode *node);
385 int nodeSocketIsHidden(struct bNodeSocket *sock);
386 void nodeSocketSetType(struct bNodeSocket *sock, int type);
389 void BKE_node_clipboard_init(struct bNodeTree *ntree);
390 void BKE_node_clipboard_clear(void);
391 void BKE_node_clipboard_add_node(struct bNode *node);
392 void BKE_node_clipboard_add_link(struct bNodeLink *link);
393 const struct ListBase *BKE_node_clipboard_get_nodes(void);
394 const struct ListBase *BKE_node_clipboard_get_links(void);
395 int BKE_node_clipboard_get_type(void);
397 /* ************** NODE TYPE ACCESS *************** */
399 struct bNodeTemplate nodeMakeTemplate(struct bNode *node);
400 int nodeValid(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
401 const char *nodeLabel(struct bNode *node);
402 struct bNodeTree *nodeGroupEditGet(struct bNode *node);
403 struct bNodeTree *nodeGroupEditSet(struct bNode *node, int edit);
404 void nodeGroupEditClear(struct bNode *node);
406 /* Init a new node type struct with default values and callbacks */
407 void node_type_base(struct bNodeTreeType *ttype, struct bNodeType *ntype, int type,
408 const char *name, short nclass, short flag);
409 void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs);
410 void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth);
411 void node_type_init(struct bNodeType *ntype, void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp));
412 void node_type_valid(struct bNodeType *ntype, int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp));
413 void node_type_storage(struct bNodeType *ntype,
414 const char *storagename,
415 void (*freestoragefunc)(struct bNode *),
416 void (*copystoragefunc)(struct bNode *, struct bNode *));
417 void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *));
418 void node_type_template(struct bNodeType *ntype, struct bNodeTemplate (*templatefunc)(struct bNode *));
419 void node_type_update(struct bNodeType *ntype,
420 void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
421 void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id));
422 void node_type_tree(struct bNodeType *ntype,
423 void (*inittreefunc)(struct bNodeTree *),
424 void (*updatetreefunc)(struct bNodeTree *));
425 void node_type_group_edit(struct bNodeType *ntype,
426 struct bNodeTree *(*group_edit_get)(struct bNode *node),
427 struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit),
428 void (*group_edit_clear)(struct bNode *node));
430 void node_type_exec(struct bNodeType *ntype, void (*execfunc)(void *data, struct bNode *, struct bNodeStack **,
431 struct bNodeStack **));
432 void node_type_exec_new(struct bNodeType *ntype,
433 void *(*initexecfunc)(struct bNode *node),
434 void (*freeexecfunc)(struct bNode *node, void *nodedata),
435 void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata,
436 struct bNodeStack **, struct bNodeStack **));
437 void node_type_internal_connect(struct bNodeType *ntype, ListBase (*internal_connect)(struct bNodeTree *, struct bNode *));
438 void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node,
439 struct GPUNodeStack *in, struct GPUNodeStack *out));
440 void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node,
441 void *nodedata, struct GPUNodeStack *in,
442 struct GPUNodeStack *out));
443 void node_type_compatibility(struct bNodeType *ntype, short compatibility);
445 /* ************** COMMON NODES *************** */
448 #define NODE_FORLOOP 3
449 #define NODE_WHILELOOP 4
451 #define NODE_REROUTE 6
453 /* look up a socket on a group node by the internal group socket */
454 struct bNodeSocket *node_group_find_input(struct bNode *gnode, struct bNodeSocket *gsock);
455 struct bNodeSocket *node_group_find_output(struct bNode *gnode, struct bNodeSocket *gsock);
457 struct bNodeSocket *node_group_add_socket(struct bNodeTree *ngroup, const char *name, int type, int in_out);
458 struct bNodeSocket *node_group_expose_socket(struct bNodeTree *ngroup, struct bNodeSocket *sock, int in_out);
459 void node_group_expose_all_sockets(struct bNodeTree *ngroup);
460 void node_group_remove_socket(struct bNodeTree *ngroup, struct bNodeSocket *gsock, int in_out);
461 struct bNodeSocket *node_group_add_extern_socket(struct bNodeTree *ntree, ListBase *lb, int in_out, struct bNodeSocket *gsock);
463 /* in node_common.c */
464 void register_node_type_frame(struct bNodeTreeType *ttype);
465 void register_node_type_reroute(struct bNodeTreeType *ttype);
467 /* ************** SHADER NODES *************** */
472 /* note: types are needed to restore callbacks, don't change values */
473 /* range 1 - 100 is reserved for common nodes */
474 /* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
476 #define SH_NODE_OUTPUT 1
478 #define SH_NODE_MATERIAL 100
479 #define SH_NODE_RGB 101
480 #define SH_NODE_VALUE 102
481 #define SH_NODE_MIX_RGB 103
482 #define SH_NODE_VALTORGB 104
483 #define SH_NODE_RGBTOBW 105
484 #define SH_NODE_TEXTURE 106
485 #define SH_NODE_NORMAL 107
486 #define SH_NODE_GEOMETRY 108
487 #define SH_NODE_MAPPING 109
488 #define SH_NODE_CURVE_VEC 110
489 #define SH_NODE_CURVE_RGB 111
490 #define SH_NODE_CAMERA 114
491 #define SH_NODE_MATH 115
492 #define SH_NODE_VECT_MATH 116
493 #define SH_NODE_SQUEEZE 117
494 #define SH_NODE_MATERIAL_EXT 118
495 #define SH_NODE_INVERT 119
496 #define SH_NODE_SEPRGB 120
497 #define SH_NODE_COMBRGB 121
498 #define SH_NODE_HUE_SAT 122
499 #define NODE_DYNAMIC 123
501 #define SH_NODE_OUTPUT_MATERIAL 124
502 #define SH_NODE_OUTPUT_WORLD 125
503 #define SH_NODE_OUTPUT_LAMP 126
504 #define SH_NODE_FRESNEL 127
505 #define SH_NODE_MIX_SHADER 128
506 #define SH_NODE_ATTRIBUTE 129
507 #define SH_NODE_BACKGROUND 130
508 #define SH_NODE_BSDF_ANISOTROPIC 131
509 #define SH_NODE_BSDF_DIFFUSE 132
510 #define SH_NODE_BSDF_GLOSSY 133
511 #define SH_NODE_BSDF_GLASS 134
512 #define SH_NODE_BSDF_TRANSLUCENT 137
513 #define SH_NODE_BSDF_TRANSPARENT 138
514 #define SH_NODE_BSDF_VELVET 139
515 #define SH_NODE_EMISSION 140
516 #define SH_NODE_NEW_GEOMETRY 141
517 #define SH_NODE_LIGHT_PATH 142
518 #define SH_NODE_TEX_IMAGE 143
519 #define SH_NODE_TEX_SKY 145
520 #define SH_NODE_TEX_GRADIENT 146
521 #define SH_NODE_TEX_VORONOI 147
522 #define SH_NODE_TEX_MAGIC 148
523 #define SH_NODE_TEX_WAVE 149
524 #define SH_NODE_TEX_NOISE 150
525 #define SH_NODE_TEX_MUSGRAVE 152
526 #define SH_NODE_TEX_COORD 155
527 #define SH_NODE_ADD_SHADER 156
528 #define SH_NODE_TEX_ENVIRONMENT 157
529 #define SH_NODE_OUTPUT_TEXTURE 158
530 #define SH_NODE_HOLDOUT 159
531 #define SH_NODE_LAYER_WEIGHT 160
532 #define SH_NODE_VOLUME_TRANSPARENT 161
533 #define SH_NODE_VOLUME_ISOTROPIC 162
534 #define SH_NODE_GAMMA 163
535 #define SH_NODE_TEX_CHECKER 164
536 #define SH_NODE_BRIGHTCONTRAST 165
537 #define SH_NODE_LIGHT_FALLOFF 166
538 #define SH_NODE_OBJECT_INFO 167
539 #define SH_NODE_PARTICLE_INFO 168
541 /* custom defines options for Material node */
542 #define SH_NODE_MAT_DIFF 1
543 #define SH_NODE_MAT_SPEC 2
544 #define SH_NODE_MAT_NEG 4
545 /* custom defines: states for Script node. These are bit indices */
546 #define NODE_DYNAMIC_READY 0 /* 1 */
547 #define NODE_DYNAMIC_LOADED 1 /* 2 */
548 #define NODE_DYNAMIC_NEW 2 /* 4 */
549 #define NODE_DYNAMIC_UPDATED 3 /* 8 */
550 #define NODE_DYNAMIC_ADDEXIST 4 /* 16 */
551 #define NODE_DYNAMIC_ERROR 5 /* 32 */
552 #define NODE_DYNAMIC_REPARSE 6 /* 64 */
553 #define NODE_DYNAMIC_SET 15 /* sign */
557 struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
558 void ntreeShaderEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
559 void ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
560 void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
561 void nodeShaderSynchronizeID(struct bNode *node, int copyto);
563 /* switch material render loop */
564 extern void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
565 void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
567 void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
570 /* ************** COMPOSITE NODES *************** */
572 /* output socket defines */
573 #define RRES_OUT_IMAGE 0
574 #define RRES_OUT_ALPHA 1
576 #define RRES_OUT_NORMAL 3
577 #define RRES_OUT_UV 4
578 #define RRES_OUT_VEC 5
579 #define RRES_OUT_RGBA 6
580 #define RRES_OUT_DIFF 7
581 #define RRES_OUT_SPEC 8
582 #define RRES_OUT_SHADOW 9
583 #define RRES_OUT_AO 10
584 #define RRES_OUT_REFLECT 11
585 #define RRES_OUT_REFRACT 12
586 #define RRES_OUT_INDIRECT 13
587 #define RRES_OUT_INDEXOB 14
588 #define RRES_OUT_INDEXMA 15
589 #define RRES_OUT_MIST 16
590 #define RRES_OUT_EMIT 17
591 #define RRES_OUT_ENV 18
592 #define RRES_OUT_DIFF_DIRECT 19
593 #define RRES_OUT_DIFF_INDIRECT 20
594 #define RRES_OUT_DIFF_COLOR 21
595 #define RRES_OUT_GLOSSY_DIRECT 22
596 #define RRES_OUT_GLOSSY_INDIRECT 23
597 #define RRES_OUT_GLOSSY_COLOR 24
598 #define RRES_OUT_TRANSM_DIRECT 25
599 #define RRES_OUT_TRANSM_INDIRECT 26
600 #define RRES_OUT_TRANSM_COLOR 27
602 /* note: types are needed to restore callbacks, don't change values */
603 #define CMP_NODE_VIEWER 201
604 #define CMP_NODE_RGB 202
605 #define CMP_NODE_VALUE 203
606 #define CMP_NODE_MIX_RGB 204
607 #define CMP_NODE_VALTORGB 205
608 #define CMP_NODE_RGBTOBW 206
609 #define CMP_NODE_NORMAL 207
610 #define CMP_NODE_CURVE_VEC 208
611 #define CMP_NODE_CURVE_RGB 209
612 #define CMP_NODE_ALPHAOVER 210
613 #define CMP_NODE_BLUR 211
614 #define CMP_NODE_FILTER 212
615 #define CMP_NODE_MAP_VALUE 213
616 #define CMP_NODE_TIME 214
617 #define CMP_NODE_VECBLUR 215
618 #define CMP_NODE_SEPRGBA 216
619 #define CMP_NODE_SEPHSVA 217
620 #define CMP_NODE_SETALPHA 218
621 #define CMP_NODE_HUE_SAT 219
622 #define CMP_NODE_IMAGE 220
623 #define CMP_NODE_R_LAYERS 221
624 #define CMP_NODE_COMPOSITE 222
625 #define CMP_NODE_OUTPUT_FILE 223
626 #define CMP_NODE_TEXTURE 224
627 #define CMP_NODE_TRANSLATE 225
628 #define CMP_NODE_ZCOMBINE 226
629 #define CMP_NODE_COMBRGBA 227
630 #define CMP_NODE_DILATEERODE 228
631 #define CMP_NODE_ROTATE 229
632 #define CMP_NODE_SCALE 230
633 #define CMP_NODE_SEPYCCA 231
634 #define CMP_NODE_COMBYCCA 232
635 #define CMP_NODE_SEPYUVA 233
636 #define CMP_NODE_COMBYUVA 234
637 #define CMP_NODE_DIFF_MATTE 235
638 #define CMP_NODE_COLOR_SPILL 236
639 #define CMP_NODE_CHROMA_MATTE 237
640 #define CMP_NODE_CHANNEL_MATTE 238
641 #define CMP_NODE_FLIP 239
642 #define CMP_NODE_SPLITVIEWER 240
643 #define CMP_NODE_INDEX_MASK 241
644 #define CMP_NODE_MAP_UV 242
645 #define CMP_NODE_ID_MASK 243
646 #define CMP_NODE_DEFOCUS 244
647 #define CMP_NODE_DISPLACE 245
648 #define CMP_NODE_COMBHSVA 246
649 #define CMP_NODE_MATH 247
650 #define CMP_NODE_LUMA_MATTE 248
651 #define CMP_NODE_BRIGHTCONTRAST 249
652 #define CMP_NODE_GAMMA 250
653 #define CMP_NODE_INVERT 251
654 #define CMP_NODE_NORMALIZE 252
655 #define CMP_NODE_CROP 253
656 #define CMP_NODE_DBLUR 254
657 #define CMP_NODE_BILATERALBLUR 255
658 #define CMP_NODE_PREMULKEY 256
659 #define CMP_NODE_DIST_MATTE 257
660 #define CMP_NODE_VIEW_LEVELS 258
661 #define CMP_NODE_COLOR_MATTE 259
662 #define CMP_NODE_COLORBALANCE 260
663 #define CMP_NODE_HUECORRECT 261
664 #define CMP_NODE_MOVIECLIP 262
665 #define CMP_NODE_STABILIZE2D 263
666 #define CMP_NODE_TRANSFORM 264
667 #define CMP_NODE_MOVIEDISTORTION 265
668 #define CMP_NODE_DOUBLEEDGEMASK 266
669 #define CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED 267 /* DEPRECATED multi file node has been merged into regular CMP_NODE_OUTPUT_FILE */
670 #define CMP_NODE_MASK 268
671 #define CMP_NODE_KEYINGSCREEN 269
672 #define CMP_NODE_KEYING 270
673 #define CMP_NODE_TRACKPOS 271
674 #define CMP_NODE_INPAINT 272
676 #define CMP_NODE_GLARE 301
677 #define CMP_NODE_TONEMAP 302
678 #define CMP_NODE_LENSDIST 303
680 #define CMP_NODE_COLORCORRECTION 312
681 #define CMP_NODE_MASK_BOX 313
682 #define CMP_NODE_MASK_ELLIPSE 314
683 #define CMP_NODE_BOKEHIMAGE 315
684 #define CMP_NODE_BOKEHBLUR 316
685 #define CMP_NODE_SWITCH 317
687 /* channel toggles */
688 #define CMP_CHAN_RGB 1
692 #define CMP_CHAN_B 16
695 #define CMP_FILT_SOFT 0
696 #define CMP_FILT_SHARP 1
697 #define CMP_FILT_LAPLACE 2
698 #define CMP_FILT_SOBEL 3
699 #define CMP_FILT_PREWITT 4
700 #define CMP_FILT_KIRSCH 5
701 #define CMP_FILT_SHADOW 6
703 /* scale node type, in custom1 */
704 #define CMP_SCALE_RELATIVE 0
705 #define CMP_SCALE_ABSOLUTE 1
706 #define CMP_SCALE_SCENEPERCENT 2
707 #define CMP_SCALE_RENDERPERCENT 3
709 #define CMP_SCALE_RENDERSIZE_FRAME_ASPECT (1 << 0)
710 #define CMP_SCALE_RENDERSIZE_FRAME_CROP (1 << 1)
715 struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
716 void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
717 void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews);
718 void ntreeCompositTagRender(struct Scene *sce);
719 int ntreeCompositTagAnimated(struct bNodeTree *ntree);
720 void ntreeCompositTagGenerators(struct bNodeTree *ntree);
721 void ntreeCompositForceHidden(struct bNodeTree *ntree, struct Scene *scene);
722 void ntreeCompositClearTags(struct bNodeTree *ntree);
724 struct bNodeSocket *ntreeCompositOutputFileAddSocket(struct bNodeTree *ntree, struct bNode *node,
725 const char *name, struct ImageFormatData *im_format);
726 int ntreeCompositOutputFileRemoveActiveSocket(struct bNodeTree *ntree, struct bNode *node);
727 void ntreeCompositOutputFileSetPath(struct bNode *node, struct bNodeSocket *sock, const char *name);
728 void ntreeCompositOutputFileSetLayer(struct bNode *node, struct bNodeSocket *sock, const char *name);
729 /* needed in do_versions */
730 void ntreeCompositOutputFileUniquePath(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
731 void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
733 /* ************** TEXTURE NODES *************** */
737 #define TEX_NODE_OUTPUT 401
738 #define TEX_NODE_CHECKER 402
739 #define TEX_NODE_TEXTURE 403
740 #define TEX_NODE_BRICKS 404
741 #define TEX_NODE_MATH 405
742 #define TEX_NODE_MIX_RGB 406
743 #define TEX_NODE_RGBTOBW 407
744 #define TEX_NODE_VALTORGB 408
745 #define TEX_NODE_IMAGE 409
746 #define TEX_NODE_CURVE_RGB 410
747 #define TEX_NODE_INVERT 411
748 #define TEX_NODE_HUE_SAT 412
749 #define TEX_NODE_CURVE_TIME 413
750 #define TEX_NODE_ROTATE 414
751 #define TEX_NODE_VIEWER 415
752 #define TEX_NODE_TRANSLATE 416
753 #define TEX_NODE_COORD 417
754 #define TEX_NODE_DISTANCE 418
755 #define TEX_NODE_COMPOSE 419
756 #define TEX_NODE_DECOMPOSE 420
757 #define TEX_NODE_VALTONOR 421
758 #define TEX_NODE_SCALE 422
759 #define TEX_NODE_AT 423
761 /* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */
762 #define TEX_NODE_PROC 500
763 #define TEX_NODE_PROC_MAX 600
766 int ntreeTexTagAnimated(struct bNodeTree *ntree);
767 void ntreeTexCheckCyclics(struct bNodeTree *ntree);
769 struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
770 void ntreeTexEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
771 int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, int osatex, short thread, struct Tex *tex, short which_output, int cfra, int preview, struct ShadeInput *shi, struct MTex *mtex);
774 /*************************************************/
776 void init_nodesystem(void);
777 void free_nodesystem(void);
779 void clear_scene_in_nodes(struct Main *bmain, struct Scene *sce);