-
Notifications
You must be signed in to change notification settings - Fork 87
/
PointRayTracerKernel.h
60 lines (44 loc) · 1.28 KB
/
PointRayTracerKernel.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
/* This file is part of COVISE.
You can use it under the terms of the GNU Lesser General Public License
version 2.1 or later, see lgpl-2.1.txt.
* License: LGPL 2+ */
#ifndef POINT_RAY_TRACER_KERNEL_H
#define POINT_RAY_TRACER_KERNEL_H
//#include <visionaray/get_color.h>
#include "PointRayTracerGlobals.h"
// kernel with ray tracing logic
template <typename BVHs>
struct Kernel
{
using R = ray_type;
using S = R::scalar_type;
using C = visionaray::vector<4, S>;
Kernel(BVHs bvhs_begin, BVHs bvhs_end)
: m_bvhs_begin(bvhs_begin)
, m_bvhs_end(bvhs_end)
{
}
VSNRAY_FUNC
visionaray::result_record<S> operator()(R ray)
{
visionaray::result_record<S> result;
result.color = C(0.f);
auto hit_rec = visionaray::closest_hit(
ray,
m_bvhs_begin,
m_bvhs_end
);
result.hit = hit_rec.hit;
auto color = hit_rec.color;
result.color = visionaray::select(
hit_rec.hit,
C(visionaray::vector<3, S>(color), S(1.0)),
result.color
);
result.depth = hit_rec.t;
return result;
}
BVHs m_bvhs_begin;
BVHs m_bvhs_end;
};
#endif // POINT_RAY_TRACER_KERNEL_H