4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version. The Blender
10 * Foundation also sells licenses for use in proprietary software under
11 * the Blender License. See http://www.blender.org/BL/ for information
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The Original Code is Copyright (C) 2005 Blender Foundation.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL LICENSE BLOCK *****
53 /* ************** NODE TYPE DEFINITIONS ***** */
55 typedef struct bNodeSocketType {
58 float val1, val2, val3, val4; /* default alloc value for inputs */
59 float min, max; /* default range for inputs */
61 /* after this line is used internal only */
62 struct bNodeSocket *sock; /* used during verify_types */
63 struct bNodeSocket *internsock; /* group nodes, the internal socket counterpart */
64 int own_index; /* verify group nodes */
68 typedef struct bNodeType {
72 float width, minwidth, maxwidth;
75 bNodeSocketType *inputs, *outputs;
77 char storagename[64]; /* struct name for DNA */
79 void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **);
81 /* this line is set on startup of blender */
82 int (*butfunc)(struct uiBlock *, struct bNodeTree *, struct bNode *, struct rctf *);
84 void (*initfunc)(struct bNode *);
85 void (*freestoragefunc)(struct bNode *);
86 void (*copystoragefunc)(struct bNode *, struct bNode *);
88 /* for use with dynamic typedefs */
90 void *pynode; /* holds pointer to python script */
91 void *pydict; /* holds pointer to python script dictionary (scope)*/
95 /* node->exec, now in use for composites (#define for break is same as ready yes) */
96 #define NODE_PROCESSING 1
99 #define NODE_FINISHED 4
100 #define NODE_FREEBUFS 8
102 /* nodetype->nclass, for add-menu and themes */
103 #define NODE_CLASS_INPUT 0
104 #define NODE_CLASS_OUTPUT 1
105 #define NODE_CLASS_OP_COLOR 3
106 #define NODE_CLASS_OP_VECTOR 4
107 #define NODE_CLASS_OP_FILTER 5
108 #define NODE_CLASS_GROUP 6
109 #define NODE_CLASS_FILE 7
110 #define NODE_CLASS_CONVERTOR 8
111 #define NODE_CLASS_MATTE 9
112 #define NODE_CLASS_DISTORT 10
113 #define NODE_CLASS_OP_DYNAMIC 11
115 /* ************** GENERIC API, TREES *************** */
117 void ntreeVerifyTypes(struct bNodeTree *ntree);
119 struct bNodeTree *ntreeAddTree(int type);
120 void ntreeInitTypes(struct bNodeTree *ntree);
122 void ntreeMakeOwnType(struct bNodeTree *ntree);
123 void ntreeUpdateType(struct bNodeTree *ntree, struct bNodeType *ntype);
124 void ntreeFreeTree(struct bNodeTree *ntree);
125 struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree, int internal_select);
126 void ntreeMakeLocal(struct bNodeTree *ntree);
128 void ntreeSocketUseFlags(struct bNodeTree *ntree);
130 void ntreeSolveOrder(struct bNodeTree *ntree);
132 void ntreeBeginExecTree(struct bNodeTree *ntree);
133 void ntreeExecTree(struct bNodeTree *ntree, void *callerdata, int thread);
134 void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int do_previews);
135 void ntreeEndExecTree(struct bNodeTree *ntree);
137 void ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
138 void ntreeClearPreview(struct bNodeTree *ntree);
140 void ntreeFreeCache(struct bNodeTree *ntree);
142 /* ************** GENERIC API, NODES *************** */
144 void nodeVerifyType(struct bNodeTree *ntree, struct bNode *node);
146 void nodeAddToPreview(struct bNode *, float *, int, int);
148 void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
149 void nodeAddSockets(struct bNode *node, struct bNodeType *ntype);
150 struct bNode *nodeAddNodeType(struct bNodeTree *ntree, int type, struct bNodeTree *ngroup, struct ID *id);
151 void nodeRegisterType(struct ListBase *typelist, const struct bNodeType *ntype) ;
152 void nodeUpdateType(struct bNodeTree *ntree, struct bNode* node, struct bNodeType *ntype);
153 void nodeMakeDynamicType(struct bNode *node);
154 int nodeDynamicUnlinkText(struct ID *txtid);
155 void nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
156 struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal);
158 struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
159 void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
161 int nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **nodep, int *sockindex);
163 struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
164 int nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
166 void nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
167 struct bNode *nodeGetActive(struct bNodeTree *ntree);
168 struct bNode *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
169 void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
171 void NodeTagChanged(struct bNodeTree *ntree, struct bNode *node);
172 void NodeTagIDChanged(struct bNodeTree *ntree, struct ID *id);
174 /* ************** Groups ****************** */
176 struct bNode *nodeMakeGroupFromSelected(struct bNodeTree *ntree);
177 int nodeGroupUnGroup(struct bNodeTree *ntree, struct bNode *gnode);
179 void nodeVerifyGroup(struct bNodeTree *ngroup);
180 void nodeGroupSocketUseFlags(struct bNodeTree *ngroup);
182 void nodeCopyGroup(struct bNode *gnode);
184 /* ************** COMMON NODES *************** */
187 #define NODE_GROUP_MENU 1000
188 #define NODE_DYNAMIC_MENU 4000
190 extern bNodeType node_group_typeinfo;
193 /* ************** SHADER NODES *************** */
198 /* note: types are needed to restore callbacks, don't change values */
199 /* range 1 - 100 is reserved for common nodes */
200 /* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
202 #define SH_NODE_OUTPUT 1
204 #define SH_NODE_MATERIAL 100
205 #define SH_NODE_RGB 101
206 #define SH_NODE_VALUE 102
207 #define SH_NODE_MIX_RGB 103
208 #define SH_NODE_VALTORGB 104
209 #define SH_NODE_RGBTOBW 105
210 #define SH_NODE_TEXTURE 106
211 #define SH_NODE_NORMAL 107
212 #define SH_NODE_GEOMETRY 108
213 #define SH_NODE_MAPPING 109
214 #define SH_NODE_CURVE_VEC 110
215 #define SH_NODE_CURVE_RGB 111
216 #define SH_NODE_CAMERA 114
217 #define SH_NODE_MATH 115
218 #define SH_NODE_VECT_MATH 116
219 #define SH_NODE_SQUEEZE 117
220 #define SH_NODE_MATERIAL_EXT 118
221 #define SH_NODE_INVERT 119
222 #define SH_NODE_SEPRGB 120
223 #define SH_NODE_COMBRGB 121
224 #define SH_NODE_HUE_SAT 122
225 #define NODE_DYNAMIC 123
227 /* custom defines options for Material node */
228 #define SH_NODE_MAT_DIFF 1
229 #define SH_NODE_MAT_SPEC 2
230 #define SH_NODE_MAT_NEG 4
231 /* custom defines: states for Script node. These are bit indices */
232 #define NODE_DYNAMIC_READY 0 /* 1 */
233 #define NODE_DYNAMIC_LOADED 1 /* 2 */
234 #define NODE_DYNAMIC_NEW 2 /* 4 */
235 #define NODE_DYNAMIC_UPDATED 3 /* 8 */
236 #define NODE_DYNAMIC_ADDEXIST 4 /* 16 */
237 #define NODE_DYNAMIC_ERROR 5 /* 32 */
238 #define NODE_DYNAMIC_REPARSE 6 /* 64 */
239 #define NODE_DYNAMIC_SET 15 /* sign */
241 /* the type definitions array */
242 extern struct ListBase node_all_shaders;
246 void ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
247 void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
248 void nodeShaderSynchronizeID(struct bNode *node, int copyto);
250 /* switch material render loop */
251 extern void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
252 void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
255 /* ************** COMPOSITE NODES *************** */
257 /* output socket defines */
258 #define RRES_OUT_IMAGE 0
259 #define RRES_OUT_ALPHA 1
261 #define RRES_OUT_NORMAL 3
262 #define RRES_OUT_UV 4
263 #define RRES_OUT_VEC 5
264 #define RRES_OUT_RGBA 6
265 #define RRES_OUT_DIFF 7
266 #define RRES_OUT_SPEC 8
267 #define RRES_OUT_SHADOW 9
268 #define RRES_OUT_AO 10
269 #define RRES_OUT_REFLECT 11
270 #define RRES_OUT_REFRACT 12
271 #define RRES_OUT_RADIO 13
272 #define RRES_OUT_INDEXOB 14
273 #define RRES_OUT_MIST 15
275 /* note: types are needed to restore callbacks, don't change values */
276 #define CMP_NODE_VIEWER 201
277 #define CMP_NODE_RGB 202
278 #define CMP_NODE_VALUE 203
279 #define CMP_NODE_MIX_RGB 204
280 #define CMP_NODE_VALTORGB 205
281 #define CMP_NODE_RGBTOBW 206
282 #define CMP_NODE_NORMAL 207
283 #define CMP_NODE_CURVE_VEC 208
284 #define CMP_NODE_CURVE_RGB 209
285 #define CMP_NODE_ALPHAOVER 210
286 #define CMP_NODE_BLUR 211
287 #define CMP_NODE_FILTER 212
288 #define CMP_NODE_MAP_VALUE 213
289 #define CMP_NODE_TIME 214
290 #define CMP_NODE_VECBLUR 215
291 #define CMP_NODE_SEPRGBA 216
292 #define CMP_NODE_SEPHSVA 217
293 #define CMP_NODE_SETALPHA 218
294 #define CMP_NODE_HUE_SAT 219
295 #define CMP_NODE_IMAGE 220
296 #define CMP_NODE_R_LAYERS 221
297 #define CMP_NODE_COMPOSITE 222
298 #define CMP_NODE_OUTPUT_FILE 223
299 #define CMP_NODE_TEXTURE 224
300 #define CMP_NODE_TRANSLATE 225
301 #define CMP_NODE_ZCOMBINE 226
302 #define CMP_NODE_COMBRGBA 227
303 #define CMP_NODE_DILATEERODE 228
304 #define CMP_NODE_ROTATE 229
305 #define CMP_NODE_SCALE 230
306 #define CMP_NODE_SEPYCCA 231
307 #define CMP_NODE_COMBYCCA 232
308 #define CMP_NODE_SEPYUVA 233
309 #define CMP_NODE_COMBYUVA 234
310 #define CMP_NODE_DIFF_MATTE 235
311 #define CMP_NODE_COLOR_SPILL 236
312 #define CMP_NODE_CHROMA 237
313 #define CMP_NODE_CHANNEL_MATTE 238
314 #define CMP_NODE_FLIP 239
315 #define CMP_NODE_SPLITVIEWER 240
316 #define CMP_NODE_INDEX_MASK 241
317 #define CMP_NODE_MAP_UV 242
318 #define CMP_NODE_ID_MASK 243
319 #define CMP_NODE_DEFOCUS 244
320 #define CMP_NODE_DISPLACE 245
321 #define CMP_NODE_COMBHSVA 246
322 #define CMP_NODE_MATH 247
323 #define CMP_NODE_LUMA_MATTE 248
324 #define CMP_NODE_BRIGHTCONTRAST 249
325 #define CMP_NODE_GAMMA 250
326 #define CMP_NODE_INVERT 251
327 #define CMP_NODE_NORMALIZE 252
328 #define CMP_NODE_CROP 253
329 #define CMP_NODE_DBLUR 254
330 #define CMP_NODE_BILATERALBLUR 255
332 #define CMP_NODE_GLARE 301
333 #define CMP_NODE_TONEMAP 302
334 #define CMP_NODE_LENSDIST 303
336 /* channel toggles */
337 #define CMP_CHAN_RGB 1
341 #define CMP_CHAN_B 16
344 #define CMP_FILT_SOFT 0
345 #define CMP_FILT_SHARP 1
346 #define CMP_FILT_LAPLACE 2
347 #define CMP_FILT_SOBEL 3
348 #define CMP_FILT_PREWITT 4
349 #define CMP_FILT_KIRSCH 5
350 #define CMP_FILT_SHADOW 6
352 /* scale node type, in custom1 */
353 #define CMP_SCALE_RELATIVE 0
354 #define CMP_SCALE_ABSOLUTE 1
355 #define CMP_SCALE_SCENEPERCENT 2
358 /* the type definitions array */
359 extern struct ListBase node_all_composit;
363 void ntreeCompositTagRender(struct Scene *sce);
364 int ntreeCompositTagAnimated(struct bNodeTree *ntree);
365 void ntreeCompositTagGenerators(struct bNodeTree *ntree);
366 void ntreeCompositForceHidden(struct bNodeTree *ntree);
368 void free_compbuf(struct CompBuf *cbuf); /* internal...*/
370 void init_nodesystem(void);
371 void free_nodesystem(void);