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, Xavier Thomas
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file DNA_node_types.h
32 #ifndef __DNA_NODE_TYPES_H__
33 #define __DNA_NODE_TYPES_H__
36 #include "DNA_vec_types.h"
37 #include "DNA_listBase.h"
38 #include "DNA_texture_types.h"
39 #include "DNA_scene_types.h"
52 #define NODE_MAXSTR 64
54 typedef struct bNodeStack {
58 short hasinput; /* when input has link, tagged before executing */
59 short hasoutput; /* when output is linked, tagged before executing */
60 short datatype; /* type of data pointer */
61 short sockettype; /* type of socket stack comes from, to remap linking different sockets */
62 short is_copy; /* data is a copy of external data (no freeing) */
63 short external; /* data is used by external nodes (no freeing) */
67 /* ns->datatype, shadetree only */
68 #define NS_OSA_VECTORS 1
69 #define NS_OSA_VALUES 2
71 /* node socket/node socket type -b conversion rules */
72 #define NS_CR_CENTER 0
74 #define NS_CR_FIT_WIDTH 2
75 #define NS_CR_FIT_HEIGHT 3
77 #define NS_CR_STRETCH 5
79 typedef struct bNodeSocket {
80 struct bNodeSocket *next, *prev, *new_sock;
82 char name[64]; /* MAX_NAME */
84 void *storage; /* custom storage */
87 short limit; /* max. number of links */
92 void *default_value; /* default input value used for unlinked sockets */
95 short stack_index; /* local stack index */
96 /* XXX deprecated, kept for forward compatibility */
97 short stack_type DNA_DEPRECATED;
98 int resizemode; /* compositor resize mode of the socket */
99 void *cache; /* cached data from execution */
101 /* internal data to retrieve relations and groups */
102 int own_index; /* group socket identifiers, to find matching pairs after reading files */
103 /* XXX deprecated, only used for restoring old group node links */
104 int to_index DNA_DEPRECATED;
105 struct bNodeSocket *groupsock;
107 struct bNodeLink *link; /* a link pointer, set in ntreeUpdateTree */
109 /* XXX deprecated, socket input values are stored in default_value now. kept for forward compatibility */
110 bNodeStack ns DNA_DEPRECATED; /* custom data for inputs, only UI writes in this */
115 #define SOCK_VECTOR 1
117 #define SOCK_SHADER 3
118 #define SOCK_BOOLEAN 4
121 #define NUM_SOCKET_TYPES 7 /* must be last! */
123 /* socket side (input/output) */
127 /* sock->flag, first bit is select */
128 /* hidden is user defined, to hide unused */
129 #define SOCK_HIDDEN 2
130 /* only used now for groups... */
131 #define SOCK_IN_USE 4 /* XXX deprecated */
132 /* unavailable is for dynamic sockets */
133 #define SOCK_UNAVAIL 8
134 /* dynamic socket (can be modified by user) */
135 #define SOCK_DYNAMIC 16
136 /* group socket should not be exposed */
137 #define SOCK_INTERNAL 32
138 /* socket collapsed in UI */
139 #define SOCK_COLLAPSED 64
140 /* hide socket value, if it gets auto default */
141 #define SOCK_HIDE_VALUE 128
142 /* socket hidden automatically, to distinguish from manually hidden */
143 /* DEPRECATED, only kept here to avoid reusing the flag */
144 #define SOCK_AUTO_HIDDEN__DEPRECATED 256
146 typedef struct bNodePreview {
152 /* limit data in bNode to what we want to see saved? */
153 typedef struct bNode {
154 struct bNode *next, *prev, *new_node;
156 char name[64]; /* MAX_NAME */
159 short done, level; /* both for dependency and sorting */
160 short lasty, menunr; /* lasty: check preview render status, menunr: browse ID blocks */
161 short stack_index; /* for groupnode, offset in global caller stack */
162 short nr; /* number of this node in list, used for UI exec events */
163 float color[3]; /* custom user-defined color */
165 ListBase inputs, outputs;
166 struct bNode *parent; /* parent node */
167 struct ID *id; /* optional link to libdata */
168 void *storage; /* custom data, must be struct, for storage in file */
170 float locx, locy; /* root offset for drawing */
171 float width, height; /* node custom width and height */
172 float miniwidth; /* node width if hidden */
173 float offsetx, offsety; /* additional offset from loc */
175 int update; /* update flags */
177 char label[64]; /* custom user-defined label, MAX_NAME */
178 short custom1, custom2; /* to be abused for buttons */
179 float custom3, custom4;
181 short need_exec, exec; /* need_exec is set as UI execution event, exec is flag during exec */
182 void *threaddata; /* optional extra storage for use in thread (read only then!) */
184 rctf totr; /* entire boundbox */
185 rctf butr; /* optional buttons area */
186 rctf prvr; /* optional preview area */
187 bNodePreview *preview; /* optional preview image */
188 struct uiBlock *block; /* runtime during drawing */
190 struct bNodeType *typeinfo; /* lookup of callbacks and defaults */
194 #define NODE_SELECT 1
195 #define NODE_OPTIONS 2
196 #define NODE_PREVIEW 4
197 #define NODE_HIDDEN 8
198 #define NODE_ACTIVE 16
199 #define NODE_ACTIVE_ID 32
200 #define NODE_DO_OUTPUT 64
201 #define NODE_GROUP_EDIT 128
202 /* free test flag, undefined */
203 #define NODE_TEST 256
204 /* node is disabled */
205 #define NODE_MUTED 512
206 #define NODE_CUSTOM_NAME 1024 /* deprecated! */
207 /* group node types: use const outputs by default */
208 #define NODE_CONST_OUTPUT (1<<11)
209 /* node is always behind others */
210 #define NODE_BACKGROUND (1<<12)
211 /* automatic flag for nodes included in transforms */
212 #define NODE_TRANSFORM (1<<13)
213 /* node is active texture */
214 #define NODE_ACTIVE_TEXTURE (1<<14)
215 /* use a custom color for the node */
216 #define NODE_CUSTOM_COLOR (1<<15)
219 /* XXX NODE_UPDATE is a generic update flag. More fine-grained updates
220 * might be used in the future, but currently all work the same way.
222 #define NODE_UPDATE 0xFFFF /* generic update flag (includes all others) */
223 #define NODE_UPDATE_ID 1 /* associated id data block has changed */
225 typedef struct bNodeLink {
226 struct bNodeLink *next, *prev;
228 bNode *fromnode, *tonode;
229 bNodeSocket *fromsock, *tosock;
236 #define NODE_LINKFLAG_HILITE 1 /* link has been successfully validated */
237 #define NODE_LINK_VALID 2
239 /* tree->edit_quality/tree->render_quality */
240 #define NTREE_QUALITY_HIGH 0
241 #define NTREE_QUALITY_MEDIUM 1
242 #define NTREE_QUALITY_LOW 2
244 /* the basis for a Node tree, all links and nodes reside internal here */
245 /* only re-usable node trees are in the library though, materials and textures allocate own tree struct */
246 typedef struct bNodeTree {
248 struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
250 struct bGPdata *gpd; /* grease pencil data */
252 ListBase nodes, links;
254 int type, init; /* set init on fileread */
255 int cur_index; /* sockets in groups have unique identifiers, adding new sockets always
256 * will increase this counter */
258 int update; /* update flags */
260 int nodetype; /* specific node type this tree is used for */
262 short edit_quality; /* Quality setting when editing */
263 short render_quality; /* Quality setting when rendering */
264 int chunksize; /* tile size for compositor engine */
266 ListBase inputs, outputs; /* external sockets for group nodes */
269 /* XXX It would be preferable to completely move this data out of the underlying node tree,
270 * so node tree execution could finally run independent of the tree itself. This would allow node trees
271 * to be merely linked by other data (materials, textures, etc.), as ID data is supposed to.
272 * Execution data is generated from the tree once at execution start and can then be used
273 * as long as necessary, even while the tree is being modified.
275 struct bNodeTreeExec *execdata;
278 void (*progress)(void *, float progress);
279 void (*stats_draw)(void *, char *str);
280 int (*test_break)(void *);
281 void *tbh, *prh, *sdh;
285 /* ntree->type, index */
286 #define NTREE_SHADER 0
287 #define NTREE_COMPOSIT 1
288 #define NTREE_TEXTURE 2
289 #define NUM_NTREE_TYPES 3
291 /* ntree->init, flag */
292 #define NTREE_TYPE_INIT 1
295 #define NTREE_DS_EXPAND 1 /* for animation editors */
296 #define NTREE_COM_OPENCL 2 /* use opencl */
297 /* XXX not nice, but needed as a temporary flags
298 * for group updates after library linking.
300 #define NTREE_DO_VERSIONS_GROUP_EXPOSE 1024
303 #define NTREE_UPDATE 0xFFFF /* generic update flag (includes all others) */
304 #define NTREE_UPDATE_LINKS 1 /* links have been added or removed */
305 #define NTREE_UPDATE_NODES 2 /* nodes or sockets have been added or removed */
306 #define NTREE_UPDATE_GROUP_IN 16 /* group inputs have changed */
307 #define NTREE_UPDATE_GROUP_OUT 32 /* group outputs have changed */
308 #define NTREE_UPDATE_GROUP 48 /* group has changed (generic flag including all other group flags) */
311 /* socket value structs for input buttons */
313 typedef struct bNodeSocketValueInt {
314 int subtype; /* RNA subtype */
317 } bNodeSocketValueInt;
319 typedef struct bNodeSocketValueFloat {
320 int subtype; /* RNA subtype */
323 } bNodeSocketValueFloat;
325 typedef struct bNodeSocketValueBoolean {
328 } bNodeSocketValueBoolean;
330 typedef struct bNodeSocketValueVector {
331 int subtype; /* RNA subtype */
334 } bNodeSocketValueVector;
336 typedef struct bNodeSocketValueRGBA {
338 } bNodeSocketValueRGBA;
341 /* data structs, for node->storage */
343 #define CMP_NODE_MASKTYPE_ADD 0
344 #define CMP_NODE_MASKTYPE_SUBTRACT 1
345 #define CMP_NODE_MASKTYPE_MULTIPLY 2
346 #define CMP_NODE_MASKTYPE_NOT 3
348 #define CMP_NODE_LENSFLARE_GHOST 1
349 #define CMP_NODE_LENSFLARE_GLOW 2
350 #define CMP_NODE_LENSFLARE_CIRCLE 4
351 #define CMP_NODE_LENSFLARE_STREAKS 8
353 #define CMP_NODE_DILATEERODE_STEP 0
354 #define CMP_NODE_DILATEERODE_DISTANCE_THRESH 1
355 #define CMP_NODE_DILATEERODE_DISTANCE 2
357 typedef struct NodeFrame {
362 /* this one has been replaced with ImageUser, keep it for do_versions() */
363 typedef struct NodeImageAnim {
364 int frames, sfra, nr;
369 typedef struct ColorCorrectionData {
376 } ColorCorrectionData;
378 typedef struct NodeColorCorrection {
379 ColorCorrectionData master;
380 ColorCorrectionData shadows;
381 ColorCorrectionData midtones;
382 ColorCorrectionData highlights;
385 } NodeColorCorrection;
387 typedef struct NodeBokehImage {
395 typedef struct NodeBoxMask {
404 typedef struct NodeEllipseMask {
413 /* layer info for image node outputs */
414 typedef struct NodeImageLayer {
415 /* index in the Image->layers->passes lists */
417 /* render pass flag, in case this is an original render pass */
421 typedef struct NodeBlurData {
423 short samples, maxspeed, minspeed, relative, aspect;
425 float fac, percentx, percenty;
428 int image_in_width, image_in_height; /* needed for absolute/relative conversions */
431 typedef struct NodeDBlurData {
432 float center_x, center_y, distance, angle, spin, zoom;
437 typedef struct NodeBilateralBlurData {
438 float sigma_color, sigma_space;
440 } NodeBilateralBlurData;
442 typedef struct NodeHueSat {
446 typedef struct NodeImageFile {
447 char name[1024]; /* 1024 = FILE_MAX */
448 struct ImageFormatData im_format;
452 /* XXX first struct fields should match NodeImageFile to ensure forward compatibility */
453 typedef struct NodeImageMultiFile {
454 char base_path[1024]; /* 1024 = FILE_MAX */
455 ImageFormatData format;
456 int sfra DNA_DEPRECATED, efra DNA_DEPRECATED; /* XXX old frame rand values from NodeImageFile for forward compatibility */
457 int active_input; /* selected input in details view list */
459 } NodeImageMultiFile;
460 typedef struct NodeImageMultiFileSocket {
461 /* single layer file output */
462 short use_render_format DNA_DEPRECATED;
463 short use_node_format; /* use overall node image format */
465 char path[1024]; /* 1024 = FILE_MAX */
466 ImageFormatData format;
468 /* multilayer output */
469 char layer[30]; /* EXR_TOT_MAXNAME-2 ('.' and channel char are appended) */
471 } NodeImageMultiFileSocket;
473 typedef struct NodeChroma {
475 float fsize, fstrength, falpha;
477 short algorithm, channel;
480 typedef struct NodeTwoXYs {
481 short x1, x2, y1, y2;
482 float fac_x1, fac_x2, fac_y1, fac_y2;
485 typedef struct NodeTwoFloats {
489 typedef struct NodeGeometry {
490 char uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
494 typedef struct NodeVertexCol {
498 /* qdn: Defocus blur node */
499 typedef struct NodeDefocus {
500 char bktype, pad_c1, preview, gamco;
501 short samples, no_zbuf;
502 float fstop, maxblur, bthresh, scale;
503 float rotation, pad_f1;
506 typedef struct NodeScriptDict {
507 void *dict; /* for PyObject *dict */
508 void *node; /* for BPy_Node *node */
511 /* qdn: glare node */
512 typedef struct NodeGlare {
513 char quality, type, iter;
514 char angle, pad_c1, size, pad[2];
515 float colmod, mix, threshold, fade;
516 float angle_ofs, pad_f1;
519 /* qdn: tonemap node */
520 typedef struct NodeTonemap {
521 float key, offset, gamma;
526 /* qdn: lens distortion node */
527 typedef struct NodeLensDist {
528 short jit, proj, fit, pad;
531 typedef struct NodeColorBalance {
537 /* for ui representation */
542 /* temp storage for inverted lift */
547 typedef struct NodeColorspill {
548 short limchan, unspill;
550 float uspillr, uspillg, uspillb;
553 typedef struct NodeTexBase {
554 TexMapping tex_mapping;
555 ColorMapping color_mapping;
558 typedef struct NodeTexSky {
560 float sun_direction[3];
564 typedef struct NodeTexImage {
566 int color_space, pad;
569 typedef struct NodeTexChecker {
573 typedef struct NodeTexEnvironment {
575 int color_space, projection;
576 } NodeTexEnvironment;
578 typedef struct NodeTexGradient {
584 typedef struct NodeTexNoise {
588 typedef struct NodeTexVoronoi {
594 typedef struct NodeTexMusgrave {
600 typedef struct NodeTexWave {
606 typedef struct NodeTexMagic {
612 typedef struct NodeShaderAttribute {
614 } NodeShaderAttribute;
617 typedef struct TexNodeOutput {
621 typedef struct NodeKeyingScreenData {
622 char tracking_object[64];
623 } NodeKeyingScreenData;
625 typedef struct NodeKeyingData {
626 float despill_factor;
627 float clip_black, clip_white;
629 int blur_pre, blur_post;
632 /* frame node flags */
633 #define NODE_FRAME_SHRINK 1 /* keep the bounding box minimal */
634 #define NODE_FRAME_RESIZEABLE 2 /* test flag, if frame can be resized by user */
636 /* comp channel matte */
637 #define CMP_NODE_CHANNEL_MATTE_CS_RGB 1
638 #define CMP_NODE_CHANNEL_MATTE_CS_HSV 2
639 #define CMP_NODE_CHANNEL_MATTE_CS_YUV 3
640 #define CMP_NODE_CHANNEL_MATTE_CS_YCC 4
642 /* glossy distributions */
643 #define SHD_GLOSSY_BECKMANN 0
644 #define SHD_GLOSSY_SHARP 1
645 #define SHD_GLOSSY_GGX 2
648 #define SHD_BLEND_LINEAR 0
649 #define SHD_BLEND_QUADRATIC 1
650 #define SHD_BLEND_EASING 2
651 #define SHD_BLEND_DIAGONAL 3
652 #define SHD_BLEND_RADIAL 4
653 #define SHD_BLEND_QUADRATIC_SPHERE 5
654 #define SHD_BLEND_SPHERICAL 6
656 /* noise basis for textures */
657 #define SHD_NOISE_PERLIN 0
658 #define SHD_NOISE_VORONOI_F1 1
659 #define SHD_NOISE_VORONOI_F2 2
660 #define SHD_NOISE_VORONOI_F3 3
661 #define SHD_NOISE_VORONOI_F4 4
662 #define SHD_NOISE_VORONOI_F2_F1 5
663 #define SHD_NOISE_VORONOI_CRACKLE 6
664 #define SHD_NOISE_CELL_NOISE 7
666 #define SHD_NOISE_SOFT 0
667 #define SHD_NOISE_HARD 1
669 /* voronoi texture */
670 #define SHD_VORONOI_DISTANCE_SQUARED 0
671 #define SHD_VORONOI_ACTUAL_DISTANCE 1
672 #define SHD_VORONOI_MANHATTAN 2
673 #define SHD_VORONOI_CHEBYCHEV 3
674 #define SHD_VORONOI_MINKOVSKY_H 4
675 #define SHD_VORONOI_MINKOVSKY_4 5
676 #define SHD_VORONOI_MINKOVSKY 6
678 #define SHD_VORONOI_INTENSITY 0
679 #define SHD_VORONOI_CELLS 1
681 /* musgrave texture */
682 #define SHD_MUSGRAVE_MULTIFRACTAL 0
683 #define SHD_MUSGRAVE_FBM 1
684 #define SHD_MUSGRAVE_HYBRID_MULTIFRACTAL 2
685 #define SHD_MUSGRAVE_RIDGED_MULTIFRACTAL 3
686 #define SHD_MUSGRAVE_HETERO_TERRAIN 4
689 #define SHD_WAVE_BANDS 0
690 #define SHD_WAVE_RINGS 1
692 #define SHD_WAVE_SINE 0
693 #define SHD_WAVE_SAW 1
694 #define SHD_WAVE_TRI 2
696 /* image/environment texture */
697 #define SHD_COLORSPACE_NONE 0
698 #define SHD_COLORSPACE_COLOR 1
700 /* environment texture */
701 #define SHD_PROJ_EQUIRECTANGULAR 0
702 #define SHD_PROJ_MIRROR_BALL 1
705 #define CMP_NODE_BLUR_ASPECT_NONE 0
706 #define CMP_NODE_BLUR_ASPECT_Y 1
707 #define CMP_NODE_BLUR_ASPECT_X 2