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 /* tree->chunksize */
245 #define NTREE_CHUNCKSIZE_32 32
246 #define NTREE_CHUNCKSIZE_64 64
247 #define NTREE_CHUNCKSIZE_128 128
248 #define NTREE_CHUNCKSIZE_256 256
249 #define NTREE_CHUNCKSIZE_512 512
250 #define NTREE_CHUNCKSIZE_1024 1024
252 /* the basis for a Node tree, all links and nodes reside internal here */
253 /* only re-usable node trees are in the library though, materials and textures allocate own tree struct */
254 typedef struct bNodeTree {
256 struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
258 struct bGPdata *gpd; /* grease pencil data */
260 ListBase nodes, links;
262 int type, init; /* set init on fileread */
263 int cur_index; /* sockets in groups have unique identifiers, adding new sockets always
264 * will increase this counter */
266 int update; /* update flags */
268 int nodetype; /* specific node type this tree is used for */
270 short edit_quality; /* Quality setting when editing */
271 short render_quality; /* Quality setting when rendering */
272 int chunksize; /* tile size for compositor engine */
274 ListBase inputs, outputs; /* external sockets for group nodes */
277 /* XXX It would be preferable to completely move this data out of the underlying node tree,
278 * so node tree execution could finally run independent of the tree itself. This would allow node trees
279 * to be merely linked by other data (materials, textures, etc.), as ID data is supposed to.
280 * Execution data is generated from the tree once at execution start and can then be used
281 * as long as necessary, even while the tree is being modified.
283 struct bNodeTreeExec *execdata;
286 void (*progress)(void *, float progress);
287 void (*stats_draw)(void *, char *str);
288 int (*test_break)(void *);
289 void *tbh, *prh, *sdh;
293 /* ntree->type, index */
294 #define NTREE_SHADER 0
295 #define NTREE_COMPOSIT 1
296 #define NTREE_TEXTURE 2
297 #define NUM_NTREE_TYPES 3
299 /* ntree->init, flag */
300 #define NTREE_TYPE_INIT 1
303 #define NTREE_DS_EXPAND 1 /* for animation editors */
304 #define NTREE_COM_OPENCL 2 /* use opencl */
305 /* XXX not nice, but needed as a temporary flags
306 * for group updates after library linking.
308 #define NTREE_DO_VERSIONS_GROUP_EXPOSE 1024
311 #define NTREE_UPDATE 0xFFFF /* generic update flag (includes all others) */
312 #define NTREE_UPDATE_LINKS 1 /* links have been added or removed */
313 #define NTREE_UPDATE_NODES 2 /* nodes or sockets have been added or removed */
314 #define NTREE_UPDATE_GROUP_IN 16 /* group inputs have changed */
315 #define NTREE_UPDATE_GROUP_OUT 32 /* group outputs have changed */
316 #define NTREE_UPDATE_GROUP 48 /* group has changed (generic flag including all other group flags) */
319 /* socket value structs for input buttons */
321 typedef struct bNodeSocketValueInt {
322 int subtype; /* RNA subtype */
325 } bNodeSocketValueInt;
327 typedef struct bNodeSocketValueFloat {
328 int subtype; /* RNA subtype */
331 } bNodeSocketValueFloat;
333 typedef struct bNodeSocketValueBoolean {
336 } bNodeSocketValueBoolean;
338 typedef struct bNodeSocketValueVector {
339 int subtype; /* RNA subtype */
342 } bNodeSocketValueVector;
344 typedef struct bNodeSocketValueRGBA {
346 } bNodeSocketValueRGBA;
349 /* data structs, for node->storage */
351 CMP_NODE_MASKTYPE_ADD = 0,
352 CMP_NODE_MASKTYPE_SUBTRACT = 1,
353 CMP_NODE_MASKTYPE_MULTIPLY = 2,
354 CMP_NODE_MASKTYPE_NOT = 3
358 CMP_NODE_LENSFLARE_GHOST = 1,
359 CMP_NODE_LENSFLARE_GLOW = 2,
360 CMP_NODE_LENSFLARE_CIRCLE = 4,
361 CMP_NODE_LENSFLARE_STREAKS = 8
365 CMP_NODE_DILATEERODE_STEP = 0,
366 CMP_NODE_DILATEERODE_DISTANCE_THRESH = 1,
367 CMP_NODE_DILATEERODE_DISTANCE = 2,
368 CMP_NODE_DILATEERODE_DISTANCE_FEATHER = 3
372 CMP_NODEFLAG_MASK_AA = (1 << 0),
373 CMP_NODEFLAG_MASK_FEATHER = (1 << 1)
376 typedef struct NodeFrame {
381 /* this one has been replaced with ImageUser, keep it for do_versions() */
382 typedef struct NodeImageAnim {
383 int frames, sfra, nr;
388 typedef struct ColorCorrectionData {
395 } ColorCorrectionData;
397 typedef struct NodeColorCorrection {
398 ColorCorrectionData master;
399 ColorCorrectionData shadows;
400 ColorCorrectionData midtones;
401 ColorCorrectionData highlights;
404 } NodeColorCorrection;
406 typedef struct NodeBokehImage {
414 typedef struct NodeBoxMask {
423 typedef struct NodeEllipseMask {
432 /* layer info for image node outputs */
433 typedef struct NodeImageLayer {
434 /* index in the Image->layers->passes lists */
436 /* render pass flag, in case this is an original render pass */
440 typedef struct NodeBlurData {
442 short samples, maxspeed, minspeed, relative, aspect;
444 float fac, percentx, percenty;
447 int image_in_width, image_in_height; /* needed for absolute/relative conversions */
450 typedef struct NodeDBlurData {
451 float center_x, center_y, distance, angle, spin, zoom;
456 typedef struct NodeBilateralBlurData {
457 float sigma_color, sigma_space;
459 } NodeBilateralBlurData;
461 typedef struct NodeHueSat {
465 typedef struct NodeImageFile {
466 char name[1024]; /* 1024 = FILE_MAX */
467 struct ImageFormatData im_format;
471 /* XXX first struct fields should match NodeImageFile to ensure forward compatibility */
472 typedef struct NodeImageMultiFile {
473 char base_path[1024]; /* 1024 = FILE_MAX */
474 ImageFormatData format;
475 int sfra DNA_DEPRECATED, efra DNA_DEPRECATED; /* XXX old frame rand values from NodeImageFile for forward compatibility */
476 int active_input; /* selected input in details view list */
478 } NodeImageMultiFile;
479 typedef struct NodeImageMultiFileSocket {
480 /* single layer file output */
481 short use_render_format DNA_DEPRECATED;
482 short use_node_format; /* use overall node image format */
484 char path[1024]; /* 1024 = FILE_MAX */
485 ImageFormatData format;
487 /* multilayer output */
488 char layer[30]; /* EXR_TOT_MAXNAME-2 ('.' and channel char are appended) */
490 } NodeImageMultiFileSocket;
492 typedef struct NodeChroma {
494 float fsize, fstrength, falpha;
496 short algorithm, channel;
499 typedef struct NodeTwoXYs {
500 short x1, x2, y1, y2;
501 float fac_x1, fac_x2, fac_y1, fac_y2;
504 typedef struct NodeTwoFloats {
508 typedef struct NodeGeometry {
509 char uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
513 typedef struct NodeVertexCol {
517 /* qdn: Defocus blur node */
518 typedef struct NodeDefocus {
519 char bktype, pad_c1, preview, gamco;
520 short samples, no_zbuf;
521 float fstop, maxblur, bthresh, scale;
522 float rotation, pad_f1;
525 typedef struct NodeScriptDict {
526 void *dict; /* for PyObject *dict */
527 void *node; /* for BPy_Node *node */
530 /* qdn: glare node */
531 typedef struct NodeGlare {
532 char quality, type, iter;
533 char angle, pad_c1, size, pad[2];
534 float colmod, mix, threshold, fade;
535 float angle_ofs, pad_f1;
538 /* qdn: tonemap node */
539 typedef struct NodeTonemap {
540 float key, offset, gamma;
545 /* qdn: lens distortion node */
546 typedef struct NodeLensDist {
547 short jit, proj, fit, pad;
550 typedef struct NodeColorBalance {
556 /* for ui representation */
561 /* temp storage for inverted lift */
566 typedef struct NodeColorspill {
567 short limchan, unspill;
569 float uspillr, uspillg, uspillb;
572 typedef struct NodeDilateErode {
577 typedef struct NodeTexBase {
578 TexMapping tex_mapping;
579 ColorMapping color_mapping;
582 typedef struct NodeTexSky {
584 float sun_direction[3];
588 typedef struct NodeTexImage {
591 int color_space, pad;
594 typedef struct NodeTexChecker {
598 typedef struct NodeTexEnvironment {
601 int color_space, projection;
602 } NodeTexEnvironment;
604 typedef struct NodeTexGradient {
610 typedef struct NodeTexNoise {
614 typedef struct NodeTexVoronoi {
620 typedef struct NodeTexMusgrave {
626 typedef struct NodeTexWave {
632 typedef struct NodeTexMagic {
638 typedef struct NodeShaderAttribute {
640 } NodeShaderAttribute;
643 typedef struct TexNodeOutput {
647 typedef struct NodeKeyingScreenData {
648 char tracking_object[64];
649 } NodeKeyingScreenData;
651 typedef struct NodeKeyingData {
652 float screen_balance;
653 float despill_factor;
654 int edge_kernel_radius;
655 float edge_kernel_tolerance;
656 float clip_black, clip_white;
658 int blur_pre, blur_post;
661 /* frame node flags */
662 #define NODE_FRAME_SHRINK 1 /* keep the bounding box minimal */
663 #define NODE_FRAME_RESIZEABLE 2 /* test flag, if frame can be resized by user */
665 /* comp channel matte */
666 #define CMP_NODE_CHANNEL_MATTE_CS_RGB 1
667 #define CMP_NODE_CHANNEL_MATTE_CS_HSV 2
668 #define CMP_NODE_CHANNEL_MATTE_CS_YUV 3
669 #define CMP_NODE_CHANNEL_MATTE_CS_YCC 4
671 /* glossy distributions */
672 #define SHD_GLOSSY_BECKMANN 0
673 #define SHD_GLOSSY_SHARP 1
674 #define SHD_GLOSSY_GGX 2
677 #define SHD_BLEND_LINEAR 0
678 #define SHD_BLEND_QUADRATIC 1
679 #define SHD_BLEND_EASING 2
680 #define SHD_BLEND_DIAGONAL 3
681 #define SHD_BLEND_RADIAL 4
682 #define SHD_BLEND_QUADRATIC_SPHERE 5
683 #define SHD_BLEND_SPHERICAL 6
685 /* noise basis for textures */
686 #define SHD_NOISE_PERLIN 0
687 #define SHD_NOISE_VORONOI_F1 1
688 #define SHD_NOISE_VORONOI_F2 2
689 #define SHD_NOISE_VORONOI_F3 3
690 #define SHD_NOISE_VORONOI_F4 4
691 #define SHD_NOISE_VORONOI_F2_F1 5
692 #define SHD_NOISE_VORONOI_CRACKLE 6
693 #define SHD_NOISE_CELL_NOISE 7
695 #define SHD_NOISE_SOFT 0
696 #define SHD_NOISE_HARD 1
698 /* voronoi texture */
699 #define SHD_VORONOI_DISTANCE_SQUARED 0
700 #define SHD_VORONOI_ACTUAL_DISTANCE 1
701 #define SHD_VORONOI_MANHATTAN 2
702 #define SHD_VORONOI_CHEBYCHEV 3
703 #define SHD_VORONOI_MINKOVSKY_H 4
704 #define SHD_VORONOI_MINKOVSKY_4 5
705 #define SHD_VORONOI_MINKOVSKY 6
707 #define SHD_VORONOI_INTENSITY 0
708 #define SHD_VORONOI_CELLS 1
710 /* musgrave texture */
711 #define SHD_MUSGRAVE_MULTIFRACTAL 0
712 #define SHD_MUSGRAVE_FBM 1
713 #define SHD_MUSGRAVE_HYBRID_MULTIFRACTAL 2
714 #define SHD_MUSGRAVE_RIDGED_MULTIFRACTAL 3
715 #define SHD_MUSGRAVE_HETERO_TERRAIN 4
718 #define SHD_WAVE_BANDS 0
719 #define SHD_WAVE_RINGS 1
721 #define SHD_WAVE_SINE 0
722 #define SHD_WAVE_SAW 1
723 #define SHD_WAVE_TRI 2
725 /* image/environment texture */
726 #define SHD_COLORSPACE_NONE 0
727 #define SHD_COLORSPACE_COLOR 1
729 /* environment texture */
730 #define SHD_PROJ_EQUIRECTANGULAR 0
731 #define SHD_PROJ_MIRROR_BALL 1
734 #define CMP_NODE_BLUR_ASPECT_NONE 0
735 #define CMP_NODE_BLUR_ASPECT_Y 1
736 #define CMP_NODE_BLUR_ASPECT_X 2