Cycles:
[blender.git] / intern / cycles / kernel / svm / svm_types.h
1 /*
2  * Copyright 2011, Blender Foundation.
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 #ifndef __SVM_TYPES_H__
20 #define __SVM_TYPES_H__
21
22 CCL_NAMESPACE_BEGIN
23
24 /* Stack */
25
26 /* SVM stack has a fixed size */
27 #define SVM_STACK_SIZE 255
28 /* SVM stack offsets with this value indicate that it's not on the stack */
29 #define SVM_STACK_INVALID 255 
30
31 /* Nodes */
32
33 typedef enum NodeType {
34         NODE_END = 0,
35         NODE_CLOSURE_BSDF,
36         NODE_CLOSURE_EMISSION,
37         NODE_CLOSURE_BACKGROUND,
38         NODE_CLOSURE_SET_WEIGHT,
39         NODE_CLOSURE_WEIGHT,
40         NODE_MIX_CLOSURE,
41         NODE_JUMP,
42         NODE_TEX_IMAGE,
43         NODE_TEX_IMAGE_BOX,
44         NODE_TEX_SKY,
45         NODE_GEOMETRY,
46         NODE_GEOMETRY_DUPLI,
47         NODE_LIGHT_PATH,
48         NODE_VALUE_F,
49         NODE_VALUE_V,
50         NODE_MIX,
51         NODE_ATTR,
52         NODE_CONVERT,
53         NODE_FRESNEL,
54         NODE_WIREFRAME,
55         NODE_WAVELENGTH,
56         NODE_BLACKBODY,
57         NODE_EMISSION_WEIGHT,
58         NODE_TEX_GRADIENT,
59         NODE_TEX_VORONOI,
60         NODE_TEX_MUSGRAVE,
61         NODE_TEX_WAVE,
62         NODE_TEX_MAGIC,
63         NODE_TEX_NOISE,
64         NODE_SHADER_JUMP,
65         NODE_SET_DISPLACEMENT,
66         NODE_GEOMETRY_BUMP_DX,
67         NODE_GEOMETRY_BUMP_DY,
68         NODE_SET_BUMP,
69         NODE_MATH,
70         NODE_VECTOR_MATH,
71         NODE_VECTOR_TRANSFORM,
72         NODE_MAPPING,
73         NODE_TEX_COORD,
74         NODE_TEX_COORD_BUMP_DX,
75         NODE_TEX_COORD_BUMP_DY,
76         NODE_ADD_CLOSURE,
77         NODE_EMISSION_SET_WEIGHT_TOTAL,
78         NODE_ATTR_BUMP_DX,
79         NODE_ATTR_BUMP_DY,
80         NODE_TEX_ENVIRONMENT,
81         NODE_CLOSURE_HOLDOUT,
82         NODE_LAYER_WEIGHT,
83         NODE_CLOSURE_VOLUME,
84         NODE_SEPARATE_RGB,
85         NODE_COMBINE_RGB,
86         NODE_SEPARATE_HSV,
87         NODE_COMBINE_HSV,
88         NODE_HSV,
89         NODE_CAMERA,
90         NODE_INVERT,
91         NODE_NORMAL,
92         NODE_GAMMA,
93         NODE_TEX_CHECKER,
94         NODE_BRIGHTCONTRAST,
95         NODE_RGB_RAMP,
96         NODE_RGB_CURVES,
97         NODE_VECTOR_CURVES,
98         NODE_MIN_MAX,
99         NODE_LIGHT_FALLOFF,
100         NODE_OBJECT_INFO,
101         NODE_PARTICLE_INFO,
102         NODE_TEX_BRICK,
103         NODE_CLOSURE_SET_NORMAL,
104         NODE_CLOSURE_AMBIENT_OCCLUSION,
105         NODE_TANGENT,
106         NODE_NORMAL_MAP,
107         NODE_HAIR_INFO
108 } NodeType;
109
110 typedef enum NodeAttributeType {
111         NODE_ATTR_FLOAT = 0,
112         NODE_ATTR_FLOAT3
113 } NodeAttributeType;
114
115 typedef enum NodeGeometry {
116         NODE_GEOM_P = 0,
117         NODE_GEOM_N,
118         NODE_GEOM_T,
119         NODE_GEOM_I,
120         NODE_GEOM_Ng,
121         NODE_GEOM_uv
122 } NodeGeometry;
123
124 typedef enum NodeObjectInfo {
125         NODE_INFO_OB_LOCATION,
126         NODE_INFO_OB_INDEX,
127         NODE_INFO_MAT_INDEX,
128         NODE_INFO_OB_RANDOM
129 } NodeObjectInfo;
130
131 typedef enum NodeParticleInfo {
132         NODE_INFO_PAR_INDEX,
133         NODE_INFO_PAR_AGE,
134         NODE_INFO_PAR_LIFETIME,
135         NODE_INFO_PAR_LOCATION,
136         NODE_INFO_PAR_ROTATION,
137         NODE_INFO_PAR_SIZE,
138         NODE_INFO_PAR_VELOCITY,
139         NODE_INFO_PAR_ANGULAR_VELOCITY
140 } NodeParticleInfo;
141
142 typedef enum NodeHairInfo {
143         NODE_INFO_CURVE_IS_STRAND,
144         NODE_INFO_CURVE_INTERCEPT,
145         NODE_INFO_CURVE_THICKNESS,
146         /*fade for minimum hair width transpency*/
147         /*NODE_INFO_CURVE_FADE,*/
148         NODE_INFO_CURVE_TANGENT_NORMAL
149 } NodeHairInfo;
150
151 typedef enum NodeLightPath {
152         NODE_LP_camera = 0,
153         NODE_LP_shadow,
154         NODE_LP_diffuse,
155         NODE_LP_glossy,
156         NODE_LP_singular,
157         NODE_LP_reflection,
158         NODE_LP_transmission,
159         NODE_LP_backfacing,
160         NODE_LP_ray_length
161 } NodeLightPath;
162
163 typedef enum NodeLightFalloff {
164         NODE_LIGHT_FALLOFF_QUADRATIC,
165         NODE_LIGHT_FALLOFF_LINEAR,
166         NODE_LIGHT_FALLOFF_CONSTANT
167 } NodeLightFalloff;
168
169 typedef enum NodeTexCoord {
170         NODE_TEXCO_NORMAL,
171         NODE_TEXCO_OBJECT,
172         NODE_TEXCO_CAMERA,
173         NODE_TEXCO_WINDOW,
174         NODE_TEXCO_REFLECTION,
175         NODE_TEXCO_DUPLI_GENERATED,
176         NODE_TEXCO_DUPLI_UV
177 } NodeTexCoord;
178
179 typedef enum NodeMix {
180         NODE_MIX_BLEND = 0,
181         NODE_MIX_ADD,
182         NODE_MIX_MUL,
183         NODE_MIX_SUB,
184         NODE_MIX_SCREEN,
185         NODE_MIX_DIV,
186         NODE_MIX_DIFF,
187         NODE_MIX_DARK,
188         NODE_MIX_LIGHT,
189         NODE_MIX_OVERLAY,
190         NODE_MIX_DODGE,
191         NODE_MIX_BURN,
192         NODE_MIX_HUE,
193         NODE_MIX_SAT,
194         NODE_MIX_VAL,
195         NODE_MIX_COLOR,
196         NODE_MIX_SOFT,
197         NODE_MIX_LINEAR,
198         NODE_MIX_CLAMP /* used for the clamp UI option */
199 } NodeMix;
200
201 typedef enum NodeMath {
202         NODE_MATH_ADD,
203         NODE_MATH_SUBTRACT,
204         NODE_MATH_MULTIPLY,
205         NODE_MATH_DIVIDE,
206         NODE_MATH_SINE,
207         NODE_MATH_COSINE,
208         NODE_MATH_TANGENT,
209         NODE_MATH_ARCSINE,
210         NODE_MATH_ARCCOSINE,
211         NODE_MATH_ARCTANGENT,
212         NODE_MATH_POWER,
213         NODE_MATH_LOGARITHM,
214         NODE_MATH_MINIMUM,
215         NODE_MATH_MAXIMUM,
216         NODE_MATH_ROUND,
217         NODE_MATH_LESS_THAN,
218         NODE_MATH_GREATER_THAN,
219         NODE_MATH_MODULO,
220         NODE_MATH_CLAMP /* used for the clamp UI option */
221 } NodeMath;
222
223 typedef enum NodeVectorMath {
224         NODE_VECTOR_MATH_ADD,
225         NODE_VECTOR_MATH_SUBTRACT,
226         NODE_VECTOR_MATH_AVERAGE,
227         NODE_VECTOR_MATH_DOT_PRODUCT,
228         NODE_VECTOR_MATH_CROSS_PRODUCT,
229         NODE_VECTOR_MATH_NORMALIZE
230 } NodeVectorMath;
231
232 typedef enum NodeVectorTransformType {
233         NODE_VECTOR_TRANSFORM_TYPE_VECTOR,
234         NODE_VECTOR_TRANSFORM_TYPE_POINT
235 } NodeVectorTransformType;
236
237 typedef enum NodeVectorTransformConvertFrom {
238         NODE_VECTOR_TRANSFORM_CONVERT_FROM_WORLD,
239         NODE_VECTOR_TRANSFORM_CONVERT_FROM_OBJECT,
240         NODE_VECTOR_TRANSFORM_CONVERT_FROM_CAMERA
241 } NodeVectorTransformConvertFrom;
242
243 typedef enum NodeVectorTransformConvertTo {
244         NODE_VECTOR_TRANSFORM_CONVERT_TO_WORLD,
245         NODE_VECTOR_TRANSFORM_CONVERT_TO_OBJECT,
246         NODE_VECTOR_TRANSFORM_CONVERT_TO_CAMERA
247 } NodeVectorTransformConvertTo;
248
249 typedef enum NodeConvert {
250         NODE_CONVERT_FV,
251         NODE_CONVERT_FI,
252         NODE_CONVERT_CF,
253         NODE_CONVERT_CI,
254         NODE_CONVERT_VF,
255         NODE_CONVERT_VI,
256         NODE_CONVERT_IF,
257         NODE_CONVERT_IV
258 } NodeConvert;
259
260 typedef enum NodeDistanceMetric {
261         NODE_VORONOI_DISTANCE_SQUARED,
262         NODE_VORONOI_ACTUAL_DISTANCE,
263         NODE_VORONOI_MANHATTAN,
264         NODE_VORONOI_CHEBYCHEV,
265         NODE_VORONOI_MINKOVSKY_H,
266         NODE_VORONOI_MINKOVSKY_4,
267         NODE_VORONOI_MINKOVSKY
268 } NodeDistanceMetric;
269
270 typedef enum NodeNoiseBasis {
271         NODE_NOISE_PERLIN,
272         NODE_NOISE_VORONOI_F1,
273         NODE_NOISE_VORONOI_F2,
274         NODE_NOISE_VORONOI_F3,
275         NODE_NOISE_VORONOI_F4,
276         NODE_NOISE_VORONOI_F2_F1,
277         NODE_NOISE_VORONOI_CRACKLE,
278         NODE_NOISE_CELL_NOISE
279 } NodeNoiseBasis;
280
281 typedef enum NodeWaveBasis {
282         NODE_WAVE_SINE,
283         NODE_WAVE_SAW,
284         NODE_WAVE_TRI
285 } NodeWaveBasis;
286
287 typedef enum NodeMusgraveType {
288         NODE_MUSGRAVE_MULTIFRACTAL,
289         NODE_MUSGRAVE_FBM,
290         NODE_MUSGRAVE_HYBRID_MULTIFRACTAL,
291         NODE_MUSGRAVE_RIDGED_MULTIFRACTAL,
292         NODE_MUSGRAVE_HETERO_TERRAIN
293 } NodeMusgraveType;
294
295 typedef enum NodeWaveType {
296         NODE_WAVE_BANDS,
297         NODE_WAVE_RINGS
298 } NodeWaveType;
299
300 typedef enum NodeGradientType {
301         NODE_BLEND_LINEAR,
302         NODE_BLEND_QUADRATIC,
303         NODE_BLEND_EASING,
304         NODE_BLEND_DIAGONAL,
305         NODE_BLEND_RADIAL,
306         NODE_BLEND_QUADRATIC_SPHERE,
307         NODE_BLEND_SPHERICAL
308 } NodeGradientType;
309
310 typedef enum NodeVoronoiColoring {
311         NODE_VORONOI_INTENSITY,
312         NODE_VORONOI_CELLS
313 } NodeVoronoiColoring;
314
315 typedef enum NodeBlendWeightType {
316         NODE_LAYER_WEIGHT_FRESNEL,
317         NODE_LAYER_WEIGHT_FACING
318 } NodeBlendWeightType;
319
320 typedef enum NodeTangentDirectionType {
321         NODE_TANGENT_RADIAL,
322         NODE_TANGENT_UVMAP
323 } NodeTangentDirectionType;
324
325 typedef enum NodeTangentAxis {
326         NODE_TANGENT_AXIS_X,
327         NODE_TANGENT_AXIS_Y,
328         NODE_TANGENT_AXIS_Z
329 } NodeTangentAxis;
330
331 typedef enum NodeNormalMapSpace {
332         NODE_NORMAL_MAP_TANGENT,
333         NODE_NORMAL_MAP_OBJECT,
334         NODE_NORMAL_MAP_WORLD,
335         NODE_NORMAL_MAP_BLENDER_OBJECT,
336         NODE_NORMAL_MAP_BLENDER_WORLD,
337 } NodeNormalMapSpace;
338
339 typedef enum ShaderType {
340         SHADER_TYPE_SURFACE,
341         SHADER_TYPE_VOLUME,
342         SHADER_TYPE_DISPLACEMENT
343 } ShaderType;
344
345 /* Closure */
346
347 typedef enum ClosureType {
348         CLOSURE_BSDF_ID,
349         
350         /* Diffuse */
351         CLOSURE_BSDF_DIFFUSE_ID,
352         CLOSURE_BSDF_OREN_NAYAR_ID,
353         CLOSURE_BSDF_WESTIN_SHEEN_ID,
354         CLOSURE_BSDF_DIFFUSE_RAMP_ID,
355         CLOSURE_BSDF_DIFFUSE_TOON_ID,
356         
357         /* Glossy */
358         CLOSURE_BSDF_GLOSSY_ID,
359         CLOSURE_BSDF_REFLECTION_ID,
360         CLOSURE_BSDF_MICROFACET_GGX_ID,
361         CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
362         CLOSURE_BSDF_WARD_ID,
363         CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
364         CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
365         CLOSURE_BSDF_PHONG_RAMP_ID,
366         CLOSURE_BSDF_GLOSSY_TOON_ID,
367         
368         /* Transmission */
369         CLOSURE_BSDF_TRANSMISSION_ID,
370         CLOSURE_BSDF_TRANSLUCENT_ID,
371         CLOSURE_BSDF_REFRACTION_ID,
372         CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
373         CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
374         CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID,
375         CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID,
376         CLOSURE_BSDF_SHARP_GLASS_ID,
377         
378         /* Transparent */
379         CLOSURE_BSDF_TRANSPARENT_ID,
380
381         /* Other */
382         CLOSURE_BSSRDF_ID,
383         CLOSURE_EMISSION_ID,
384         CLOSURE_DEBUG_ID,
385         CLOSURE_BACKGROUND_ID,
386         CLOSURE_HOLDOUT_ID,
387         CLOSURE_AMBIENT_OCCLUSION_ID,
388
389         /* Volume */
390         CLOSURE_VOLUME_ID,
391         CLOSURE_VOLUME_TRANSPARENT_ID,
392         CLOSURE_VOLUME_ISOTROPIC_ID,
393
394         NBUILTIN_CLOSURES
395 } ClosureType;
396
397 /* watch this, being lazy with memory usage */
398 #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
399 #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID)
400 #define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_GLOSSY_TOON_ID)
401 #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_SHARP_GLASS_ID)
402 #define CLOSURE_IS_BSSRDF(type) (type == CLOSURE_BSSRDF_ID)
403 #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
404 #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
405 #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
406 #define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
407 #define CLOSURE_IS_AMBIENT_OCCLUSION(type) (type == CLOSURE_AMBIENT_OCCLUSION_ID)
408
409 CCL_NAMESPACE_END
410
411 #endif /*  __SVM_TYPES_H__ */
412