-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry.h
113 lines (83 loc) · 1.76 KB
/
geometry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// geometry.h
// Oculus
//
// Created by Manuel Broncano Rodriguez on 6/12/13.
// Copyright (c) 2013 Manuel Broncano Rodriguez. All rights reserved.
//
#ifndef Oculus_geometry_h
#define Oculus_geometry_h
#define P_NONE UINT_MAX
#ifdef __IS_KERNEL__
#define EPSILON 1e-2f
#define PI M_PI_F
typedef float3 Vector;
typedef struct {
uchar r, g, b;
} Pixel;
typedef float2 textcoord_t;
typedef uint2 random_state_t;
__constant const Vector vec_zero = (Vector)(0.f, 0.f, 0.f);
__constant const Vector vec_y = (Vector)(0.f, 1.f, 0.f);
__constant const Vector vec_x = (Vector)(1.f, 0.f, 0.f);
__constant const Vector vec_one = (Vector)(1.f, 1.f, 1.f);
__constant const Vector ambient = (Vector)(.1f, .1f, .1f);
typedef struct {
uint pid; // primitive index
uint skip; // the distance to the right node
Vector min, max;
} BVHNode;
typedef struct {
uint c[10];
} counter_t;
#else
#include <OpenCL/OpenCL.h>
typedef cl_float3 Vector;
typedef struct {
cl_uchar r, g, b;
} Pixel;
typedef cl_uint2 random_state_t;
typedef cl_float2 textcoord_t;
const Vector vec_zero = (Vector){{0.f, 0.f, 0.f}};
typedef struct {
cl_uint pid; // primitive index
cl_uint skip; // the distance to the right node
Vector min, max;
} BVHNode;
typedef struct {
cl_uint c[10];
} counter_t;
#endif
typedef struct {
Vector o, d;
} Ray;
typedef enum {
Diffuse, Specular, Dielectric, Metal
} Surface;
typedef struct {
Surface s;
Vector c;
float e;
} Material;
typedef struct {
Vector c;
float r;
} Sphere;
typedef struct {
Vector p[3];
} Triangle;
typedef struct {
Vector o, t;
} Camera;
typedef enum {
sphere, triangle
} PrimitiveType;
typedef struct {
union {
Sphere sphere;
Triangle triangle;
};
Material m;
PrimitiveType t;
} Primitive;
#endif