2 * Copyright 2011, Blender Foundation.
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.
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.
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.
19 #ifndef __KERNEL_TYPES_H__
20 #define __KERNEL_TYPES_H__
22 #include "kernel_math.h"
24 #include "svm/svm_types.h"
28 #define OBJECT_SIZE 16
32 #define __INSTANCING__
35 #define __BACKGROUND__
36 #define __CAUSTICS_TRICKS__
37 #define __VISIBILITY_FLAG__
38 #define __RAY_DIFFERENTIALS__
39 #define __CAMERA_CLIPPING__
40 #define __INTERSECTION_REFINE__
42 #ifndef __KERNEL_OPENCL__
47 //#define __MULTI_LIGHT__
51 #define __MULTI_CLOSURE__
52 #define __TRANSPARENT_SHADOWS__
56 #ifdef __KERNEL_CUDA__
57 #if __CUDA_ARCH__ >= 200
58 #define __MULTI_CLOSURE__
59 #define __TRANSPARENT_SHADOWS__
63 //#define __SOBOL_FULL_SCREEN__
64 //#define __MODIFY_TP__
69 enum PathTraceDimension {
87 /* these flag values correspond exactly to OSL defaults, so be careful not to
88 * change this, or if you do, set the "raytypes" shading system attribute with
89 * your own new ray types and bitflag values */
94 PATH_RAY_TRANSMIT = 4,
97 PATH_RAY_SINGULAR = 32,
98 PATH_RAY_TRANSPARENT = 64,
100 PATH_RAY_SHADOW_OPAQUE = 128,
101 PATH_RAY_SHADOW_TRANSPARENT = 256,
102 PATH_RAY_SHADOW = (PATH_RAY_SHADOW_OPAQUE|PATH_RAY_SHADOW_TRANSPARENT),
104 PATH_RAY_MIS_SKIP = 512,
106 PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512)
111 typedef enum ClosureLabel {
115 LABEL_BACKGROUND = 4,
122 LABEL_SINGULAR = 512,
123 LABEL_TRANSPARENT = 1024,
129 typedef enum ShaderFlag {
130 SHADER_SMOOTH_NORMAL = (1 << 31),
131 SHADER_CAST_SHADOW = (1 << 30),
132 SHADER_AREA_LIGHT = (1 << 29),
134 SHADER_MASK = ~(SHADER_SMOOTH_NORMAL|SHADER_CAST_SHADOW|SHADER_AREA_LIGHT)
139 typedef enum LightType {
147 typedef struct differential3 {
152 typedef struct differential {
164 #ifdef __RAY_DIFFERENTIALS__
172 typedef struct Intersection {
180 typedef enum AttributeElement {
190 #define MAX_CLOSURE 8
192 typedef struct ShaderClosure {
196 #ifdef __MULTI_CLOSURE__
211 * Main shader state at a point on the surface or in a volume. All coordinates
212 * are in world space. */
214 enum ShaderDataFlag {
216 SD_BACKFACING = 1, /* backside of surface? */
217 SD_EMISSION = 2, /* have emissive closure? */
218 SD_BSDF = 4, /* have bsdf closure? */
219 SD_BSDF_HAS_EVAL = 8, /* have non-singular bsdf closure? */
220 SD_BSDF_GLOSSY = 16, /* have glossy bsdf */
221 SD_HOLDOUT = 32, /* have holdout closure? */
222 SD_VOLUME = 64, /* have volume closure? */
225 SD_SAMPLE_AS_LIGHT = 128, /* direct light sample */
226 SD_HAS_SURFACE_TRANSPARENT = 256, /* has surface transparency */
227 SD_HAS_VOLUME = 512, /* has volume shader */
228 SD_HOMOGENEOUS_VOLUME = 1024 /* has homogeneous volume */
231 typedef struct ShaderData {
234 /* smooth normal for shading */
236 /* true geometric normal */
238 /* view/incoming direction */
242 /* booleans describing shader, see ShaderDataFlag */
245 /* primitive id if there is one, ~0 otherwise */
247 /* parametric coordinates
248 * - barycentric weights for triangles */
250 /* object id if there is one, ~0 otherwise */
253 #ifdef __RAY_DIFFERENTIALS__
254 /* differential of P. these are orthogonal to Ng, not N */
256 /* differential of I */
258 /* differential of u, v */
263 /* differential of P w.r.t. parametric coordinates. note that dPdu is
264 * not readily suitable as a tangent for shading on triangles. */
268 #ifdef __MULTI_CLOSURE__
269 /* Closure data, we store a fixed array of closures */
270 ShaderClosure closure[MAX_CLOSURE];
274 /* Closure data, with a single sampled closure for low memory usage */
275 ShaderClosure closure;
284 /* Constrant Kernel Data */
286 typedef struct KernelCamera {
295 Transform cameratoworld;
296 Transform rastertocamera;
311 float bladesrotation;
323 Transform screentoworld;
324 Transform rastertoworld;
325 Transform ndctoworld;
326 Transform worldtoscreen;
327 Transform worldtoraster;
328 Transform worldtondc;
329 Transform worldtocamera;
332 typedef struct KernelFilm {
334 int pad1, pad2, pad3;
337 typedef struct KernelBackground {
338 /* only shader index */
344 typedef struct KernelSunSky {
345 /* sun direction in spherical and cartesian */
346 float theta, phi, pad3, pad4;
352 /* perez function parameters */
353 float zenith_Y, zenith_x, zenith_y, pad2;
354 float perez_Y[5], perez_x[5], perez_y[5];
358 typedef struct KernelIntegrator {
360 int use_direct_light;
361 int num_distribution;
370 int max_diffuse_bounce;
371 int max_glossy_bounce;
372 int max_transmission_bounce;
375 int transparent_min_bounce;
376 int transparent_max_bounce;
377 int transparent_shadows;
387 typedef struct KernelBVH {
390 int attributes_map_stride;
394 typedef struct KernelData {
397 KernelBackground background;
399 KernelIntegrator integrator;
405 #endif /* __KERNEL_TYPES_H__ */