forked from weft/warp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hits_mesh.cu
41 lines (33 loc) · 1.36 KB
/
hits_mesh.cu
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
#include <optix.h>
#include <optixu/optixu_math_namespace.h>
#include "datadef.h"
using namespace optix;
rtDeclareVariable(intersection_point, payload, rtPayload, );
rtDeclareVariable(float, int_dist, rtIntersectionDistance, );
rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
rtDeclareVariable(unsigned, cellnum, attribute cell_num, );
rtDeclareVariable(int, celltal, attribute cell_tal, );
rtDeclareVariable(unsigned, cellmat, attribute cell_mat, );
rtDeclareVariable(unsigned, cellfissile, attribute cell_fis, );
rtDeclareVariable(unsigned, sense, attribute cell_sense, );
rtDeclareVariable(float3, normal, attribute normal, );
RT_PROGRAM void closest_hit()
{
// always update current position and intersection distance, camera takes care of recording the first one
payload.x = int_dist * ray.direction.x + ray.origin.x;
payload.y = int_dist * ray.direction.y + ray.origin.y;
payload.z = int_dist * ray.direction.z + ray.origin.z;
payload.surf_dist = int_dist;
//write normals
payload.norm[0] = normal.x;
payload.norm[1] = normal.y;
payload.norm[2] = normal.z;
// update sense
payload.sense = sense;
if (sense == 0){rtPrintf("sense of closest_hit is 0!\n");}
//update mat, cell, fiss
payload.mat = cellmat;
payload.cell = cellnum;
payload.tally_index = celltal;
payload.fiss = cellfissile;
}