00001
00002
00003
00004
00005
00006
00007 #ifndef RC_CUDA_TRACER_H
00008 #define RC_CUDA_TRACER_H
00009
00010
00011 #if defined RC_WIN32 || defined WIN32
00012 #pragma warning( disable : 4201 )
00013 #endif
00014
00015 typedef struct {
00016
00017 float c[4];
00018
00019 } CudaColor;
00020
00021
00022 typedef struct {
00023
00024 float t;
00025 float u;
00026 float v;
00027
00028 int hit;
00029
00030 } CudaTriangleIntersection;
00031
00032
00033 typedef struct {
00034
00035 float t;
00036 float uv[2];
00037
00038 int hit;
00039
00040 float normal[3];
00041
00042
00043
00044
00045 } CudaIntersection;
00046
00047
00048 typedef struct {
00049
00050 union {
00051
00052 struct {
00053
00054
00055 float v0[3];
00056 float e1[3];
00057 float e2[3];
00058
00059
00060
00061 int aux_idx[3];
00062
00063
00064
00065 };
00066
00067 unsigned int bytes[12];
00068 };
00069
00070 } CudaTriangle;
00071
00072
00073 typedef struct {
00074
00075
00076
00077 float n[2];
00078 unsigned char norm_dir;
00079 unsigned char pad[7];
00080
00081
00082
00083
00084
00085
00086 } CudaVertexAux;
00087
00088
00089
00090 typedef struct {
00091
00092
00093
00094 float minCorner[3];
00095 float maxCorner[3];
00096
00097
00098
00099 union {
00100 struct {
00101 unsigned short leaf;
00102 unsigned short n;
00103 };
00104
00105 unsigned int info;
00106 };
00107
00108
00109
00110 int index;
00111
00112
00113
00114 } CudaBVHNode;
00115
00116
00117 typedef struct {
00118
00119 union {
00120 struct {
00121 CudaBVHNode left;
00122 CudaBVHNode right;
00123 } nodes;
00124
00125 unsigned int bytes[16];
00126 };
00127
00128 } CudaNodePair;
00129
00130
00131 typedef struct {
00132
00133 CudaBVHNode *nodes;
00134 int n_nodes;
00135
00136 CudaTriangle *triangles;
00137 int n_triangles;
00138
00139 CudaVertexAux *aux;
00140 int n_aux;
00141
00142 } CudaBVH;
00143
00144
00145 void CudaTracerInit(
00146 CudaBVH *host_bvh
00147 );
00148
00149 bool CudaTracerRun(
00150 unsigned int *pixels,
00151 float ray_orig[3],
00152 float lgt_pos[3],
00153 int resolution[2],
00154 float vp_inv[16]
00155 );
00156
00157
00158
00159 #endif
00160
00161