Cycles: add Transparent Depth output to Light Path node.
[blender-staging.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_ADD_CLOSURE,
76         NODE_EMISSION_SET_WEIGHT_TOTAL,
77         NODE_ATTR_BUMP_DX,
78         NODE_ATTR_BUMP_DY,
79         NODE_TEX_ENVIRONMENT,
80         NODE_CLOSURE_HOLDOUT,
81         NODE_LAYER_WEIGHT,
82         NODE_CLOSURE_VOLUME,
83         NODE_SEPARATE_RGB,
84         NODE_COMBINE_RGB,
85         NODE_SEPARATE_HSV,
86         NODE_COMBINE_HSV,
87         NODE_HSV,
88         NODE_CAMERA,
89         NODE_INVERT,
90         NODE_NORMAL,
91         NODE_GAMMA,
92         NODE_TEX_CHECKER,
93         NODE_BRIGHTCONTRAST,
94         NODE_RGB_RAMP,
95         NODE_RGB_CURVES,
96         NODE_VECTOR_CURVES,
97         NODE_MIN_MAX,
98         NODE_LIGHT_FALLOFF,
99         NODE_OBJECT_INFO,
100         NODE_PARTICLE_INFO,
101         NODE_TEX_BRICK,
102         NODE_CLOSURE_SET_NORMAL,
103         NODE_CLOSURE_AMBIENT_OCCLUSION,
104         NODE_TANGENT,
105         NODE_NORMAL_MAP,
106         NODE_HAIR_INFO,
107         NODE_UVMAP
108 } NodeType;
109
110 typedef enum NodeAttributeType {
111         NODE_ATTR_FLOAT = 0,
112         NODE_ATTR_FLOAT3,
113         NODE_ATTR_MATRIX
114 } NodeAttributeType;
115
116 typedef enum NodeGeometry {
117         NODE_GEOM_P = 0,
118         NODE_GEOM_N,
119         NODE_GEOM_T,
120         NODE_GEOM_I,
121         NODE_GEOM_Ng,
122         NODE_GEOM_uv
123 } NodeGeometry;
124
125 typedef enum NodeObjectInfo {
126         NODE_INFO_OB_LOCATION,
127         NODE_INFO_OB_INDEX,
128         NODE_INFO_MAT_INDEX,
129         NODE_INFO_OB_RANDOM
130 } NodeObjectInfo;
131
132 typedef enum NodeParticleInfo {
133         NODE_INFO_PAR_INDEX,
134         NODE_INFO_PAR_AGE,
135         NODE_INFO_PAR_LIFETIME,
136         NODE_INFO_PAR_LOCATION,
137         NODE_INFO_PAR_ROTATION,
138         NODE_INFO_PAR_SIZE,
139         NODE_INFO_PAR_VELOCITY,
140         NODE_INFO_PAR_ANGULAR_VELOCITY
141 } NodeParticleInfo;
142
143 typedef enum NodeHairInfo {
144         NODE_INFO_CURVE_IS_STRAND,
145         NODE_INFO_CURVE_INTERCEPT,
146         NODE_INFO_CURVE_THICKNESS,
147         /*fade for minimum hair width transpency*/
148         /*NODE_INFO_CURVE_FADE,*/
149         NODE_INFO_CURVE_TANGENT_NORMAL
150 } NodeHairInfo;
151
152 typedef enum NodeLightPath {
153         NODE_LP_camera = 0,
154         NODE_LP_shadow,
155         NODE_LP_diffuse,
156         NODE_LP_glossy,
157         NODE_LP_singular,
158         NODE_LP_reflection,
159         NODE_LP_transmission,
160         NODE_LP_volume_scatter,
161         NODE_LP_backfacing,
162         NODE_LP_ray_length,
163         NODE_LP_ray_depth,
164         NODE_LP_ray_transparent
165 } NodeLightPath;
166
167 typedef enum NodeLightFalloff {
168         NODE_LIGHT_FALLOFF_QUADRATIC,
169         NODE_LIGHT_FALLOFF_LINEAR,
170         NODE_LIGHT_FALLOFF_CONSTANT
171 } NodeLightFalloff;
172
173 typedef enum NodeTexCoord {
174         NODE_TEXCO_NORMAL,
175         NODE_TEXCO_OBJECT,
176         NODE_TEXCO_CAMERA,
177         NODE_TEXCO_WINDOW,
178         NODE_TEXCO_REFLECTION,
179         NODE_TEXCO_DUPLI_GENERATED,
180         NODE_TEXCO_DUPLI_UV,
181         NODE_TEXCO_VOLUME_GENERATED
182 } NodeTexCoord;
183
184 typedef enum NodeMix {
185         NODE_MIX_BLEND = 0,
186         NODE_MIX_ADD,
187         NODE_MIX_MUL,
188         NODE_MIX_SUB,
189         NODE_MIX_SCREEN,
190         NODE_MIX_DIV,
191         NODE_MIX_DIFF,
192         NODE_MIX_DARK,
193         NODE_MIX_LIGHT,
194         NODE_MIX_OVERLAY,
195         NODE_MIX_DODGE,
196         NODE_MIX_BURN,
197         NODE_MIX_HUE,
198         NODE_MIX_SAT,
199         NODE_MIX_VAL,
200         NODE_MIX_COLOR,
201         NODE_MIX_SOFT,
202         NODE_MIX_LINEAR,
203         NODE_MIX_CLAMP /* used for the clamp UI option */
204 } NodeMix;
205
206 typedef enum NodeMath {
207         NODE_MATH_ADD,
208         NODE_MATH_SUBTRACT,
209         NODE_MATH_MULTIPLY,
210         NODE_MATH_DIVIDE,
211         NODE_MATH_SINE,
212         NODE_MATH_COSINE,
213         NODE_MATH_TANGENT,
214         NODE_MATH_ARCSINE,
215         NODE_MATH_ARCCOSINE,
216         NODE_MATH_ARCTANGENT,
217         NODE_MATH_POWER,
218         NODE_MATH_LOGARITHM,
219         NODE_MATH_MINIMUM,
220         NODE_MATH_MAXIMUM,
221         NODE_MATH_ROUND,
222         NODE_MATH_LESS_THAN,
223         NODE_MATH_GREATER_THAN,
224         NODE_MATH_MODULO,
225         NODE_MATH_CLAMP /* used for the clamp UI option */
226 } NodeMath;
227
228 typedef enum NodeVectorMath {
229         NODE_VECTOR_MATH_ADD,
230         NODE_VECTOR_MATH_SUBTRACT,
231         NODE_VECTOR_MATH_AVERAGE,
232         NODE_VECTOR_MATH_DOT_PRODUCT,
233         NODE_VECTOR_MATH_CROSS_PRODUCT,
234         NODE_VECTOR_MATH_NORMALIZE
235 } NodeVectorMath;
236
237 typedef enum NodeVectorTransformType {
238         NODE_VECTOR_TRANSFORM_TYPE_VECTOR,
239         NODE_VECTOR_TRANSFORM_TYPE_POINT,
240         NODE_VECTOR_TRANSFORM_TYPE_NORMAL
241 } NodeVectorTransformType;
242
243 typedef enum NodeVectorTransformConvertSpace {
244         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD,
245         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT,
246         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA
247 } NodeVectorTransformConvertSpace;
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 NodeMusgraveType {
282         NODE_MUSGRAVE_MULTIFRACTAL,
283         NODE_MUSGRAVE_FBM,
284         NODE_MUSGRAVE_HYBRID_MULTIFRACTAL,
285         NODE_MUSGRAVE_RIDGED_MULTIFRACTAL,
286         NODE_MUSGRAVE_HETERO_TERRAIN
287 } NodeMusgraveType;
288
289 typedef enum NodeWaveType {
290         NODE_WAVE_BANDS,
291         NODE_WAVE_RINGS
292 } NodeWaveType;
293
294 typedef enum NodeSkyType {
295         NODE_SKY_OLD,
296         NODE_SKY_NEW
297 } NodeSkyType;
298
299 typedef enum NodeGradientType {
300         NODE_BLEND_LINEAR,
301         NODE_BLEND_QUADRATIC,
302         NODE_BLEND_EASING,
303         NODE_BLEND_DIAGONAL,
304         NODE_BLEND_RADIAL,
305         NODE_BLEND_QUADRATIC_SPHERE,
306         NODE_BLEND_SPHERICAL
307 } NodeGradientType;
308
309 typedef enum NodeVoronoiColoring {
310         NODE_VORONOI_INTENSITY,
311         NODE_VORONOI_CELLS
312 } NodeVoronoiColoring;
313
314 typedef enum NodeBlendWeightType {
315         NODE_LAYER_WEIGHT_FRESNEL,
316         NODE_LAYER_WEIGHT_FACING
317 } NodeBlendWeightType;
318
319 typedef enum NodeTangentDirectionType {
320         NODE_TANGENT_RADIAL,
321         NODE_TANGENT_UVMAP
322 } NodeTangentDirectionType;
323
324 typedef enum NodeTangentAxis {
325         NODE_TANGENT_AXIS_X,
326         NODE_TANGENT_AXIS_Y,
327         NODE_TANGENT_AXIS_Z
328 } NodeTangentAxis;
329
330 typedef enum NodeNormalMapSpace {
331         NODE_NORMAL_MAP_TANGENT,
332         NODE_NORMAL_MAP_OBJECT,
333         NODE_NORMAL_MAP_WORLD,
334         NODE_NORMAL_MAP_BLENDER_OBJECT,
335         NODE_NORMAL_MAP_BLENDER_WORLD,
336 } NodeNormalMapSpace;
337
338 typedef enum ShaderType {
339         SHADER_TYPE_SURFACE,
340         SHADER_TYPE_VOLUME,
341         SHADER_TYPE_DISPLACEMENT
342 } ShaderType;
343
344 /* Closure */
345
346 typedef enum ClosureType {
347         CLOSURE_BSDF_ID,
348
349         /* Diffuse */
350         CLOSURE_BSDF_DIFFUSE_ID,
351         CLOSURE_BSDF_OREN_NAYAR_ID,
352         CLOSURE_BSDF_WESTIN_SHEEN_ID,
353         CLOSURE_BSDF_DIFFUSE_RAMP_ID,
354         CLOSURE_BSDF_DIFFUSE_TOON_ID,
355
356         /* Glossy */
357         CLOSURE_BSDF_GLOSSY_ID,
358         CLOSURE_BSDF_REFLECTION_ID,
359         CLOSURE_BSDF_MICROFACET_GGX_ID,
360         CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
361         CLOSURE_BSDF_WARD_ID,
362         CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
363         CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
364         CLOSURE_BSDF_PHONG_RAMP_ID,
365         CLOSURE_BSDF_GLOSSY_TOON_ID,
366         CLOSURE_BSDF_HAIR_REFLECTION_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         CLOSURE_BSDF_HAIR_TRANSMISSION_ID,
378
379         /* Special cases */
380         CLOSURE_BSDF_BSSRDF_ID,
381         CLOSURE_BSDF_TRANSPARENT_ID,
382
383         /* BSSRDF */
384         CLOSURE_BSSRDF_CUBIC_ID,
385         CLOSURE_BSSRDF_GAUSSIAN_ID,
386
387         /* Other */
388         CLOSURE_EMISSION_ID,
389         CLOSURE_BACKGROUND_ID,
390         CLOSURE_HOLDOUT_ID,
391         CLOSURE_AMBIENT_OCCLUSION_ID,
392
393         /* Volume */
394         CLOSURE_VOLUME_ID,
395         CLOSURE_VOLUME_ABSORPTION_ID,
396         CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID,
397
398         NBUILTIN_CLOSURES
399 } ClosureType;
400
401 /* watch this, being lazy with memory usage */
402 #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
403 #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID)
404 #define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID)
405 #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_HAIR_TRANSMISSION_ID)
406 #define CLOSURE_IS_BSDF_BSSRDF(type) (type == CLOSURE_BSDF_BSSRDF_ID)
407 #define CLOSURE_IS_BSDF_ANISOTROPIC(type) (type == CLOSURE_BSDF_WARD_ID)
408 #define CLOSURE_IS_BSDF_OR_BSSRDF(type) (type <= CLOSURE_BSSRDF_GAUSSIAN_ID)
409 #define CLOSURE_IS_BSSRDF(type) (type >= CLOSURE_BSSRDF_CUBIC_ID && type <= CLOSURE_BSSRDF_GAUSSIAN_ID)
410 #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID)
411 #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
412 #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
413 #define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
414 #define CLOSURE_IS_AMBIENT_OCCLUSION(type) (type == CLOSURE_AMBIENT_OCCLUSION_ID)
415 #define CLOSURE_IS_PHASE(type) (type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID)
416
417 #define CLOSURE_WEIGHT_CUTOFF 1e-5f
418
419 CCL_NAMESPACE_END
420
421 #endif /*  __SVM_TYPES_H__ */
422