a8d0da6ff393fafddeb23949dc4479f7992da5be
[blender.git] / intern / cycles / kernel / svm / svm_types.h
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __SVM_TYPES_H__
18 #define __SVM_TYPES_H__
19
20 CCL_NAMESPACE_BEGIN
21
22 /* Stack */
23
24 /* SVM stack has a fixed size */
25 #define SVM_STACK_SIZE 255
26 /* SVM stack offsets with this value indicate that it's not on the stack */
27 #define SVM_STACK_INVALID 255 
28
29 /* Nodes */
30
31 typedef enum NodeType {
32         NODE_END = 0,
33         NODE_CLOSURE_BSDF,
34         NODE_CLOSURE_EMISSION,
35         NODE_CLOSURE_BACKGROUND,
36         NODE_CLOSURE_SET_WEIGHT,
37         NODE_CLOSURE_WEIGHT,
38         NODE_MIX_CLOSURE,
39         NODE_JUMP_IF_ZERO,
40         NODE_JUMP_IF_ONE,
41         NODE_TEX_IMAGE,
42         NODE_TEX_IMAGE_BOX,
43         NODE_TEX_SKY,
44         NODE_GEOMETRY,
45         NODE_GEOMETRY_DUPLI,
46         NODE_LIGHT_PATH,
47         NODE_VALUE_F,
48         NODE_VALUE_V,
49         NODE_MIX,
50         NODE_ATTR,
51         NODE_CONVERT,
52         NODE_FRESNEL,
53         NODE_WIREFRAME,
54         NODE_WAVELENGTH,
55         NODE_BLACKBODY,
56         NODE_EMISSION_WEIGHT,
57         NODE_TEX_GRADIENT,
58         NODE_TEX_VORONOI,
59         NODE_TEX_MUSGRAVE,
60         NODE_TEX_WAVE,
61         NODE_TEX_MAGIC,
62         NODE_TEX_NOISE,
63         NODE_SHADER_JUMP,
64         NODE_SET_DISPLACEMENT,
65         NODE_GEOMETRY_BUMP_DX,
66         NODE_GEOMETRY_BUMP_DY,
67         NODE_SET_BUMP,
68         NODE_MATH,
69         NODE_VECTOR_MATH,
70         NODE_VECTOR_TRANSFORM,
71         NODE_MAPPING,
72         NODE_TEX_COORD,
73         NODE_TEX_COORD_BUMP_DX,
74         NODE_TEX_COORD_BUMP_DY,
75         NODE_ATTR_BUMP_DX,
76         NODE_ATTR_BUMP_DY,
77         NODE_TEX_ENVIRONMENT,
78         NODE_CLOSURE_HOLDOUT,
79         NODE_LAYER_WEIGHT,
80         NODE_CLOSURE_VOLUME,
81         NODE_SEPARATE_VECTOR,
82         NODE_COMBINE_VECTOR,
83         NODE_SEPARATE_HSV,
84         NODE_COMBINE_HSV,
85         NODE_HSV,
86         NODE_CAMERA,
87         NODE_INVERT,
88         NODE_NORMAL,
89         NODE_GAMMA,
90         NODE_TEX_CHECKER,
91         NODE_BRIGHTCONTRAST,
92         NODE_RGB_RAMP,
93         NODE_RGB_CURVES,
94         NODE_VECTOR_CURVES,
95         NODE_MIN_MAX,
96         NODE_LIGHT_FALLOFF,
97         NODE_OBJECT_INFO,
98         NODE_PARTICLE_INFO,
99         NODE_TEX_BRICK,
100         NODE_CLOSURE_SET_NORMAL,
101         NODE_CLOSURE_AMBIENT_OCCLUSION,
102         NODE_TANGENT,
103         NODE_NORMAL_MAP,
104         NODE_HAIR_INFO,
105         NODE_UVMAP
106 } NodeType;
107
108 typedef enum NodeAttributeType {
109         NODE_ATTR_FLOAT = 0,
110         NODE_ATTR_FLOAT3,
111         NODE_ATTR_MATRIX
112 } NodeAttributeType;
113
114 typedef enum NodeGeometry {
115         NODE_GEOM_P = 0,
116         NODE_GEOM_N,
117         NODE_GEOM_T,
118         NODE_GEOM_I,
119         NODE_GEOM_Ng,
120         NODE_GEOM_uv
121 } NodeGeometry;
122
123 typedef enum NodeObjectInfo {
124         NODE_INFO_OB_LOCATION,
125         NODE_INFO_OB_INDEX,
126         NODE_INFO_MAT_INDEX,
127         NODE_INFO_OB_RANDOM
128 } NodeObjectInfo;
129
130 typedef enum NodeParticleInfo {
131         NODE_INFO_PAR_INDEX,
132         NODE_INFO_PAR_AGE,
133         NODE_INFO_PAR_LIFETIME,
134         NODE_INFO_PAR_LOCATION,
135         NODE_INFO_PAR_ROTATION,
136         NODE_INFO_PAR_SIZE,
137         NODE_INFO_PAR_VELOCITY,
138         NODE_INFO_PAR_ANGULAR_VELOCITY
139 } NodeParticleInfo;
140
141 typedef enum NodeHairInfo {
142         NODE_INFO_CURVE_IS_STRAND,
143         NODE_INFO_CURVE_INTERCEPT,
144         NODE_INFO_CURVE_THICKNESS,
145         /*fade for minimum hair width transpency*/
146         /*NODE_INFO_CURVE_FADE,*/
147         NODE_INFO_CURVE_TANGENT_NORMAL
148 } NodeHairInfo;
149
150 typedef enum NodeLightPath {
151         NODE_LP_camera = 0,
152         NODE_LP_shadow,
153         NODE_LP_diffuse,
154         NODE_LP_glossy,
155         NODE_LP_singular,
156         NODE_LP_reflection,
157         NODE_LP_transmission,
158         NODE_LP_volume_scatter,
159         NODE_LP_backfacing,
160         NODE_LP_ray_length,
161         NODE_LP_ray_depth,
162         NODE_LP_ray_transparent
163 } NodeLightPath;
164
165 typedef enum NodeLightFalloff {
166         NODE_LIGHT_FALLOFF_QUADRATIC,
167         NODE_LIGHT_FALLOFF_LINEAR,
168         NODE_LIGHT_FALLOFF_CONSTANT
169 } NodeLightFalloff;
170
171 typedef enum NodeTexCoord {
172         NODE_TEXCO_NORMAL,
173         NODE_TEXCO_OBJECT,
174         NODE_TEXCO_CAMERA,
175         NODE_TEXCO_WINDOW,
176         NODE_TEXCO_REFLECTION,
177         NODE_TEXCO_DUPLI_GENERATED,
178         NODE_TEXCO_DUPLI_UV,
179         NODE_TEXCO_VOLUME_GENERATED
180 } NodeTexCoord;
181
182 typedef enum NodeMix {
183         NODE_MIX_BLEND = 0,
184         NODE_MIX_ADD,
185         NODE_MIX_MUL,
186         NODE_MIX_SUB,
187         NODE_MIX_SCREEN,
188         NODE_MIX_DIV,
189         NODE_MIX_DIFF,
190         NODE_MIX_DARK,
191         NODE_MIX_LIGHT,
192         NODE_MIX_OVERLAY,
193         NODE_MIX_DODGE,
194         NODE_MIX_BURN,
195         NODE_MIX_HUE,
196         NODE_MIX_SAT,
197         NODE_MIX_VAL,
198         NODE_MIX_COLOR,
199         NODE_MIX_SOFT,
200         NODE_MIX_LINEAR,
201         NODE_MIX_CLAMP /* used for the clamp UI option */
202 } NodeMix;
203
204 typedef enum NodeMath {
205         NODE_MATH_ADD,
206         NODE_MATH_SUBTRACT,
207         NODE_MATH_MULTIPLY,
208         NODE_MATH_DIVIDE,
209         NODE_MATH_SINE,
210         NODE_MATH_COSINE,
211         NODE_MATH_TANGENT,
212         NODE_MATH_ARCSINE,
213         NODE_MATH_ARCCOSINE,
214         NODE_MATH_ARCTANGENT,
215         NODE_MATH_POWER,
216         NODE_MATH_LOGARITHM,
217         NODE_MATH_MINIMUM,
218         NODE_MATH_MAXIMUM,
219         NODE_MATH_ROUND,
220         NODE_MATH_LESS_THAN,
221         NODE_MATH_GREATER_THAN,
222         NODE_MATH_MODULO,
223     NODE_MATH_ABSOLUTE,
224         NODE_MATH_CLAMP /* used for the clamp UI option */
225 } NodeMath;
226
227 typedef enum NodeVectorMath {
228         NODE_VECTOR_MATH_ADD,
229         NODE_VECTOR_MATH_SUBTRACT,
230         NODE_VECTOR_MATH_AVERAGE,
231         NODE_VECTOR_MATH_DOT_PRODUCT,
232         NODE_VECTOR_MATH_CROSS_PRODUCT,
233         NODE_VECTOR_MATH_NORMALIZE
234 } NodeVectorMath;
235
236 typedef enum NodeVectorTransformType {
237         NODE_VECTOR_TRANSFORM_TYPE_VECTOR,
238         NODE_VECTOR_TRANSFORM_TYPE_POINT,
239         NODE_VECTOR_TRANSFORM_TYPE_NORMAL
240 } NodeVectorTransformType;
241
242 typedef enum NodeVectorTransformConvertSpace {
243         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD,
244         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT,
245         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA
246 } NodeVectorTransformConvertSpace;
247
248 typedef enum NodeConvert {
249         NODE_CONVERT_FV,
250         NODE_CONVERT_FI,
251         NODE_CONVERT_CF,
252         NODE_CONVERT_CI,
253         NODE_CONVERT_VF,
254         NODE_CONVERT_VI,
255         NODE_CONVERT_IF,
256         NODE_CONVERT_IV
257 } NodeConvert;
258
259 typedef enum NodeDistanceMetric {
260         NODE_VORONOI_DISTANCE_SQUARED,
261         NODE_VORONOI_ACTUAL_DISTANCE,
262         NODE_VORONOI_MANHATTAN,
263         NODE_VORONOI_CHEBYCHEV,
264         NODE_VORONOI_MINKOVSKY_H,
265         NODE_VORONOI_MINKOVSKY_4,
266         NODE_VORONOI_MINKOVSKY
267 } NodeDistanceMetric;
268
269 typedef enum NodeNoiseBasis {
270         NODE_NOISE_PERLIN,
271         NODE_NOISE_VORONOI_F1,
272         NODE_NOISE_VORONOI_F2,
273         NODE_NOISE_VORONOI_F3,
274         NODE_NOISE_VORONOI_F4,
275         NODE_NOISE_VORONOI_F2_F1,
276         NODE_NOISE_VORONOI_CRACKLE,
277         NODE_NOISE_CELL_NOISE
278 } NodeNoiseBasis;
279
280 typedef enum NodeMusgraveType {
281         NODE_MUSGRAVE_MULTIFRACTAL,
282         NODE_MUSGRAVE_FBM,
283         NODE_MUSGRAVE_HYBRID_MULTIFRACTAL,
284         NODE_MUSGRAVE_RIDGED_MULTIFRACTAL,
285         NODE_MUSGRAVE_HETERO_TERRAIN
286 } NodeMusgraveType;
287
288 typedef enum NodeWaveType {
289         NODE_WAVE_BANDS,
290         NODE_WAVE_RINGS
291 } NodeWaveType;
292
293 typedef enum NodeSkyType {
294         NODE_SKY_OLD,
295         NODE_SKY_NEW
296 } NodeSkyType;
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 NodeImageProjection {
338         NODE_IMAGE_PROJ_FLAT   = 0,
339         NODE_IMAGE_PROJ_BOX    = 1,
340         NODE_IMAGE_PROJ_SPHERE = 2,
341         NODE_IMAGE_PROJ_TUBE   = 3,
342 } NodeImageProjection;
343
344 typedef enum ShaderType {
345         SHADER_TYPE_SURFACE,
346         SHADER_TYPE_VOLUME,
347         SHADER_TYPE_DISPLACEMENT
348 } ShaderType;
349
350 /* Closure */
351
352 typedef enum ClosureType {
353         CLOSURE_BSDF_ID,
354
355         /* Diffuse */
356         CLOSURE_BSDF_DIFFUSE_ID,
357         CLOSURE_BSDF_OREN_NAYAR_ID,
358         CLOSURE_BSDF_DIFFUSE_RAMP_ID,
359         CLOSURE_BSDF_DIFFUSE_TOON_ID,
360
361         /* Glossy */
362         CLOSURE_BSDF_GLOSSY_ID,
363         CLOSURE_BSDF_REFLECTION_ID,
364         CLOSURE_BSDF_MICROFACET_GGX_ID,
365         CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
366         CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID,
367         CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID,
368         CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID,
369         CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID,
370         CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
371         CLOSURE_BSDF_PHONG_RAMP_ID,
372         CLOSURE_BSDF_GLOSSY_TOON_ID,
373         CLOSURE_BSDF_HAIR_REFLECTION_ID,
374
375         /* Transmission */
376         CLOSURE_BSDF_TRANSMISSION_ID,
377         CLOSURE_BSDF_TRANSLUCENT_ID,
378         CLOSURE_BSDF_REFRACTION_ID,
379         CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
380         CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
381         CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID,
382         CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID,
383         CLOSURE_BSDF_SHARP_GLASS_ID,
384         CLOSURE_BSDF_HAIR_TRANSMISSION_ID,
385
386         /* Special cases */
387         CLOSURE_BSDF_BSSRDF_ID,
388         CLOSURE_BSDF_TRANSPARENT_ID,
389
390         /* BSSRDF */
391         CLOSURE_BSSRDF_CUBIC_ID,
392         CLOSURE_BSSRDF_GAUSSIAN_ID,
393
394         /* Other */
395         CLOSURE_EMISSION_ID,
396         CLOSURE_BACKGROUND_ID,
397         CLOSURE_HOLDOUT_ID,
398         CLOSURE_AMBIENT_OCCLUSION_ID,
399
400         /* Volume */
401         CLOSURE_VOLUME_ID,
402         CLOSURE_VOLUME_ABSORPTION_ID,
403         CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID,
404
405         NBUILTIN_CLOSURES
406 } ClosureType;
407
408 /* watch this, being lazy with memory usage */
409 #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
410 #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID)
411 #define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID)
412 #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_HAIR_TRANSMISSION_ID)
413 #define CLOSURE_IS_BSDF_BSSRDF(type) (type == CLOSURE_BSDF_BSSRDF_ID)
414 #define CLOSURE_IS_BSDF_ANISOTROPIC(type) (type >= CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID && type <= CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID)
415 #define CLOSURE_IS_BSDF_OR_BSSRDF(type) (type <= CLOSURE_BSSRDF_GAUSSIAN_ID)
416 #define CLOSURE_IS_BSSRDF(type) (type >= CLOSURE_BSSRDF_CUBIC_ID && type <= CLOSURE_BSSRDF_GAUSSIAN_ID)
417 #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID)
418 #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
419 #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
420 #define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
421 #define CLOSURE_IS_AMBIENT_OCCLUSION(type) (type == CLOSURE_AMBIENT_OCCLUSION_ID)
422 #define CLOSURE_IS_PHASE(type) (type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID)
423
424 #define CLOSURE_WEIGHT_CUTOFF 1e-5f
425
426 CCL_NAMESPACE_END
427
428 #endif /*  __SVM_TYPES_H__ */
429