Cycles Volume Render: work on nodes and closures.
[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,
40         NODE_TEX_IMAGE,
41         NODE_TEX_IMAGE_BOX,
42         NODE_TEX_SKY,
43         NODE_GEOMETRY,
44         NODE_GEOMETRY_DUPLI,
45         NODE_LIGHT_PATH,
46         NODE_VALUE_F,
47         NODE_VALUE_V,
48         NODE_MIX,
49         NODE_ATTR,
50         NODE_CONVERT,
51         NODE_FRESNEL,
52         NODE_WIREFRAME,
53         NODE_WAVELENGTH,
54         NODE_BLACKBODY,
55         NODE_EMISSION_WEIGHT,
56         NODE_TEX_GRADIENT,
57         NODE_TEX_VORONOI,
58         NODE_TEX_MUSGRAVE,
59         NODE_TEX_WAVE,
60         NODE_TEX_MAGIC,
61         NODE_TEX_NOISE,
62         NODE_SHADER_JUMP,
63         NODE_SET_DISPLACEMENT,
64         NODE_GEOMETRY_BUMP_DX,
65         NODE_GEOMETRY_BUMP_DY,
66         NODE_SET_BUMP,
67         NODE_MATH,
68         NODE_VECTOR_MATH,
69         NODE_VECTOR_TRANSFORM,
70         NODE_MAPPING,
71         NODE_TEX_COORD,
72         NODE_TEX_COORD_BUMP_DX,
73         NODE_TEX_COORD_BUMP_DY,
74         NODE_ADD_CLOSURE,
75         NODE_EMISSION_SET_WEIGHT_TOTAL,
76         NODE_ATTR_BUMP_DX,
77         NODE_ATTR_BUMP_DY,
78         NODE_TEX_ENVIRONMENT,
79         NODE_CLOSURE_HOLDOUT,
80         NODE_LAYER_WEIGHT,
81         NODE_CLOSURE_VOLUME,
82         NODE_SEPARATE_RGB,
83         NODE_COMBINE_RGB,
84         NODE_SEPARATE_HSV,
85         NODE_COMBINE_HSV,
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_volume_scatter,
158         NODE_LP_backfacing,
159         NODE_LP_ray_length,
160         NODE_LP_ray_depth
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         NODE_VECTOR_TRANSFORM_TYPE_NORMAL
236 } NodeVectorTransformType;
237
238 typedef enum NodeVectorTransformConvertSpace {
239         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD,
240         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT,
241         NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA
242 } NodeVectorTransformConvertSpace;
243
244 typedef enum NodeConvert {
245         NODE_CONVERT_FV,
246         NODE_CONVERT_FI,
247         NODE_CONVERT_CF,
248         NODE_CONVERT_CI,
249         NODE_CONVERT_VF,
250         NODE_CONVERT_VI,
251         NODE_CONVERT_IF,
252         NODE_CONVERT_IV
253 } NodeConvert;
254
255 typedef enum NodeDistanceMetric {
256         NODE_VORONOI_DISTANCE_SQUARED,
257         NODE_VORONOI_ACTUAL_DISTANCE,
258         NODE_VORONOI_MANHATTAN,
259         NODE_VORONOI_CHEBYCHEV,
260         NODE_VORONOI_MINKOVSKY_H,
261         NODE_VORONOI_MINKOVSKY_4,
262         NODE_VORONOI_MINKOVSKY
263 } NodeDistanceMetric;
264
265 typedef enum NodeNoiseBasis {
266         NODE_NOISE_PERLIN,
267         NODE_NOISE_VORONOI_F1,
268         NODE_NOISE_VORONOI_F2,
269         NODE_NOISE_VORONOI_F3,
270         NODE_NOISE_VORONOI_F4,
271         NODE_NOISE_VORONOI_F2_F1,
272         NODE_NOISE_VORONOI_CRACKLE,
273         NODE_NOISE_CELL_NOISE
274 } NodeNoiseBasis;
275
276 typedef enum NodeMusgraveType {
277         NODE_MUSGRAVE_MULTIFRACTAL,
278         NODE_MUSGRAVE_FBM,
279         NODE_MUSGRAVE_HYBRID_MULTIFRACTAL,
280         NODE_MUSGRAVE_RIDGED_MULTIFRACTAL,
281         NODE_MUSGRAVE_HETERO_TERRAIN
282 } NodeMusgraveType;
283
284 typedef enum NodeWaveType {
285         NODE_WAVE_BANDS,
286         NODE_WAVE_RINGS
287 } NodeWaveType;
288
289 typedef enum NodeSkyType {
290         NODE_SKY_OLD,
291         NODE_SKY_NEW
292 } NodeSkyType;
293
294 typedef enum NodeGradientType {
295         NODE_BLEND_LINEAR,
296         NODE_BLEND_QUADRATIC,
297         NODE_BLEND_EASING,
298         NODE_BLEND_DIAGONAL,
299         NODE_BLEND_RADIAL,
300         NODE_BLEND_QUADRATIC_SPHERE,
301         NODE_BLEND_SPHERICAL
302 } NodeGradientType;
303
304 typedef enum NodeVoronoiColoring {
305         NODE_VORONOI_INTENSITY,
306         NODE_VORONOI_CELLS
307 } NodeVoronoiColoring;
308
309 typedef enum NodeBlendWeightType {
310         NODE_LAYER_WEIGHT_FRESNEL,
311         NODE_LAYER_WEIGHT_FACING
312 } NodeBlendWeightType;
313
314 typedef enum NodeTangentDirectionType {
315         NODE_TANGENT_RADIAL,
316         NODE_TANGENT_UVMAP
317 } NodeTangentDirectionType;
318
319 typedef enum NodeTangentAxis {
320         NODE_TANGENT_AXIS_X,
321         NODE_TANGENT_AXIS_Y,
322         NODE_TANGENT_AXIS_Z
323 } NodeTangentAxis;
324
325 typedef enum NodeNormalMapSpace {
326         NODE_NORMAL_MAP_TANGENT,
327         NODE_NORMAL_MAP_OBJECT,
328         NODE_NORMAL_MAP_WORLD,
329         NODE_NORMAL_MAP_BLENDER_OBJECT,
330         NODE_NORMAL_MAP_BLENDER_WORLD,
331 } NodeNormalMapSpace;
332
333 typedef enum ShaderType {
334         SHADER_TYPE_SURFACE,
335         SHADER_TYPE_VOLUME,
336         SHADER_TYPE_DISPLACEMENT
337 } ShaderType;
338
339 /* Closure */
340
341 typedef enum ClosureType {
342         CLOSURE_BSDF_ID,
343         
344         /* Diffuse */
345         CLOSURE_BSDF_DIFFUSE_ID,
346         CLOSURE_BSDF_OREN_NAYAR_ID,
347         CLOSURE_BSDF_WESTIN_SHEEN_ID,
348         CLOSURE_BSDF_DIFFUSE_RAMP_ID,
349         CLOSURE_BSDF_DIFFUSE_TOON_ID,
350         
351         /* Glossy */
352         CLOSURE_BSDF_GLOSSY_ID,
353         CLOSURE_BSDF_REFLECTION_ID,
354         CLOSURE_BSDF_MICROFACET_GGX_ID,
355         CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
356         CLOSURE_BSDF_WARD_ID,
357         CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
358         CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
359         CLOSURE_BSDF_PHONG_RAMP_ID,
360         CLOSURE_BSDF_GLOSSY_TOON_ID,
361         CLOSURE_BSDF_HAIR_REFLECTION_ID,
362
363         
364         /* Transmission */
365         CLOSURE_BSDF_TRANSMISSION_ID,
366         CLOSURE_BSDF_TRANSLUCENT_ID,
367         CLOSURE_BSDF_REFRACTION_ID,
368         CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
369         CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
370         CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID,
371         CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID,
372         CLOSURE_BSDF_SHARP_GLASS_ID,
373         CLOSURE_BSDF_HAIR_TRANSMISSION_ID,
374
375         
376         /* Special cases */
377         CLOSURE_BSDF_BSSRDF_ID,
378         CLOSURE_BSDF_TRANSPARENT_ID,
379
380         /* BSSRDF */
381         CLOSURE_BSSRDF_CUBIC_ID,
382         CLOSURE_BSSRDF_GAUSSIAN_ID,
383
384         /* Other */
385         CLOSURE_EMISSION_ID,
386         CLOSURE_DEBUG_ID,
387         CLOSURE_BACKGROUND_ID,
388         CLOSURE_HOLDOUT_ID,
389         CLOSURE_AMBIENT_OCCLUSION_ID,
390
391         /* Volume */
392         CLOSURE_VOLUME_ID,
393         CLOSURE_VOLUME_ABSORPTION_ID,
394         CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID,
395
396         NBUILTIN_CLOSURES
397 } ClosureType;
398
399 /* watch this, being lazy with memory usage */
400 #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
401 #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID)
402 #define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID)
403 #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_HAIR_TRANSMISSION_ID)
404 #define CLOSURE_IS_BSDF_BSSRDF(type) (type == CLOSURE_BSDF_BSSRDF_ID)
405 #define CLOSURE_IS_BSSRDF(type) (type >= CLOSURE_BSSRDF_CUBIC_ID && type <= CLOSURE_BSSRDF_GAUSSIAN_ID)
406 #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID)
407 #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
408 #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
409 #define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
410 #define CLOSURE_IS_AMBIENT_OCCLUSION(type) (type == CLOSURE_AMBIENT_OCCLUSION_ID)
411
412 #define CLOSURE_WEIGHT_CUTOFF 1e-5f
413
414 CCL_NAMESPACE_END
415
416 #endif /*  __SVM_TYPES_H__ */
417