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_CLOSURE__
48 //#define __TRANSPARENT_SHADOWS__
49 //#define __MULTI_LIGHT__
56 //#define __SOBOL_FULL_SCREEN__
57 //#define __MODIFY_TP__
62 enum PathTraceDimension {
80 /* these flag values correspond exactly to OSL defaults, so be careful not to
81 * change this, or if you do, set the "raytypes" shading system attribute with
82 * your own new ray types and bitflag values */
88 PATH_RAY_TRANSMIT = 8,
89 PATH_RAY_DIFFUSE = 16,
91 PATH_RAY_SINGULAR = 64,
92 PATH_RAY_TRANSPARENT = 128,
94 PATH_RAY_ALL = (1|2|4|8|16|32|64|128)
99 typedef enum ClosureLabel {
103 LABEL_BACKGROUND = 4,
110 LABEL_SINGULAR = 512,
111 LABEL_TRANSPARENT = 1024,
117 typedef enum ShaderFlag {
118 SHADER_SMOOTH_NORMAL = (1 << 31),
119 SHADER_CAST_SHADOW = (1 << 30),
120 SHADER_AREA_LIGHT = (1 << 29),
122 SHADER_MASK = ~(SHADER_SMOOTH_NORMAL|SHADER_CAST_SHADOW|SHADER_AREA_LIGHT)
127 typedef enum LightType {
135 typedef struct differential3 {
140 typedef struct differential {
152 #ifdef __RAY_DIFFERENTIALS__
160 typedef struct Intersection {
168 typedef enum AttributeElement {
178 #define MAX_CLOSURE 8
180 typedef struct ShaderClosure {
184 #ifdef __MULTI_CLOSURE__
199 * Main shader state at a point on the surface or in a volume. All coordinates
200 * are in world space. */
202 enum ShaderDataFlag {
204 SD_BACKFACING = 1, /* backside of surface? */
205 SD_EMISSION = 2, /* have emissive closure? */
206 SD_BSDF = 4, /* have bsdf closure? */
207 SD_BSDF_HAS_EVAL = 8, /* have non-singular bsdf closure? */
208 SD_BSDF_GLOSSY = 16, /* have glossy bsdf */
209 SD_HOLDOUT = 32, /* have holdout closure? */
210 SD_VOLUME = 64, /* have volume closure? */
213 SD_SAMPLE_AS_LIGHT = 128, /* direct light sample */
214 SD_HAS_SURFACE_TRANSPARENT = 256, /* has surface transparency */
215 SD_HAS_VOLUME = 512, /* has volume shader */
216 SD_HOMOGENEOUS_VOLUME = 1024 /* has homogeneous volume */
219 typedef struct ShaderData {
222 /* smooth normal for shading */
224 /* true geometric normal */
226 /* view/incoming direction */
230 /* booleans describing shader, see ShaderDataFlag */
233 /* primitive id if there is one, ~0 otherwise */
235 /* parametric coordinates
236 * - barycentric weights for triangles */
238 /* object id if there is one, ~0 otherwise */
241 #ifdef __RAY_DIFFERENTIALS__
242 /* differential of P. these are orthogonal to Ng, not N */
244 /* differential of I */
246 /* differential of u, v */
251 /* differential of P w.r.t. parametric coordinates. note that dPdu is
252 * not readily suitable as a tangent for shading on triangles. */
256 #ifdef __MULTI_CLOSURE__
257 /* Closure data, we store a fixed array of closures */
258 ShaderClosure closure[MAX_CLOSURE];
262 /* Closure data, with a single sampled closure for low memory usage */
263 ShaderClosure closure;
272 /* Constrant Kernel Data */
274 typedef struct KernelCamera {
283 Transform cameratoworld;
284 Transform rastertocamera;
299 float bladesrotation;
311 Transform screentoworld;
312 Transform rastertoworld;
313 Transform ndctoworld;
314 Transform worldtoscreen;
315 Transform worldtoraster;
316 Transform worldtondc;
317 Transform worldtocamera;
320 typedef struct KernelFilm {
322 int pad1, pad2, pad3;
325 typedef struct KernelBackground {
326 /* only shader index */
332 typedef struct KernelSunSky {
333 /* sun direction in spherical and cartesian */
334 float theta, phi, pad3, pad4;
340 /* perez function parameters */
341 float zenith_Y, zenith_x, zenith_y, pad2;
342 float perez_Y[5], perez_x[5], perez_y[5];
346 typedef struct KernelIntegrator {
348 int use_direct_light;
349 int num_distribution;
359 int max_diffuse_bounce;
360 int max_glossy_bounce;
361 int max_transmission_bounce;
364 int transparent_min_bounce;
365 int transparent_max_bounce;
366 int transparent_shadows;
373 typedef struct KernelBVH {
376 int attributes_map_stride;
380 typedef struct KernelData {
383 KernelBackground background;
385 KernelIntegrator integrator;
391 #endif /* __KERNEL_TYPES_H__ */