-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathrender_instances.cpp
87 lines (77 loc) · 3.23 KB
/
render_instances.cpp
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
// This file is distributed under the MIT license.
// See the LICENSE file for details.
#include <cassert>
#include "render.h"
namespace visionaray
{
void render_instances_cpp(
index_bvh<index_bvh<basic_triangle<3, float>>::bvh_inst>& bvh,
aligned_vector<vec3> const& geometric_normals,
aligned_vector<vec3> const& shading_normals,
aligned_vector<vec2> const& tex_coords,
aligned_vector<generic_material_t> const& materials,
aligned_vector<vec3> const& colors,
aligned_vector<texture_t> const& textures,
aligned_vector<generic_light_t> const& lights,
unsigned bounces,
float epsilon,
vec4 bgcolor,
vec4 ambient,
host_device_rt& rt,
host_sched_t<ray_type_cpu>& sched,
camera_t const& cam,
unsigned& frame_num,
algorithm algo,
unsigned ssaa_samples,
host_environment_light const& env_light
)
{
using bvh_ref = index_bvh<index_bvh<basic_triangle<3, float>>::bvh_inst>::bvh_ref;
aligned_vector<bvh_ref> primitives;
primitives.push_back(bvh.ref());
if (env_light.texture())
{
auto kparams = make_kernel_params(
normals_per_vertex_binding{},
colors_per_vertex_binding{},
primitives.data(),
primitives.data() + primitives.size(),
geometric_normals.data(),
shading_normals.data(),
tex_coords.data(),
materials.data(),
colors.data(),
textures.data(),
lights.data(),
lights.data() + lights.size(),
env_light,
env_light,
bounces,
epsilon
);
call_kernel( algo, sched, kparams, frame_num, ssaa_samples, cam, rt );
}
else
{
auto kparams = make_kernel_params(
normals_per_vertex_binding{},
colors_per_vertex_binding{},
primitives.data(),
primitives.data() + primitives.size(),
geometric_normals.data(),
shading_normals.data(),
tex_coords.data(),
materials.data(),
colors.data(),
textures.data(),
lights.data(),
lights.data() + lights.size(),
bounces,
epsilon,
bgcolor,
ambient
);
call_kernel( algo, sched, kparams, frame_num, ssaa_samples, cam, rt );
}
}
} // visionaray