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 *, float *, int, int, int);
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 void nodeAttachNode(struct bNode *node, struct bNode *parent);
363 void nodeDetachNode(struct bNode *node);
365 struct bNode *nodeFindNodebyName(struct bNodeTree *ntree, const char *name);
366 int nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **nodep, int *sockindex, int *in_out);
368 struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
369 int nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
371 void nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
372 struct bNode *nodeGetActive(struct bNodeTree *ntree);
373 struct bNode *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
374 int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
375 void nodeClearActive(struct bNodeTree *ntree);
376 void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
377 struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree);
379 void nodeUpdate(struct bNodeTree *ntree, struct bNode *node);
380 int nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
382 void nodeFreePreview(struct bNode *node);
384 int nodeSocketIsHidden(struct bNodeSocket *sock);
385 void nodeSocketSetType(struct bNodeSocket *sock, int type);
387 /* ************** NODE TYPE ACCESS *************** */
389 struct bNodeTemplate nodeMakeTemplate(struct bNode *node);
390 int nodeValid(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
391 const char* nodeLabel(struct bNode *node);
392 struct bNodeTree *nodeGroupEditGet(struct bNode *node);
393 struct bNodeTree *nodeGroupEditSet(struct bNode *node, int edit);
394 void nodeGroupEditClear(struct bNode *node);
396 /* Init a new node type struct with default values and callbacks */
397 void node_type_base(struct bNodeTreeType *ttype, struct bNodeType *ntype, int type,
398 const char *name, short nclass, short flag);
399 void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs);
400 void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth);
401 void node_type_init(struct bNodeType *ntype, void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp));
402 void node_type_valid(struct bNodeType *ntype, int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp));
403 void node_type_storage(struct bNodeType *ntype,
404 const char *storagename,
405 void (*freestoragefunc)(struct bNode *),
406 void (*copystoragefunc)(struct bNode *, struct bNode *));
407 void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *));
408 void node_type_template(struct bNodeType *ntype, struct bNodeTemplate (*templatefunc)(struct bNode *));
409 void node_type_update(struct bNodeType *ntype,
410 void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
411 void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id));
412 void node_type_tree(struct bNodeType *ntype,
413 void (*inittreefunc)(struct bNodeTree *),
414 void (*updatetreefunc)(struct bNodeTree *));
415 void node_type_group_edit(struct bNodeType *ntype,
416 struct bNodeTree *(*group_edit_get)(struct bNode *node),
417 struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit),
418 void (*group_edit_clear)(struct bNode *node));
420 void node_type_exec(struct bNodeType *ntype, void (*execfunc)(void *data, struct bNode *, struct bNodeStack **,
421 struct bNodeStack **));
422 void node_type_exec_new(struct bNodeType *ntype,
423 void *(*initexecfunc)(struct bNode *node),
424 void (*freeexecfunc)(struct bNode *node, void *nodedata),
425 void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata,
426 struct bNodeStack **, struct bNodeStack **));
427 void node_type_internal_connect(struct bNodeType *ntype, ListBase (*internal_connect)(struct bNodeTree *, struct bNode *));
428 void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node,
429 struct GPUNodeStack *in, struct GPUNodeStack *out));
430 void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node,
431 void *nodedata, struct GPUNodeStack *in,
432 struct GPUNodeStack *out));
433 void node_type_compatibility(struct bNodeType *ntype, short compatibility);
435 /* ************** COMMON NODES *************** */
438 #define NODE_FORLOOP 3
439 #define NODE_WHILELOOP 4
441 #define NODE_REROUTE 6
443 /* look up a socket on a group node by the internal group socket */
444 struct bNodeSocket *node_group_find_input(struct bNode *gnode, struct bNodeSocket *gsock);
445 struct bNodeSocket *node_group_find_output(struct bNode *gnode, struct bNodeSocket *gsock);
447 struct bNodeSocket *node_group_add_socket(struct bNodeTree *ngroup, const char *name, int type, int in_out);
448 struct bNodeSocket *node_group_expose_socket(struct bNodeTree *ngroup, struct bNodeSocket *sock, int in_out);
449 void node_group_expose_all_sockets(struct bNodeTree *ngroup);
450 void node_group_remove_socket(struct bNodeTree *ngroup, struct bNodeSocket *gsock, int in_out);
451 struct bNodeSocket *node_group_add_extern_socket(struct bNodeTree *ntree, ListBase *lb, int in_out, struct bNodeSocket *gsock);
453 /* in node_common.c */
454 void register_node_type_frame(struct bNodeTreeType *ttype);
455 void register_node_type_reroute(struct bNodeTreeType *ttype);
457 /* ************** SHADER NODES *************** */
462 /* note: types are needed to restore callbacks, don't change values */
463 /* range 1 - 100 is reserved for common nodes */
464 /* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
466 #define SH_NODE_OUTPUT 1
468 #define SH_NODE_MATERIAL 100
469 #define SH_NODE_RGB 101
470 #define SH_NODE_VALUE 102
471 #define SH_NODE_MIX_RGB 103
472 #define SH_NODE_VALTORGB 104
473 #define SH_NODE_RGBTOBW 105
474 #define SH_NODE_TEXTURE 106
475 #define SH_NODE_NORMAL 107
476 #define SH_NODE_GEOMETRY 108
477 #define SH_NODE_MAPPING 109
478 #define SH_NODE_CURVE_VEC 110
479 #define SH_NODE_CURVE_RGB 111
480 #define SH_NODE_CAMERA 114
481 #define SH_NODE_MATH 115
482 #define SH_NODE_VECT_MATH 116
483 #define SH_NODE_SQUEEZE 117
484 #define SH_NODE_MATERIAL_EXT 118
485 #define SH_NODE_INVERT 119
486 #define SH_NODE_SEPRGB 120
487 #define SH_NODE_COMBRGB 121
488 #define SH_NODE_HUE_SAT 122
489 #define NODE_DYNAMIC 123
491 #define SH_NODE_OUTPUT_MATERIAL 124
492 #define SH_NODE_OUTPUT_WORLD 125
493 #define SH_NODE_OUTPUT_LAMP 126
494 #define SH_NODE_FRESNEL 127
495 #define SH_NODE_MIX_SHADER 128
496 #define SH_NODE_ATTRIBUTE 129
497 #define SH_NODE_BACKGROUND 130
498 #define SH_NODE_BSDF_ANISOTROPIC 131
499 #define SH_NODE_BSDF_DIFFUSE 132
500 #define SH_NODE_BSDF_GLOSSY 133
501 #define SH_NODE_BSDF_GLASS 134
502 #define SH_NODE_BSDF_TRANSLUCENT 137
503 #define SH_NODE_BSDF_TRANSPARENT 138
504 #define SH_NODE_BSDF_VELVET 139
505 #define SH_NODE_EMISSION 140
506 #define SH_NODE_NEW_GEOMETRY 141
507 #define SH_NODE_LIGHT_PATH 142
508 #define SH_NODE_TEX_IMAGE 143
509 #define SH_NODE_TEX_SKY 145
510 #define SH_NODE_TEX_GRADIENT 146
511 #define SH_NODE_TEX_VORONOI 147
512 #define SH_NODE_TEX_MAGIC 148
513 #define SH_NODE_TEX_WAVE 149
514 #define SH_NODE_TEX_NOISE 150
515 #define SH_NODE_TEX_MUSGRAVE 152
516 #define SH_NODE_TEX_COORD 155
517 #define SH_NODE_ADD_SHADER 156
518 #define SH_NODE_TEX_ENVIRONMENT 157
519 #define SH_NODE_OUTPUT_TEXTURE 158
520 #define SH_NODE_HOLDOUT 159
521 #define SH_NODE_LAYER_WEIGHT 160
522 #define SH_NODE_VOLUME_TRANSPARENT 161
523 #define SH_NODE_VOLUME_ISOTROPIC 162
524 #define SH_NODE_GAMMA 163
525 #define SH_NODE_TEX_CHECKER 164
526 #define SH_NODE_BRIGHTCONTRAST 165
527 #define SH_NODE_LIGHT_FALLOFF 166
528 #define SH_NODE_OBJECT_INFO 167
529 #define SH_NODE_PARTICLE_INFO 168
531 /* custom defines options for Material node */
532 #define SH_NODE_MAT_DIFF 1
533 #define SH_NODE_MAT_SPEC 2
534 #define SH_NODE_MAT_NEG 4
535 /* custom defines: states for Script node. These are bit indices */
536 #define NODE_DYNAMIC_READY 0 /* 1 */
537 #define NODE_DYNAMIC_LOADED 1 /* 2 */
538 #define NODE_DYNAMIC_NEW 2 /* 4 */
539 #define NODE_DYNAMIC_UPDATED 3 /* 8 */
540 #define NODE_DYNAMIC_ADDEXIST 4 /* 16 */
541 #define NODE_DYNAMIC_ERROR 5 /* 32 */
542 #define NODE_DYNAMIC_REPARSE 6 /* 64 */
543 #define NODE_DYNAMIC_SET 15 /* sign */
547 struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
548 void ntreeShaderEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
549 void ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
550 void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
551 void nodeShaderSynchronizeID(struct bNode *node, int copyto);
553 /* switch material render loop */
554 extern void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
555 void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
557 void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
560 /* ************** COMPOSITE NODES *************** */
562 /* output socket defines */
563 #define RRES_OUT_IMAGE 0
564 #define RRES_OUT_ALPHA 1
566 #define RRES_OUT_NORMAL 3
567 #define RRES_OUT_UV 4
568 #define RRES_OUT_VEC 5
569 #define RRES_OUT_RGBA 6
570 #define RRES_OUT_DIFF 7
571 #define RRES_OUT_SPEC 8
572 #define RRES_OUT_SHADOW 9
573 #define RRES_OUT_AO 10
574 #define RRES_OUT_REFLECT 11
575 #define RRES_OUT_REFRACT 12
576 #define RRES_OUT_INDIRECT 13
577 #define RRES_OUT_INDEXOB 14
578 #define RRES_OUT_INDEXMA 15
579 #define RRES_OUT_MIST 16
580 #define RRES_OUT_EMIT 17
581 #define RRES_OUT_ENV 18
582 #define RRES_OUT_DIFF_DIRECT 19
583 #define RRES_OUT_DIFF_INDIRECT 20
584 #define RRES_OUT_DIFF_COLOR 21
585 #define RRES_OUT_GLOSSY_DIRECT 22
586 #define RRES_OUT_GLOSSY_INDIRECT 23
587 #define RRES_OUT_GLOSSY_COLOR 24
588 #define RRES_OUT_TRANSM_DIRECT 25
589 #define RRES_OUT_TRANSM_INDIRECT 26
590 #define RRES_OUT_TRANSM_COLOR 27
592 /* note: types are needed to restore callbacks, don't change values */
593 #define CMP_NODE_VIEWER 201
594 #define CMP_NODE_RGB 202
595 #define CMP_NODE_VALUE 203
596 #define CMP_NODE_MIX_RGB 204
597 #define CMP_NODE_VALTORGB 205
598 #define CMP_NODE_RGBTOBW 206
599 #define CMP_NODE_NORMAL 207
600 #define CMP_NODE_CURVE_VEC 208
601 #define CMP_NODE_CURVE_RGB 209
602 #define CMP_NODE_ALPHAOVER 210
603 #define CMP_NODE_BLUR 211
604 #define CMP_NODE_FILTER 212
605 #define CMP_NODE_MAP_VALUE 213
606 #define CMP_NODE_TIME 214
607 #define CMP_NODE_VECBLUR 215
608 #define CMP_NODE_SEPRGBA 216
609 #define CMP_NODE_SEPHSVA 217
610 #define CMP_NODE_SETALPHA 218
611 #define CMP_NODE_HUE_SAT 219
612 #define CMP_NODE_IMAGE 220
613 #define CMP_NODE_R_LAYERS 221
614 #define CMP_NODE_COMPOSITE 222
615 #define CMP_NODE_OUTPUT_FILE 223
616 #define CMP_NODE_TEXTURE 224
617 #define CMP_NODE_TRANSLATE 225
618 #define CMP_NODE_ZCOMBINE 226
619 #define CMP_NODE_COMBRGBA 227
620 #define CMP_NODE_DILATEERODE 228
621 #define CMP_NODE_ROTATE 229
622 #define CMP_NODE_SCALE 230
623 #define CMP_NODE_SEPYCCA 231
624 #define CMP_NODE_COMBYCCA 232
625 #define CMP_NODE_SEPYUVA 233
626 #define CMP_NODE_COMBYUVA 234
627 #define CMP_NODE_DIFF_MATTE 235
628 #define CMP_NODE_COLOR_SPILL 236
629 #define CMP_NODE_CHROMA_MATTE 237
630 #define CMP_NODE_CHANNEL_MATTE 238
631 #define CMP_NODE_FLIP 239
632 #define CMP_NODE_SPLITVIEWER 240
633 #define CMP_NODE_INDEX_MASK 241
634 #define CMP_NODE_MAP_UV 242
635 #define CMP_NODE_ID_MASK 243
636 #define CMP_NODE_DEFOCUS 244
637 #define CMP_NODE_DISPLACE 245
638 #define CMP_NODE_COMBHSVA 246
639 #define CMP_NODE_MATH 247
640 #define CMP_NODE_LUMA_MATTE 248
641 #define CMP_NODE_BRIGHTCONTRAST 249
642 #define CMP_NODE_GAMMA 250
643 #define CMP_NODE_INVERT 251
644 #define CMP_NODE_NORMALIZE 252
645 #define CMP_NODE_CROP 253
646 #define CMP_NODE_DBLUR 254
647 #define CMP_NODE_BILATERALBLUR 255
648 #define CMP_NODE_PREMULKEY 256
649 #define CMP_NODE_DIST_MATTE 257
650 #define CMP_NODE_VIEW_LEVELS 258
651 #define CMP_NODE_COLOR_MATTE 259
652 #define CMP_NODE_COLORBALANCE 260
653 #define CMP_NODE_HUECORRECT 261
654 #define CMP_NODE_MOVIECLIP 262
655 #define CMP_NODE_STABILIZE2D 263
656 #define CMP_NODE_TRANSFORM 264
657 #define CMP_NODE_MOVIEDISTORTION 265
658 #define CMP_NODE_DOUBLEEDGEMASK 266
659 #define CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED 267 /* DEPRECATED multi file node has been merged into regular CMP_NODE_OUTPUT_FILE */
660 #define CMP_NODE_MASK 268
661 #define CMP_NODE_KEYINGSCREEN 269
662 #define CMP_NODE_KEYING 270
664 #define CMP_NODE_GLARE 301
665 #define CMP_NODE_TONEMAP 302
666 #define CMP_NODE_LENSDIST 303
668 #define CMP_NODE_COLORCORRECTION 312
669 #define CMP_NODE_MASK_BOX 313
670 #define CMP_NODE_MASK_ELLIPSE 314
671 #define CMP_NODE_BOKEHIMAGE 315
672 #define CMP_NODE_BOKEHBLUR 316
673 #define CMP_NODE_SWITCH 317
675 /* channel toggles */
676 #define CMP_CHAN_RGB 1
680 #define CMP_CHAN_B 16
683 #define CMP_FILT_SOFT 0
684 #define CMP_FILT_SHARP 1
685 #define CMP_FILT_LAPLACE 2
686 #define CMP_FILT_SOBEL 3
687 #define CMP_FILT_PREWITT 4
688 #define CMP_FILT_KIRSCH 5
689 #define CMP_FILT_SHADOW 6
691 /* scale node type, in custom1 */
692 #define CMP_SCALE_RELATIVE 0
693 #define CMP_SCALE_ABSOLUTE 1
694 #define CMP_SCALE_SCENEPERCENT 2
695 #define CMP_SCALE_RENDERPERCENT 3
700 struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
701 void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
702 void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews);
703 void ntreeCompositTagRender(struct Scene *sce);
704 int ntreeCompositTagAnimated(struct bNodeTree *ntree);
705 void ntreeCompositTagGenerators(struct bNodeTree *ntree);
706 void ntreeCompositForceHidden(struct bNodeTree *ntree, struct Scene *scene);
707 void ntreeCompositClearTags(struct bNodeTree *ntree);
709 struct bNodeSocket *ntreeCompositOutputFileAddSocket(struct bNodeTree *ntree, struct bNode *node,
710 const char *name, struct ImageFormatData *im_format);
711 int ntreeCompositOutputFileRemoveActiveSocket(struct bNodeTree *ntree, struct bNode *node);
712 void ntreeCompositOutputFileSetPath(struct bNode *node, struct bNodeSocket *sock, const char *name);
713 void ntreeCompositOutputFileSetLayer(struct bNode *node, struct bNodeSocket *sock, const char *name);
714 /* needed in do_versions */
715 void ntreeCompositOutputFileUniquePath(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
716 void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
718 /* ************** TEXTURE NODES *************** */
722 #define TEX_NODE_OUTPUT 401
723 #define TEX_NODE_CHECKER 402
724 #define TEX_NODE_TEXTURE 403
725 #define TEX_NODE_BRICKS 404
726 #define TEX_NODE_MATH 405
727 #define TEX_NODE_MIX_RGB 406
728 #define TEX_NODE_RGBTOBW 407
729 #define TEX_NODE_VALTORGB 408
730 #define TEX_NODE_IMAGE 409
731 #define TEX_NODE_CURVE_RGB 410
732 #define TEX_NODE_INVERT 411
733 #define TEX_NODE_HUE_SAT 412
734 #define TEX_NODE_CURVE_TIME 413
735 #define TEX_NODE_ROTATE 414
736 #define TEX_NODE_VIEWER 415
737 #define TEX_NODE_TRANSLATE 416
738 #define TEX_NODE_COORD 417
739 #define TEX_NODE_DISTANCE 418
740 #define TEX_NODE_COMPOSE 419
741 #define TEX_NODE_DECOMPOSE 420
742 #define TEX_NODE_VALTONOR 421
743 #define TEX_NODE_SCALE 422
744 #define TEX_NODE_AT 423
746 /* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */
747 #define TEX_NODE_PROC 500
748 #define TEX_NODE_PROC_MAX 600
751 int ntreeTexTagAnimated(struct bNodeTree *ntree);
752 void ntreeTexCheckCyclics(struct bNodeTree *ntree);
754 struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
755 void ntreeTexEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
756 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);
759 /*************************************************/
761 void init_nodesystem(void);
762 void free_nodesystem(void);
764 void clear_scene_in_nodes(struct Main *bmain, struct Scene *sce);