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 /// Optional custom label function for the node header.
149 const char *(*labelfunc)(struct bNode *);
150 /// Optional custom resize handle polling.
151 int (*resize_area_func)(struct bNode *node, int x, int y);
153 /// Called when the node is updated in the editor.
154 void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node);
155 /// Check and update if internal ID data has changed.
156 void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
158 /// Initialize a new node instance of this type after creation.
159 void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
160 /// Free the custom storage data.
161 void (*freestoragefunc)(struct bNode *node);
162 /// Make a copy of the custom storage data.
163 void (*copystoragefunc)(struct bNode *node, struct bNode *target);
165 /// Create a template from an existing node.
166 struct bNodeTemplate (*templatefunc)(struct bNode *);
167 /** If a node can be made from the template in the given node tree.
168 * \example Node groups can not be created inside their own node tree.
170 int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
172 /// Initialize a node tree associated to this node type.
173 void (*inittreefunc)(struct bNodeTree *ntree);
174 /// Update a node tree associated to this node type.
175 void (*updatetreefunc)(struct bNodeTree *ntree);
177 /* group edit callbacks for operators */
178 /* XXX this is going to be changed as required by the UI */
179 struct bNodeTree *(*group_edit_get)(struct bNode *node);
180 struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit);
181 void (*group_edit_clear)(struct bNode *node);
183 /* Generate a temporary list of internal links (bNodeLink), for muting and disconnect operators.
184 * Result must be freed by caller!
186 ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node);
188 /* **** execution callbacks **** */
189 void *(*initexecfunc)(struct bNode *node);
190 void (*freeexecfunc)(struct bNode *node, void *nodedata);
191 void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **);
192 /* XXX this alternative exec function has been added to avoid changing all node types.
193 * when a final generic version of execution code is defined, this will be changed anyway
195 void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **);
197 int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
198 /* extended gpu function */
199 int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out);
202 /* node->exec, now in use for composites (#define for break is same as ready yes) */
203 #define NODE_PROCESSING 1
206 #define NODE_FINISHED 4
207 #define NODE_FREEBUFS 8
208 #define NODE_SKIPPED 16
210 /* sim_exec return value */
211 #define NODE_EXEC_FINISHED 0
212 #define NODE_EXEC_SUSPEND 1
214 /* nodetype->nclass, for add-menu and themes */
215 #define NODE_CLASS_INPUT 0
216 #define NODE_CLASS_OUTPUT 1
217 #define NODE_CLASS_OP_COLOR 3
218 #define NODE_CLASS_OP_VECTOR 4
219 #define NODE_CLASS_OP_FILTER 5
220 #define NODE_CLASS_GROUP 6
221 #define NODE_CLASS_FILE 7
222 #define NODE_CLASS_CONVERTOR 8
223 #define NODE_CLASS_MATTE 9
224 #define NODE_CLASS_DISTORT 10
225 #define NODE_CLASS_OP_DYNAMIC 11
226 #define NODE_CLASS_PATTERN 12
227 #define NODE_CLASS_TEXTURE 13
228 #define NODE_CLASS_EXECUTION 14
229 #define NODE_CLASS_GETDATA 15
230 #define NODE_CLASS_SETDATA 16
231 #define NODE_CLASS_MATH 17
232 #define NODE_CLASS_MATH_VECTOR 18
233 #define NODE_CLASS_MATH_ROTATION 19
234 #define NODE_CLASS_PARTICLES 25
235 #define NODE_CLASS_TRANSFORM 30
236 #define NODE_CLASS_COMBINE 31
237 #define NODE_CLASS_SHADER 40
238 #define NODE_CLASS_LAYOUT 100
240 /* nodetype->compatibility */
241 #define NODE_OLD_SHADING 1
242 #define NODE_NEW_SHADING 2
244 /* enum values for input/output */
248 struct bNodeTreeExec;
250 typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
251 typedef void (*bNodeClassCallback)(void *calldata, int nclass, const char *name);
252 typedef struct bNodeTreeType
254 int type; /* type identifier */
255 char idname[64]; /* id name for RNA identification */
257 ListBase node_types; /* type definitions */
260 void (*free_cache)(struct bNodeTree *ntree);
261 void (*free_node_cache)(struct bNodeTree *ntree, struct bNode *node);
262 void (*foreach_nodetree)(struct Main *main, void *calldata, bNodeTreeCallback func); /* iteration over all node trees */
263 void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func); /* iteration over all node classes */
265 /* calls allowing threaded composite */
266 void (*localize)(struct bNodeTree *localtree, struct bNodeTree *ntree);
267 void (*local_sync)(struct bNodeTree *localtree, struct bNodeTree *ntree);
268 void (*local_merge)(struct bNodeTree *localtree, struct bNodeTree *ntree);
270 /* Tree update. Overrides nodetype->updatetreefunc! */
271 void (*update)(struct bNodeTree *ntree);
272 /* Node update. Overrides nodetype->updatefunc! */
273 void (*update_node)(struct bNodeTree *ntree, struct bNode *node);
275 int (*validate_link)(struct bNodeTree *ntree, struct bNodeLink *link);
277 /* Default internal linking. */
278 ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node);
281 /* ************** GENERIC API, TREES *************** */
283 struct bNodeTreeType *ntreeGetType(int type);
284 struct bNodeType *ntreeGetNodeType(struct bNodeTree *ntree);
285 struct bNodeSocketType *ntreeGetSocketType(int type);
287 struct bNodeTree *ntreeAddTree(const char *name, int type, int nodetype);
288 void ntreeInitTypes(struct bNodeTree *ntree);
290 void ntreeFreeTree(struct bNodeTree *ntree);
291 struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree);
292 void ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
293 void ntreeMakeLocal(struct bNodeTree *ntree);
294 int ntreeHasType(struct bNodeTree *ntree, int type);
296 void ntreeUpdateTree(struct bNodeTree *ntree);
297 /* XXX Currently each tree update call does call to ntreeVerifyNodes too.
298 * Some day this should be replaced by a decent depsgraph automatism!
300 void ntreeVerifyNodes(struct Main *main, struct ID *id);
302 void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
304 /* XXX old trees handle output flags automatically based on special output node types and last active selection.
305 * new tree types have a per-output socket flag to indicate the final output to use explicitly.
307 void ntreeSetOutput(struct bNodeTree *ntree);
308 void ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
309 void ntreeClearPreview(struct bNodeTree *ntree);
311 void ntreeFreeCache(struct bNodeTree *ntree);
313 int ntreeNodeExists(struct bNodeTree *ntree, struct bNode *testnode);
314 int ntreeOutputExists(struct bNode *node, struct bNodeSocket *testsock);
315 struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree);
316 void ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree);
317 void ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree);
319 /* ************** GENERIC API, NODES *************** */
321 struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, struct bNode *node, int in_out, const char *name, int type);
322 struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode *node, int in_out, struct bNodeSocket *next_sock, const char *name, int type);
323 void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock);
324 void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node);
326 void nodeAddToPreview(struct bNode *, float *, int, int, int);
328 struct bNode *nodeAddNode(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
329 void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
330 void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
332 void nodeRegisterType(struct bNodeTreeType *ttype, struct bNodeType *ntype);
333 void nodeMakeDynamicType(struct bNode *node);
334 int nodeDynamicUnlinkText(struct ID *txtid);
336 void nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
337 struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node);
339 struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
340 void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
341 void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
342 void nodeInternalRelink(struct bNodeTree *ntree, struct bNode *node);
344 void nodeSpaceCoords(struct bNode *node, float *locx, float *locy);
345 void nodeAttachNode(struct bNode *node, struct bNode *parent);
346 void nodeDetachNode(struct bNode *node);
348 struct bNode *nodeFindNodebyName(struct bNodeTree *ntree, const char *name);
349 int nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **nodep, int *sockindex, int *in_out);
351 struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
352 int nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
354 void nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
355 struct bNode *nodeGetActive(struct bNodeTree *ntree);
356 struct bNode *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
357 int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
358 void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
359 struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree);
361 void nodeUpdate(struct bNodeTree *ntree, struct bNode *node);
362 int nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
364 void nodeFreePreview(struct bNode *node);
366 int nodeSocketIsHidden(struct bNodeSocket *sock);
368 /* ************** NODE TYPE ACCESS *************** */
370 struct bNodeTemplate nodeMakeTemplate(struct bNode *node);
371 int nodeValid(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
372 const char* nodeLabel(struct bNode *node);
373 struct bNodeTree *nodeGroupEditGet(struct bNode *node);
374 struct bNodeTree *nodeGroupEditSet(struct bNode *node, int edit);
375 void nodeGroupEditClear(struct bNode *node);
377 /* Init a new node type struct with default values and callbacks */
378 void node_type_base(struct bNodeTreeType *ttype, struct bNodeType *ntype, int type,
379 const char *name, short nclass, short flag);
380 void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs);
381 void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth);
382 void node_type_init(struct bNodeType *ntype, void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp));
383 void node_type_valid(struct bNodeType *ntype, int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp));
384 void node_type_storage(struct bNodeType *ntype,
385 const char *storagename,
386 void (*freestoragefunc)(struct bNode *),
387 void (*copystoragefunc)(struct bNode *, struct bNode *));
388 void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *));
389 void node_type_template(struct bNodeType *ntype, struct bNodeTemplate (*templatefunc)(struct bNode *));
390 void node_type_update(struct bNodeType *ntype,
391 void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
392 void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id));
393 void node_type_tree(struct bNodeType *ntype,
394 void (*inittreefunc)(struct bNodeTree *),
395 void (*updatetreefunc)(struct bNodeTree *));
396 void node_type_group_edit(struct bNodeType *ntype,
397 struct bNodeTree *(*group_edit_get)(struct bNode *node),
398 struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit),
399 void (*group_edit_clear)(struct bNode *node));
401 void node_type_exec(struct bNodeType *ntype, void (*execfunc)(void *data, struct bNode *, struct bNodeStack **,
402 struct bNodeStack **));
403 void node_type_exec_new(struct bNodeType *ntype,
404 void *(*initexecfunc)(struct bNode *node),
405 void (*freeexecfunc)(struct bNode *node, void *nodedata),
406 void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata,
407 struct bNodeStack **, struct bNodeStack **));
408 void node_type_internal_connect(struct bNodeType *ntype, ListBase (*internal_connect)(struct bNodeTree *, struct bNode *));
409 void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node,
410 struct GPUNodeStack *in, struct GPUNodeStack *out));
411 void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node,
412 void *nodedata, struct GPUNodeStack *in,
413 struct GPUNodeStack *out));
414 void node_type_compatibility(struct bNodeType *ntype, short compatibility);
416 /* ************** COMMON NODES *************** */
419 #define NODE_FORLOOP 3
420 #define NODE_WHILELOOP 4
422 #define NODE_GROUP_MENU 10000
423 #define NODE_DYNAMIC_MENU 20000
425 /* look up a socket on a group node by the internal group socket */
426 struct bNodeSocket *node_group_find_input(struct bNode *gnode, struct bNodeSocket *gsock);
427 struct bNodeSocket *node_group_find_output(struct bNode *gnode, struct bNodeSocket *gsock);
429 struct bNodeSocket *node_group_add_socket(struct bNodeTree *ngroup, const char *name, int type, int in_out);
430 struct bNodeSocket *node_group_expose_socket(struct bNodeTree *ngroup, struct bNodeSocket *sock, int in_out);
431 void node_group_expose_all_sockets(struct bNodeTree *ngroup);
432 void node_group_remove_socket(struct bNodeTree *ngroup, struct bNodeSocket *gsock, int in_out);
434 struct bNode *node_group_make_from_selected(struct bNodeTree *ntree);
435 int node_group_ungroup(struct bNodeTree *ntree, struct bNode *gnode);
437 /* in node_common.c */
438 void register_node_type_frame(struct bNodeTreeType *ttype);
440 /* ************** SHADER NODES *************** */
445 /* note: types are needed to restore callbacks, don't change values */
446 /* range 1 - 100 is reserved for common nodes */
447 /* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
449 #define SH_NODE_OUTPUT 1
451 #define SH_NODE_MATERIAL 100
452 #define SH_NODE_RGB 101
453 #define SH_NODE_VALUE 102
454 #define SH_NODE_MIX_RGB 103
455 #define SH_NODE_VALTORGB 104
456 #define SH_NODE_RGBTOBW 105
457 #define SH_NODE_TEXTURE 106
458 #define SH_NODE_NORMAL 107
459 #define SH_NODE_GEOMETRY 108
460 #define SH_NODE_MAPPING 109
461 #define SH_NODE_CURVE_VEC 110
462 #define SH_NODE_CURVE_RGB 111
463 #define SH_NODE_CAMERA 114
464 #define SH_NODE_MATH 115
465 #define SH_NODE_VECT_MATH 116
466 #define SH_NODE_SQUEEZE 117
467 #define SH_NODE_MATERIAL_EXT 118
468 #define SH_NODE_INVERT 119
469 #define SH_NODE_SEPRGB 120
470 #define SH_NODE_COMBRGB 121
471 #define SH_NODE_HUE_SAT 122
472 #define NODE_DYNAMIC 123
474 #define SH_NODE_OUTPUT_MATERIAL 124
475 #define SH_NODE_OUTPUT_WORLD 125
476 #define SH_NODE_OUTPUT_LAMP 126
477 #define SH_NODE_FRESNEL 127
478 #define SH_NODE_MIX_SHADER 128
479 #define SH_NODE_ATTRIBUTE 129
480 #define SH_NODE_BACKGROUND 130
481 #define SH_NODE_BSDF_ANISOTROPIC 131
482 #define SH_NODE_BSDF_DIFFUSE 132
483 #define SH_NODE_BSDF_GLOSSY 133
484 #define SH_NODE_BSDF_GLASS 134
485 #define SH_NODE_BSDF_TRANSLUCENT 137
486 #define SH_NODE_BSDF_TRANSPARENT 138
487 #define SH_NODE_BSDF_VELVET 139
488 #define SH_NODE_EMISSION 140
489 #define SH_NODE_NEW_GEOMETRY 141
490 #define SH_NODE_LIGHT_PATH 142
491 #define SH_NODE_TEX_IMAGE 143
492 #define SH_NODE_TEX_SKY 145
493 #define SH_NODE_TEX_GRADIENT 146
494 #define SH_NODE_TEX_VORONOI 147
495 #define SH_NODE_TEX_MAGIC 148
496 #define SH_NODE_TEX_WAVE 149
497 #define SH_NODE_TEX_NOISE 150
498 #define SH_NODE_TEX_MUSGRAVE 152
499 #define SH_NODE_TEX_COORD 155
500 #define SH_NODE_ADD_SHADER 156
501 #define SH_NODE_TEX_ENVIRONMENT 157
502 #define SH_NODE_OUTPUT_TEXTURE 158
503 #define SH_NODE_HOLDOUT 159
504 #define SH_NODE_LAYER_WEIGHT 160
505 #define SH_NODE_VOLUME_TRANSPARENT 161
506 #define SH_NODE_VOLUME_ISOTROPIC 162
507 #define SH_NODE_GAMMA 163
508 #define SH_NODE_TEX_CHECKER 164
509 #define SH_NODE_BRIGHTCONTRAST 165
511 /* custom defines options for Material node */
512 #define SH_NODE_MAT_DIFF 1
513 #define SH_NODE_MAT_SPEC 2
514 #define SH_NODE_MAT_NEG 4
515 /* custom defines: states for Script node. These are bit indices */
516 #define NODE_DYNAMIC_READY 0 /* 1 */
517 #define NODE_DYNAMIC_LOADED 1 /* 2 */
518 #define NODE_DYNAMIC_NEW 2 /* 4 */
519 #define NODE_DYNAMIC_UPDATED 3 /* 8 */
520 #define NODE_DYNAMIC_ADDEXIST 4 /* 16 */
521 #define NODE_DYNAMIC_ERROR 5 /* 32 */
522 #define NODE_DYNAMIC_REPARSE 6 /* 64 */
523 #define NODE_DYNAMIC_SET 15 /* sign */
527 struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
528 void ntreeShaderEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
529 void ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
530 void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
531 void nodeShaderSynchronizeID(struct bNode *node, int copyto);
533 /* switch material render loop */
534 extern void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
535 void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
537 void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
540 /* ************** COMPOSITE NODES *************** */
542 /* output socket defines */
543 #define RRES_OUT_IMAGE 0
544 #define RRES_OUT_ALPHA 1
546 #define RRES_OUT_NORMAL 3
547 #define RRES_OUT_UV 4
548 #define RRES_OUT_VEC 5
549 #define RRES_OUT_RGBA 6
550 #define RRES_OUT_DIFF 7
551 #define RRES_OUT_SPEC 8
552 #define RRES_OUT_SHADOW 9
553 #define RRES_OUT_AO 10
554 #define RRES_OUT_REFLECT 11
555 #define RRES_OUT_REFRACT 12
556 #define RRES_OUT_INDIRECT 13
557 #define RRES_OUT_INDEXOB 14
558 #define RRES_OUT_INDEXMA 15
559 #define RRES_OUT_MIST 16
560 #define RRES_OUT_EMIT 17
561 #define RRES_OUT_ENV 18
562 #define RRES_OUT_DIFF_DIRECT 19
563 #define RRES_OUT_DIFF_INDIRECT 20
564 #define RRES_OUT_DIFF_COLOR 21
565 #define RRES_OUT_GLOSSY_DIRECT 22
566 #define RRES_OUT_GLOSSY_INDIRECT 23
567 #define RRES_OUT_GLOSSY_COLOR 24
568 #define RRES_OUT_TRANSM_DIRECT 25
569 #define RRES_OUT_TRANSM_INDIRECT 26
570 #define RRES_OUT_TRANSM_COLOR 27
572 /* note: types are needed to restore callbacks, don't change values */
573 #define CMP_NODE_VIEWER 201
574 #define CMP_NODE_RGB 202
575 #define CMP_NODE_VALUE 203
576 #define CMP_NODE_MIX_RGB 204
577 #define CMP_NODE_VALTORGB 205
578 #define CMP_NODE_RGBTOBW 206
579 #define CMP_NODE_NORMAL 207
580 #define CMP_NODE_CURVE_VEC 208
581 #define CMP_NODE_CURVE_RGB 209
582 #define CMP_NODE_ALPHAOVER 210
583 #define CMP_NODE_BLUR 211
584 #define CMP_NODE_FILTER 212
585 #define CMP_NODE_MAP_VALUE 213
586 #define CMP_NODE_TIME 214
587 #define CMP_NODE_VECBLUR 215
588 #define CMP_NODE_SEPRGBA 216
589 #define CMP_NODE_SEPHSVA 217
590 #define CMP_NODE_SETALPHA 218
591 #define CMP_NODE_HUE_SAT 219
592 #define CMP_NODE_IMAGE 220
593 #define CMP_NODE_R_LAYERS 221
594 #define CMP_NODE_COMPOSITE 222
595 #define CMP_NODE_OUTPUT_FILE 223
596 #define CMP_NODE_TEXTURE 224
597 #define CMP_NODE_TRANSLATE 225
598 #define CMP_NODE_ZCOMBINE 226
599 #define CMP_NODE_COMBRGBA 227
600 #define CMP_NODE_DILATEERODE 228
601 #define CMP_NODE_ROTATE 229
602 #define CMP_NODE_SCALE 230
603 #define CMP_NODE_SEPYCCA 231
604 #define CMP_NODE_COMBYCCA 232
605 #define CMP_NODE_SEPYUVA 233
606 #define CMP_NODE_COMBYUVA 234
607 #define CMP_NODE_DIFF_MATTE 235
608 #define CMP_NODE_COLOR_SPILL 236
609 #define CMP_NODE_CHROMA_MATTE 237
610 #define CMP_NODE_CHANNEL_MATTE 238
611 #define CMP_NODE_FLIP 239
612 #define CMP_NODE_SPLITVIEWER 240
613 #define CMP_NODE_INDEX_MASK 241
614 #define CMP_NODE_MAP_UV 242
615 #define CMP_NODE_ID_MASK 243
616 #define CMP_NODE_DEFOCUS 244
617 #define CMP_NODE_DISPLACE 245
618 #define CMP_NODE_COMBHSVA 246
619 #define CMP_NODE_MATH 247
620 #define CMP_NODE_LUMA_MATTE 248
621 #define CMP_NODE_BRIGHTCONTRAST 249
622 #define CMP_NODE_GAMMA 250
623 #define CMP_NODE_INVERT 251
624 #define CMP_NODE_NORMALIZE 252
625 #define CMP_NODE_CROP 253
626 #define CMP_NODE_DBLUR 254
627 #define CMP_NODE_BILATERALBLUR 255
628 #define CMP_NODE_PREMULKEY 256
629 #define CMP_NODE_DIST_MATTE 257
630 #define CMP_NODE_VIEW_LEVELS 258
631 #define CMP_NODE_COLOR_MATTE 259
632 #define CMP_NODE_COLORBALANCE 260
633 #define CMP_NODE_HUECORRECT 261
634 #define CMP_NODE_MOVIECLIP 262
635 #define CMP_NODE_STABILIZE2D 263
636 #define CMP_NODE_TRANSFORM 264
637 #define CMP_NODE_MOVIEDISTORTION 265
638 #define CMP_NODE_DOUBLEEDGEMASK 266
639 #define CMP_NODE_OUTPUT_MULTI_FILE 267
641 #define CMP_NODE_GLARE 301
642 #define CMP_NODE_TONEMAP 302
643 #define CMP_NODE_LENSDIST 303
645 /* channel toggles */
646 #define CMP_CHAN_RGB 1
650 #define CMP_CHAN_B 16
653 #define CMP_FILT_SOFT 0
654 #define CMP_FILT_SHARP 1
655 #define CMP_FILT_LAPLACE 2
656 #define CMP_FILT_SOBEL 3
657 #define CMP_FILT_PREWITT 4
658 #define CMP_FILT_KIRSCH 5
659 #define CMP_FILT_SHADOW 6
661 /* scale node type, in custom1 */
662 #define CMP_SCALE_RELATIVE 0
663 #define CMP_SCALE_ABSOLUTE 1
664 #define CMP_SCALE_SCENEPERCENT 2
665 #define CMP_SCALE_RENDERPERCENT 3
670 struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
671 void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
672 void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int do_previews);
673 void ntreeCompositTagRender(struct Scene *sce);
674 int ntreeCompositTagAnimated(struct bNodeTree *ntree);
675 void ntreeCompositTagGenerators(struct bNodeTree *ntree);
676 void ntreeCompositForceHidden(struct bNodeTree *ntree, struct Scene *scene);
677 void ntreeCompositClearTags(struct bNodeTree *ntree);
679 void ntreeCompositOutputMultiFileAddSocket(struct bNodeTree *ntree, struct bNode *node, struct ImageFormatData *im_format);
680 int ntreeCompositOutputMultiFileRemoveActiveSocket(struct bNodeTree *ntree, struct bNode *node);
682 /* ************** TEXTURE NODES *************** */
686 #define TEX_NODE_OUTPUT 401
687 #define TEX_NODE_CHECKER 402
688 #define TEX_NODE_TEXTURE 403
689 #define TEX_NODE_BRICKS 404
690 #define TEX_NODE_MATH 405
691 #define TEX_NODE_MIX_RGB 406
692 #define TEX_NODE_RGBTOBW 407
693 #define TEX_NODE_VALTORGB 408
694 #define TEX_NODE_IMAGE 409
695 #define TEX_NODE_CURVE_RGB 410
696 #define TEX_NODE_INVERT 411
697 #define TEX_NODE_HUE_SAT 412
698 #define TEX_NODE_CURVE_TIME 413
699 #define TEX_NODE_ROTATE 414
700 #define TEX_NODE_VIEWER 415
701 #define TEX_NODE_TRANSLATE 416
702 #define TEX_NODE_COORD 417
703 #define TEX_NODE_DISTANCE 418
704 #define TEX_NODE_COMPOSE 419
705 #define TEX_NODE_DECOMPOSE 420
706 #define TEX_NODE_VALTONOR 421
707 #define TEX_NODE_SCALE 422
708 #define TEX_NODE_AT 423
710 /* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */
711 #define TEX_NODE_PROC 500
712 #define TEX_NODE_PROC_MAX 600
715 int ntreeTexTagAnimated(struct bNodeTree *ntree);
716 void ntreeTexSetPreviewFlag(int);
717 void ntreeTexCheckCyclics(struct bNodeTree *ntree);
718 char* ntreeTexOutputMenu(struct bNodeTree *ntree);
720 struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
721 void ntreeTexEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
722 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);
725 /*************************************************/
727 void init_nodesystem(void);
728 void free_nodesystem(void);
730 void clear_scene_in_nodes(struct Main *bmain, struct Scene *sce);