9d9cb71f0f9ce48461c4a243ff3100064437fe7e
[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_HSV,
87         NODE_CAMERA,
88         NODE_INVERT,
89         NODE_NORMAL,
90         NODE_GAMMA,
91         NODE_TEX_CHECKER,
92         NODE_BRIGHTCONTRAST,
93         NODE_RGB_RAMP,
94         NODE_RGB_CURVES,
95         NODE_VECTOR_CURVES,
96         NODE_MIN_MAX,
97         NODE_LIGHT_FALLOFF,
98         NODE_OBJECT_INFO,
99         NODE_PARTICLE_INFO,
100         NODE_TEX_BRICK,
101         NODE_CLOSURE_SET_NORMAL,
102         NODE_CLOSURE_AMBIENT_OCCLUSION,
103         NODE_TANGENT,
104         NODE_NORMAL_MAP,
105         NODE_HAIR_INFO
106 } NodeType;
107
108 typedef enum NodeAttributeType {
109         NODE_ATTR_FLOAT = 0,
110         NODE_ATTR_FLOAT3
111 } NodeAttributeType;
112
113 typedef enum NodeGeometry {
114         NODE_GEOM_P = 0,
115         NODE_GEOM_N,
116         NODE_GEOM_T,
117         NODE_GEOM_I,
118         NODE_GEOM_Ng,
119         NODE_GEOM_uv
120 } NodeGeometry;
121
122 typedef enum NodeObjectInfo {
123         NODE_INFO_OB_LOCATION,
124         NODE_INFO_OB_INDEX,
125         NODE_INFO_MAT_INDEX,
126         NODE_INFO_OB_RANDOM
127 } NodeObjectInfo;
128
129 typedef enum NodeParticleInfo {
130         NODE_INFO_PAR_INDEX,
131         NODE_INFO_PAR_AGE,
132         NODE_INFO_PAR_LIFETIME,
133         NODE_INFO_PAR_LOCATION,
134         NODE_INFO_PAR_ROTATION,
135         NODE_INFO_PAR_SIZE,
136         NODE_INFO_PAR_VELOCITY,
137         NODE_INFO_PAR_ANGULAR_VELOCITY
138 } NodeParticleInfo;
139
140 typedef enum NodeHairInfo {
141         NODE_INFO_CURVE_IS_STRAND,
142         NODE_INFO_CURVE_INTERCEPT,
143         NODE_INFO_CURVE_THICKNESS,
144         /*fade for minimum hair width transpency*/
145         /*NODE_INFO_CURVE_FADE,*/
146         NODE_INFO_CURVE_TANGENT_NORMAL
147 } NodeHairInfo;
148
149 typedef enum NodeLightPath {
150         NODE_LP_camera = 0,
151         NODE_LP_shadow,
152         NODE_LP_diffuse,
153         NODE_LP_glossy,
154         NODE_LP_singular,
155         NODE_LP_reflection,
156         NODE_LP_transmission,
157         NODE_LP_backfacing,
158         NODE_LP_ray_length
159 } NodeLightPath;
160
161 typedef enum NodeLightFalloff {
162         NODE_LIGHT_FALLOFF_QUADRATIC,
163         NODE_LIGHT_FALLOFF_LINEAR,
164         NODE_LIGHT_FALLOFF_CONSTANT
165 } NodeLightFalloff;
166
167 typedef enum NodeTexCoord {
168         NODE_TEXCO_NORMAL,
169         NODE_TEXCO_OBJECT,
170         NODE_TEXCO_CAMERA,
171         NODE_TEXCO_WINDOW,
172         NODE_TEXCO_REFLECTION,
173         NODE_TEXCO_DUPLI_GENERATED,
174         NODE_TEXCO_DUPLI_UV
175 } NodeTexCoord;
176
177 typedef enum NodeMix {
178         NODE_MIX_BLEND = 0,
179         NODE_MIX_ADD,
180         NODE_MIX_MUL,
181         NODE_MIX_SUB,
182         NODE_MIX_SCREEN,
183         NODE_MIX_DIV,
184         NODE_MIX_DIFF,
185         NODE_MIX_DARK,
186         NODE_MIX_LIGHT,
187         NODE_MIX_OVERLAY,
188         NODE_MIX_DODGE,
189         NODE_MIX_BURN,
190         NODE_MIX_HUE,
191         NODE_MIX_SAT,
192         NODE_MIX_VAL,
193         NODE_MIX_COLOR,
194         NODE_MIX_SOFT,
195         NODE_MIX_LINEAR,
196         NODE_MIX_CLAMP /* used for the clamp UI option */
197 } NodeMix;
198
199 typedef enum NodeMath {
200         NODE_MATH_ADD,
201         NODE_MATH_SUBTRACT,
202         NODE_MATH_MULTIPLY,
203         NODE_MATH_DIVIDE,
204         NODE_MATH_SINE,
205         NODE_MATH_COSINE,
206         NODE_MATH_TANGENT,
207         NODE_MATH_ARCSINE,
208         NODE_MATH_ARCCOSINE,
209         NODE_MATH_ARCTANGENT,
210         NODE_MATH_POWER,
211         NODE_MATH_LOGARITHM,
212         NODE_MATH_MINIMUM,
213         NODE_MATH_MAXIMUM,
214         NODE_MATH_ROUND,
215         NODE_MATH_LESS_THAN,
216         NODE_MATH_GREATER_THAN,
217         NODE_MATH_MODULO,
218         NODE_MATH_CLAMP /* used for the clamp UI option */
219 } NodeMath;
220
221 typedef enum NodeVectorMath {
222         NODE_VECTOR_MATH_ADD,
223         NODE_VECTOR_MATH_SUBTRACT,
224         NODE_VECTOR_MATH_AVERAGE,
225         NODE_VECTOR_MATH_DOT_PRODUCT,
226         NODE_VECTOR_MATH_CROSS_PRODUCT,
227         NODE_VECTOR_MATH_NORMALIZE
228 } NodeVectorMath;
229
230 typedef enum NodeVectorTransformType {
231         NODE_VECTOR_TRANSFORM_TYPE_VECTOR,
232         NODE_VECTOR_TRANSFORM_TYPE_POINT
233 } NodeVectorTransformType;
234
235 typedef enum NodeVectorTransformConvertFrom {
236         NODE_VECTOR_TRANSFORM_CONVERT_FROM_WORLD,
237         NODE_VECTOR_TRANSFORM_CONVERT_FROM_OBJECT,
238         NODE_VECTOR_TRANSFORM_CONVERT_FROM_CAMERA
239 } NodeVectorTransformConvertFrom;
240
241 typedef enum NodeVectorTransformConvertTo {
242         NODE_VECTOR_TRANSFORM_CONVERT_TO_WORLD,
243         NODE_VECTOR_TRANSFORM_CONVERT_TO_OBJECT,
244         NODE_VECTOR_TRANSFORM_CONVERT_TO_CAMERA
245 } NodeVectorTransformConvertTo;
246
247 typedef enum NodeConvert {
248         NODE_CONVERT_FV,
249         NODE_CONVERT_FI,
250         NODE_CONVERT_CF,
251         NODE_CONVERT_CI,
252         NODE_CONVERT_VF,
253         NODE_CONVERT_VI,
254         NODE_CONVERT_IF,
255         NODE_CONVERT_IV
256 } NodeConvert;
257
258 typedef enum NodeDistanceMetric {
259         NODE_VORONOI_DISTANCE_SQUARED,
260         NODE_VORONOI_ACTUAL_DISTANCE,
261         NODE_VORONOI_MANHATTAN,
262         NODE_VORONOI_CHEBYCHEV,
263         NODE_VORONOI_MINKOVSKY_H,
264         NODE_VORONOI_MINKOVSKY_4,
265         NODE_VORONOI_MINKOVSKY
266 } NodeDistanceMetric;
267
268 typedef enum NodeNoiseBasis {
269         NODE_NOISE_PERLIN,
270         NODE_NOISE_VORONOI_F1,
271         NODE_NOISE_VORONOI_F2,
272         NODE_NOISE_VORONOI_F3,
273         NODE_NOISE_VORONOI_F4,
274         NODE_NOISE_VORONOI_F2_F1,
275         NODE_NOISE_VORONOI_CRACKLE,
276         NODE_NOISE_CELL_NOISE
277 } NodeNoiseBasis;
278
279 typedef enum NodeWaveBasis {
280         NODE_WAVE_SINE,
281         NODE_WAVE_SAW,
282         NODE_WAVE_TRI
283 } NodeWaveBasis;
284
285 typedef enum NodeMusgraveType {
286         NODE_MUSGRAVE_MULTIFRACTAL,
287         NODE_MUSGRAVE_FBM,
288         NODE_MUSGRAVE_HYBRID_MULTIFRACTAL,
289         NODE_MUSGRAVE_RIDGED_MULTIFRACTAL,
290         NODE_MUSGRAVE_HETERO_TERRAIN
291 } NodeMusgraveType;
292
293 typedef enum NodeWaveType {
294         NODE_WAVE_BANDS,
295         NODE_WAVE_RINGS
296 } NodeWaveType;
297
298 typedef enum NodeGradientType {
299         NODE_BLEND_LINEAR,
300         NODE_BLEND_QUADRATIC,
301         NODE_BLEND_EASING,
302         NODE_BLEND_DIAGONAL,
303         NODE_BLEND_RADIAL,
304         NODE_BLEND_QUADRATIC_SPHERE,
305         NODE_BLEND_SPHERICAL
306 } NodeGradientType;
307
308 typedef enum NodeVoronoiColoring {
309         NODE_VORONOI_INTENSITY,
310         NODE_VORONOI_CELLS
311 } NodeVoronoiColoring;
312
313 typedef enum NodeBlendWeightType {
314         NODE_LAYER_WEIGHT_FRESNEL,
315         NODE_LAYER_WEIGHT_FACING
316 } NodeBlendWeightType;
317
318 typedef enum NodeTangentDirectionType {
319         NODE_TANGENT_RADIAL,
320         NODE_TANGENT_UVMAP
321 } NodeTangentDirectionType;
322
323 typedef enum NodeTangentAxis {
324         NODE_TANGENT_AXIS_X,
325         NODE_TANGENT_AXIS_Y,
326         NODE_TANGENT_AXIS_Z
327 } NodeTangentAxis;
328
329 typedef enum NodeNormalMapSpace {
330         NODE_NORMAL_MAP_TANGENT,
331         NODE_NORMAL_MAP_OBJECT,
332         NODE_NORMAL_MAP_WORLD,
333         NODE_NORMAL_MAP_BLENDER_OBJECT,
334         NODE_NORMAL_MAP_BLENDER_WORLD,
335 } NodeNormalMapSpace;
336
337 typedef enum ShaderType {
338         SHADER_TYPE_SURFACE,
339         SHADER_TYPE_VOLUME,
340         SHADER_TYPE_DISPLACEMENT
341 } ShaderType;
342
343 /* Closure */
344
345 typedef enum ClosureType {
346         CLOSURE_BSDF_ID,
347         
348         /* Diffuse */
349         CLOSURE_BSDF_DIFFUSE_ID,
350         CLOSURE_BSDF_OREN_NAYAR_ID,
351         CLOSURE_BSDF_WESTIN_SHEEN_ID,
352         CLOSURE_BSDF_DIFFUSE_RAMP_ID,
353         CLOSURE_BSDF_DIFFUSE_TOON_ID,
354         
355         /* Glossy */
356         CLOSURE_BSDF_GLOSSY_ID,
357         CLOSURE_BSDF_REFLECTION_ID,
358         CLOSURE_BSDF_MICROFACET_GGX_ID,
359         CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
360         CLOSURE_BSDF_WARD_ID,
361         CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
362         CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
363         CLOSURE_BSDF_PHONG_RAMP_ID,
364         CLOSURE_BSDF_GLOSSY_TOON_ID,
365         
366         /* Transmission */
367         CLOSURE_BSDF_TRANSMISSION_ID,
368         CLOSURE_BSDF_TRANSLUCENT_ID,
369         CLOSURE_BSDF_REFRACTION_ID,
370         CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
371         CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
372         CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID,
373         CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID,
374         CLOSURE_BSDF_SHARP_GLASS_ID,
375         
376         /* Transparent */
377         CLOSURE_BSDF_TRANSPARENT_ID,
378
379         /* Other */
380         CLOSURE_BSSRDF_ID,
381         CLOSURE_EMISSION_ID,
382         CLOSURE_DEBUG_ID,
383         CLOSURE_BACKGROUND_ID,
384         CLOSURE_HOLDOUT_ID,
385         CLOSURE_AMBIENT_OCCLUSION_ID,
386
387         /* Volume */
388         CLOSURE_VOLUME_ID,
389         CLOSURE_VOLUME_TRANSPARENT_ID,
390         CLOSURE_VOLUME_ISOTROPIC_ID,
391
392         NBUILTIN_CLOSURES
393 } ClosureType;
394
395 /* watch this, being lazy with memory usage */
396 #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
397 #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID)
398 #define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_GLOSSY_TOON_ID)
399 #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_SHARP_GLASS_ID)
400 #define CLOSURE_IS_BSSRDF(type) (type == CLOSURE_BSSRDF_ID)
401 #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
402 #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
403 #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
404 #define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
405 #define CLOSURE_IS_AMBIENT_OCCLUSION(type) (type == CLOSURE_AMBIENT_OCCLUSION_ID)
406
407 CCL_NAMESPACE_END
408
409 #endif /*  __SVM_TYPES_H__ */
410