Cycles: add Ray Length output to Light Path node. This gives the distance travelled
[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 /* note that we do not simply use 0, 1, 2, .. as values for these. this works
34  * around an obscure CUDA bug that happens when compiling for fermi. why it
35  * happens i have no idea, but consecutive values are problematic, maybe it
36  * generates an incorrect jump table. */
37
38 typedef enum NodeType {
39         NODE_END = 0,
40         NODE_CLOSURE_BSDF = 100,
41         NODE_CLOSURE_EMISSION = 200,
42         NODE_CLOSURE_BACKGROUND = 300,
43         NODE_CLOSURE_SET_WEIGHT = 400,
44         NODE_CLOSURE_WEIGHT = 500,
45         NODE_MIX_CLOSURE = 600,
46         NODE_JUMP = 700,
47         NODE_TEX_IMAGE = 1000,
48         NODE_TEX_SKY = 1100,
49         NODE_GEOMETRY = 1200,
50         NODE_LIGHT_PATH = 1300,
51         NODE_VALUE_F = 1400,
52         NODE_VALUE_V = 1500,
53         NODE_MIX = 1600,
54         NODE_ATTR = 1700,
55         NODE_CONVERT = 1900,
56         NODE_FRESNEL = 2000,
57         NODE_EMISSION_WEIGHT = 2100,
58         NODE_TEX_GRADIENT = 2200,
59         NODE_TEX_VORONOI = 2300,
60         NODE_TEX_MUSGRAVE = 2400,
61         NODE_TEX_WAVE = 2500,
62         NODE_TEX_MAGIC = 2600,
63         NODE_TEX_NOISE = 3000,
64         NODE_SHADER_JUMP = 3100,
65         NODE_SET_DISPLACEMENT = 3200,
66         NODE_GEOMETRY_BUMP_DX = 3300,
67         NODE_GEOMETRY_BUMP_DY = 3400,
68         NODE_SET_BUMP = 3500,
69         NODE_MATH = 3600,
70         NODE_VECTOR_MATH = 3700,
71         NODE_MAPPING = 3800,
72         NODE_TEX_COORD = 3900,
73         NODE_TEX_COORD_BUMP_DX = 4000,
74         NODE_TEX_COORD_BUMP_DY = 4100,
75         NODE_ADD_CLOSURE = 4200,
76         NODE_EMISSION_SET_WEIGHT_TOTAL = 4300,
77         NODE_ATTR_BUMP_DX = 4400,
78         NODE_ATTR_BUMP_DY = 4500,
79         NODE_TEX_ENVIRONMENT = 4600,
80         NODE_CLOSURE_HOLDOUT = 4700,
81         NODE_LAYER_WEIGHT = 4800,
82         NODE_CLOSURE_VOLUME = 4900,
83         NODE_SEPARATE_RGB = 5000,
84         NODE_COMBINE_RGB = 5100,
85         NODE_HSV = 5200,
86         NODE_CAMERA = 5300,
87         NODE_INVERT = 5400,
88         NODE_NORMAL = 5500,
89         NODE_GAMMA = 5600,
90         NODE_TEX_CHECKER = 5700,
91         NODE_BRIGHTCONTRAST = 5800,
92         NODE_RGB_RAMP = 5900,
93         NODE_RGB_CURVES = 6000
94 } NodeType;
95
96 typedef enum NodeAttributeType {
97         NODE_ATTR_FLOAT = 0,
98         NODE_ATTR_FLOAT3
99 } NodeAttributeType;
100
101 typedef enum NodeGeometry {
102         NODE_GEOM_P = 0,
103         NODE_GEOM_N,
104         NODE_GEOM_T,
105         NODE_GEOM_I,
106         NODE_GEOM_Ng,
107         NODE_GEOM_uv
108 } NodeGeometry;
109
110 typedef enum NodeLightPath {
111         NODE_LP_camera = 0,
112         NODE_LP_shadow,
113         NODE_LP_diffuse,
114         NODE_LP_glossy,
115         NODE_LP_singular,
116         NODE_LP_reflection,
117         NODE_LP_transmission,
118         NODE_LP_backfacing,
119         NODE_LP_ray_length
120 } NodeLightPath;
121
122 typedef enum NodeTexCoord {
123         NODE_TEXCO_NORMAL,
124         NODE_TEXCO_OBJECT,
125         NODE_TEXCO_CAMERA,
126         NODE_TEXCO_WINDOW,
127         NODE_TEXCO_REFLECTION
128 } NodeTexCoord;
129
130 typedef enum NodeMix {
131         NODE_MIX_BLEND = 0,
132         NODE_MIX_ADD,
133         NODE_MIX_MUL,
134         NODE_MIX_SUB,
135         NODE_MIX_SCREEN,
136         NODE_MIX_DIV,
137         NODE_MIX_DIFF,
138         NODE_MIX_DARK,
139         NODE_MIX_LIGHT,
140         NODE_MIX_OVERLAY,
141         NODE_MIX_DODGE,
142         NODE_MIX_BURN,
143         NODE_MIX_HUE,
144         NODE_MIX_SAT,
145         NODE_MIX_VAL,
146         NODE_MIX_COLOR,
147         NODE_MIX_SOFT,
148         NODE_MIX_LINEAR
149 } NodeMix;
150
151 typedef enum NodeMath {
152         NODE_MATH_ADD,
153         NODE_MATH_SUBTRACT,
154         NODE_MATH_MULTIPLY,
155         NODE_MATH_DIVIDE,
156         NODE_MATH_SINE,
157         NODE_MATH_COSINE,
158         NODE_MATH_TANGENT,
159         NODE_MATH_ARCSINE,
160         NODE_MATH_ARCCOSINE,
161         NODE_MATH_ARCTANGENT,
162         NODE_MATH_POWER,
163         NODE_MATH_LOGARITHM,
164         NODE_MATH_MINIMUM,
165         NODE_MATH_MAXIMUM,
166         NODE_MATH_ROUND,
167         NODE_MATH_LESS_THAN,
168         NODE_MATH_GREATER_THAN
169 } NodeMath;
170
171 typedef enum NodeVectorMath {
172         NODE_VECTOR_MATH_ADD,
173         NODE_VECTOR_MATH_SUBTRACT,
174         NODE_VECTOR_MATH_AVERAGE,
175         NODE_VECTOR_MATH_DOT_PRODUCT,
176         NODE_VECTOR_MATH_CROSS_PRODUCT,
177         NODE_VECTOR_MATH_NORMALIZE
178 } NodeVectorMath;
179
180 typedef enum NodeConvert {
181         NODE_CONVERT_FV,
182         NODE_CONVERT_CF,
183         NODE_CONVERT_VF
184 } NodeConvert;
185
186 typedef enum NodeDistanceMetric {
187         NODE_VORONOI_DISTANCE_SQUARED,
188         NODE_VORONOI_ACTUAL_DISTANCE,
189         NODE_VORONOI_MANHATTAN,
190         NODE_VORONOI_CHEBYCHEV,
191         NODE_VORONOI_MINKOVSKY_H,
192         NODE_VORONOI_MINKOVSKY_4,
193         NODE_VORONOI_MINKOVSKY
194 } NodeDistanceMetric;
195
196 typedef enum NodeNoiseBasis {
197         NODE_NOISE_PERLIN,
198         NODE_NOISE_VORONOI_F1,
199         NODE_NOISE_VORONOI_F2,
200         NODE_NOISE_VORONOI_F3,
201         NODE_NOISE_VORONOI_F4,
202         NODE_NOISE_VORONOI_F2_F1,
203         NODE_NOISE_VORONOI_CRACKLE,
204         NODE_NOISE_CELL_NOISE
205 } NodeNoiseBasis;
206
207 typedef enum NodeWaveType {
208         NODE_WAVE_SINE,
209         NODE_WAVE_SAW,
210         NODE_WAVE_TRI
211 } NodeWaveType;
212
213 typedef enum NodeMusgraveType {
214         NODE_MUSGRAVE_MULTIFRACTAL,
215         NODE_MUSGRAVE_FBM,
216         NODE_MUSGRAVE_HYBRID_MULTIFRACTAL,
217         NODE_MUSGRAVE_RIDGED_MULTIFRACTAL,
218         NODE_MUSGRAVE_HETERO_TERRAIN
219 } NodeMusgraveType;
220
221 typedef enum NodeWoodType {
222         NODE_WAVE_BANDS,
223         NODE_WAVE_RINGS
224 } NodeWoodType;
225
226 typedef enum NodeBlendType {
227         NODE_BLEND_LINEAR,
228         NODE_BLEND_QUADRATIC,
229         NODE_BLEND_EASING,
230         NODE_BLEND_DIAGONAL,
231         NODE_BLEND_RADIAL,
232         NODE_BLEND_QUADRATIC_SPHERE,
233         NODE_BLEND_SPHERICAL
234 } NodeBlendType;
235
236 typedef enum NodeBlendAxis {
237         NODE_BLEND_HORIZONTAL,
238         NODE_BLEND_VERTICAL
239 } NodeBlendAxis;
240
241 typedef enum NodeMarbleType {
242         NODE_MARBLE_SOFT,
243         NODE_MARBLE_SHARP,
244         NODE_MARBLE_SHARPER
245 } NodeMarbleType;
246
247 typedef enum NodeStucciType {
248         NODE_STUCCI_PLASTIC,
249         NODE_STUCCI_WALL_IN,
250         NODE_STUCCI_WALL_OUT
251 } NodeStucciType;
252
253 typedef enum NodeVoronoiColoring {
254         NODE_VORONOI_INTENSITY,
255         NODE_VORONOI_CELLS
256 } NodeVoronoiColoring;
257
258 typedef enum NodeBlendWeightType {
259         NODE_LAYER_WEIGHT_FRESNEL,
260         NODE_LAYER_WEIGHT_FACING
261 } NodeBlendWeightType;
262
263 typedef enum ShaderType {
264         SHADER_TYPE_SURFACE,
265         SHADER_TYPE_VOLUME,
266         SHADER_TYPE_DISPLACEMENT
267 } ShaderType;
268
269 /* Closure */
270
271 typedef enum ClosureType {
272         CLOSURE_BSDF_ID,
273
274         CLOSURE_BSDF_DIFFUSE_ID,
275         CLOSURE_BSDF_OREN_NAYAR_ID,
276
277         CLOSURE_BSDF_REFLECTION_ID,
278         CLOSURE_BSDF_MICROFACET_GGX_ID,
279         CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
280         CLOSURE_BSDF_WARD_ID,
281         CLOSURE_BSDF_WESTIN_SHEEN_ID,
282
283         CLOSURE_BSDF_TRANSLUCENT_ID,
284         CLOSURE_BSDF_REFRACTION_ID,
285         CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
286         CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
287         CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
288         CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
289         CLOSURE_BSDF_GLASS_ID,
290
291         CLOSURE_BSDF_TRANSPARENT_ID,
292
293         CLOSURE_BSSRDF_CUBIC_ID,
294         CLOSURE_EMISSION_ID,
295         CLOSURE_DEBUG_ID,
296         CLOSURE_BACKGROUND_ID,
297         CLOSURE_HOLDOUT_ID,
298         CLOSURE_SUBSURFACE_ID,
299
300         CLOSURE_VOLUME_ID,
301         CLOSURE_VOLUME_TRANSPARENT_ID,
302         CLOSURE_VOLUME_ISOTROPIC_ID,
303
304         NBUILTIN_CLOSURES
305 } ClosureType;
306
307 /* watch this, being lazy with memory usage */
308 #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
309 #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID)
310 #define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID)
311 #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_GLASS_ID)
312 #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
313 #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
314 #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
315 #define CLOSURE_IS_BACKGROUND(type) (type == CLOSURE_BACKGROUND_ID)
316
317 CCL_NAMESPACE_END
318
319 #endif /*  __SVM_TYPES_H__ */
320