16c726e7faa55bc071988b665175e3c4c0f919f1
[blender-staging.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_SKY,
44         NODE_GEOMETRY,
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_EMISSION_WEIGHT,
53         NODE_TEX_GRADIENT,
54         NODE_TEX_VORONOI,
55         NODE_TEX_MUSGRAVE,
56         NODE_TEX_WAVE,
57         NODE_TEX_MAGIC,
58         NODE_TEX_NOISE,
59         NODE_SHADER_JUMP,
60         NODE_SET_DISPLACEMENT,
61         NODE_GEOMETRY_BUMP_DX,
62         NODE_GEOMETRY_BUMP_DY,
63         NODE_SET_BUMP,
64         NODE_MATH,
65         NODE_VECTOR_MATH,
66         NODE_MAPPING,
67         NODE_TEX_COORD,
68         NODE_TEX_COORD_BUMP_DX,
69         NODE_TEX_COORD_BUMP_DY,
70         NODE_ADD_CLOSURE,
71         NODE_EMISSION_SET_WEIGHT_TOTAL,
72         NODE_ATTR_BUMP_DX,
73         NODE_ATTR_BUMP_DY,
74         NODE_TEX_ENVIRONMENT,
75         NODE_CLOSURE_HOLDOUT,
76         NODE_LAYER_WEIGHT,
77         NODE_CLOSURE_VOLUME,
78         NODE_SEPARATE_RGB,
79         NODE_COMBINE_RGB,
80         NODE_HSV,
81         NODE_CAMERA,
82         NODE_INVERT,
83         NODE_NORMAL,
84         NODE_GAMMA,
85         NODE_TEX_CHECKER,
86         NODE_BRIGHTCONTRAST,
87         NODE_RGB_RAMP,
88         NODE_RGB_CURVES,
89         NODE_MIN_MAX,
90         NODE_LIGHT_FALLOFF,
91         NODE_OBJECT_INFO,
92         NODE_PARTICLE_INFO
93 } NodeType;
94
95 typedef enum NodeAttributeType {
96         NODE_ATTR_FLOAT = 0,
97         NODE_ATTR_FLOAT3
98 } NodeAttributeType;
99
100 typedef enum NodeGeometry {
101         NODE_GEOM_P = 0,
102         NODE_GEOM_N,
103         NODE_GEOM_T,
104         NODE_GEOM_I,
105         NODE_GEOM_Ng,
106         NODE_GEOM_uv
107 } NodeGeometry;
108
109 typedef enum NodeObjectInfo {
110         NODE_INFO_OB_LOCATION,
111         NODE_INFO_OB_INDEX,
112         NODE_INFO_MAT_INDEX,
113         NODE_INFO_OB_RANDOM
114 } NodeObjectInfo;
115
116 typedef enum NodeParticleInfo {
117         NODE_INFO_PAR_INDEX,
118         NODE_INFO_PAR_AGE,
119         NODE_INFO_PAR_LIFETIME,
120         NODE_INFO_PAR_LOCATION,
121         NODE_INFO_PAR_ROTATION,
122         NODE_INFO_PAR_SIZE,
123         NODE_INFO_PAR_VELOCITY,
124         NODE_INFO_PAR_ANGULAR_VELOCITY
125 } NodeParticleInfo;
126
127 typedef enum NodeLightPath {
128         NODE_LP_camera = 0,
129         NODE_LP_shadow,
130         NODE_LP_diffuse,
131         NODE_LP_glossy,
132         NODE_LP_singular,
133         NODE_LP_reflection,
134         NODE_LP_transmission,
135         NODE_LP_backfacing,
136         NODE_LP_ray_length
137 } NodeLightPath;
138
139 typedef enum NodeLightFalloff {
140         NODE_LIGHT_FALLOFF_QUADRATIC,
141         NODE_LIGHT_FALLOFF_LINEAR,
142         NODE_LIGHT_FALLOFF_CONSTANT
143 } NodeLightFalloff;
144
145 typedef enum NodeTexCoord {
146         NODE_TEXCO_NORMAL,
147         NODE_TEXCO_OBJECT,
148         NODE_TEXCO_CAMERA,
149         NODE_TEXCO_WINDOW,
150         NODE_TEXCO_REFLECTION
151 } NodeTexCoord;
152
153 typedef enum NodeMix {
154         NODE_MIX_BLEND = 0,
155         NODE_MIX_ADD,
156         NODE_MIX_MUL,
157         NODE_MIX_SUB,
158         NODE_MIX_SCREEN,
159         NODE_MIX_DIV,
160         NODE_MIX_DIFF,
161         NODE_MIX_DARK,
162         NODE_MIX_LIGHT,
163         NODE_MIX_OVERLAY,
164         NODE_MIX_DODGE,
165         NODE_MIX_BURN,
166         NODE_MIX_HUE,
167         NODE_MIX_SAT,
168         NODE_MIX_VAL,
169         NODE_MIX_COLOR,
170         NODE_MIX_SOFT,
171         NODE_MIX_LINEAR,
172         NODE_MIX_CLAMP /* used for the clamp UI option */
173 } NodeMix;
174
175 typedef enum NodeMath {
176         NODE_MATH_ADD,
177         NODE_MATH_SUBTRACT,
178         NODE_MATH_MULTIPLY,
179         NODE_MATH_DIVIDE,
180         NODE_MATH_SINE,
181         NODE_MATH_COSINE,
182         NODE_MATH_TANGENT,
183         NODE_MATH_ARCSINE,
184         NODE_MATH_ARCCOSINE,
185         NODE_MATH_ARCTANGENT,
186         NODE_MATH_POWER,
187         NODE_MATH_LOGARITHM,
188         NODE_MATH_MINIMUM,
189         NODE_MATH_MAXIMUM,
190         NODE_MATH_ROUND,
191         NODE_MATH_LESS_THAN,
192         NODE_MATH_GREATER_THAN,
193         NODE_MATH_CLAMP /* used for the clamp UI option */
194 } NodeMath;
195
196 typedef enum NodeVectorMath {
197         NODE_VECTOR_MATH_ADD,
198         NODE_VECTOR_MATH_SUBTRACT,
199         NODE_VECTOR_MATH_AVERAGE,
200         NODE_VECTOR_MATH_DOT_PRODUCT,
201         NODE_VECTOR_MATH_CROSS_PRODUCT,
202         NODE_VECTOR_MATH_NORMALIZE
203 } NodeVectorMath;
204
205 typedef enum NodeConvert {
206         NODE_CONVERT_FV,
207         NODE_CONVERT_CF,
208         NODE_CONVERT_VF
209 } NodeConvert;
210
211 typedef enum NodeDistanceMetric {
212         NODE_VORONOI_DISTANCE_SQUARED,
213         NODE_VORONOI_ACTUAL_DISTANCE,
214         NODE_VORONOI_MANHATTAN,
215         NODE_VORONOI_CHEBYCHEV,
216         NODE_VORONOI_MINKOVSKY_H,
217         NODE_VORONOI_MINKOVSKY_4,
218         NODE_VORONOI_MINKOVSKY
219 } NodeDistanceMetric;
220
221 typedef enum NodeNoiseBasis {
222         NODE_NOISE_PERLIN,
223         NODE_NOISE_VORONOI_F1,
224         NODE_NOISE_VORONOI_F2,
225         NODE_NOISE_VORONOI_F3,
226         NODE_NOISE_VORONOI_F4,
227         NODE_NOISE_VORONOI_F2_F1,
228         NODE_NOISE_VORONOI_CRACKLE,
229         NODE_NOISE_CELL_NOISE
230 } NodeNoiseBasis;
231
232 typedef enum NodeWaveBasis {
233         NODE_WAVE_SINE,
234         NODE_WAVE_SAW,
235         NODE_WAVE_TRI
236 } NodeWaveBasis;
237
238 typedef enum NodeMusgraveType {
239         NODE_MUSGRAVE_MULTIFRACTAL,
240         NODE_MUSGRAVE_FBM,
241         NODE_MUSGRAVE_HYBRID_MULTIFRACTAL,
242         NODE_MUSGRAVE_RIDGED_MULTIFRACTAL,
243         NODE_MUSGRAVE_HETERO_TERRAIN
244 } NodeMusgraveType;
245
246 typedef enum NodeWaveType {
247         NODE_WAVE_BANDS,
248         NODE_WAVE_RINGS
249 } NodeWaveType;
250
251 typedef enum NodeGradientType {
252         NODE_BLEND_LINEAR,
253         NODE_BLEND_QUADRATIC,
254         NODE_BLEND_EASING,
255         NODE_BLEND_DIAGONAL,
256         NODE_BLEND_RADIAL,
257         NODE_BLEND_QUADRATIC_SPHERE,
258         NODE_BLEND_SPHERICAL
259 } NodeGradientType;
260
261 typedef enum NodeVoronoiColoring {
262         NODE_VORONOI_INTENSITY,
263         NODE_VORONOI_CELLS
264 } NodeVoronoiColoring;
265
266 typedef enum NodeBlendWeightType {
267         NODE_LAYER_WEIGHT_FRESNEL,
268         NODE_LAYER_WEIGHT_FACING
269 } NodeBlendWeightType;
270
271 typedef enum ShaderType {
272         SHADER_TYPE_SURFACE,
273         SHADER_TYPE_VOLUME,
274         SHADER_TYPE_DISPLACEMENT
275 } ShaderType;
276
277 /* Closure */
278
279 typedef enum ClosureType {
280         CLOSURE_BSDF_ID,
281
282         CLOSURE_BSDF_DIFFUSE_ID,
283         CLOSURE_BSDF_OREN_NAYAR_ID,
284
285         CLOSURE_BSDF_REFLECTION_ID,
286         CLOSURE_BSDF_MICROFACET_GGX_ID,
287         CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
288         CLOSURE_BSDF_WARD_ID,
289         CLOSURE_BSDF_WESTIN_SHEEN_ID,
290
291         CLOSURE_BSDF_TRANSLUCENT_ID,
292         CLOSURE_BSDF_REFRACTION_ID,
293         CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
294         CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
295         CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
296         CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
297         CLOSURE_BSDF_GLASS_ID,
298
299         CLOSURE_BSDF_TRANSPARENT_ID,
300
301         CLOSURE_BSSRDF_CUBIC_ID,
302         CLOSURE_EMISSION_ID,
303         CLOSURE_DEBUG_ID,
304         CLOSURE_BACKGROUND_ID,
305         CLOSURE_HOLDOUT_ID,
306         CLOSURE_SUBSURFACE_ID,
307
308         CLOSURE_VOLUME_ID,
309         CLOSURE_VOLUME_TRANSPARENT_ID,
310         CLOSURE_VOLUME_ISOTROPIC_ID,
311
312         NBUILTIN_CLOSURES
313 } ClosureType;
314
315 /* watch this, being lazy with memory usage */
316 #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
317 #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID)
318 #define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID)
319 #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_GLASS_ID)
320 #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
321 #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
322 #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
323 #define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
324
325 CCL_NAMESPACE_END
326
327 #endif /*  __SVM_TYPES_H__ */
328