Repository navigation
Expand file tree
/
Copy pathscene.h
More file actions
114 lines (99 loc) · 3.11 KB
/
Copy pathscene.h
File metadata and controls
114 lines (99 loc) · 3.11 KB
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
114
#pragma once
#include "redner.h"
#include "vector.h"
#include "buffer.h"
#include "ray.h"
#include "intersection.h"
#include "camera.h"
#include "light.h"
#include "shape.h"
#include "material.h"
#include "edge.h"
#include <vector>
#include <memory>
#include <mutex>
#include <embree3/rtcore.h>
#ifdef COMPILE_WITH_CUDA
#include <optix_prime/optix_primepp.h>
#endif
struct Scene {
/// XXX should use py::list to avoid copy?
Scene(const Camera &camera,
const std::vector<const Shape*> &shapes,
const std::vector<const Material*> &materials,
const std::vector<const Light*> &lights,
bool use_gpu);
~Scene();
// Flatten arrays of scene content
Camera camera;
Buffer<Shape> shapes;
Buffer<Material> materials;
Buffer<Light> lights;
// Is the scene stored in GPU or CPU
bool use_gpu;
#ifdef COMPILE_WITH_CUDA
// Optix handles
optix::prime::Context optix_context;
std::vector<optix::prime::Model> optix_models;
std::vector<RTPmodel> optix_instances;
std::vector<Matrix4x4f> transforms;
optix::prime::Model optix_scene;
#endif
// Embree handles
RTCDevice embree_device;
RTCScene embree_scene;
// Light sampling
Buffer<Real> light_pmf;
Buffer<Real> light_cdf;
Buffer<Real> light_areas;
Buffer<Real*> area_cdfs;
Buffer<Real> area_cdf_pool;
// For material derivatives
std::vector<std::mutex> material_mutexes;
// For edge sampling
EdgeSampler edge_sampler;
};
struct FlattenScene {
Shape *shapes;
Material *materials;
Light *lights;
int num_lights;
Real *light_pmf;
Real *light_cdf;
Real *light_areas;
Real **area_cdfs;
};
// XXX: Again, some unnecessary copy from Python
struct DScene {
DScene() {}
DScene(const DCamera &camera,
const std::vector<DShape*> &shapes,
const std::vector<DMaterial*> &materials,
const std::vector<DLight*> &lights,
bool use_gpu);
~DScene();
DCamera camera;
Buffer<DShape> shapes;
Buffer<DMaterial> materials;
Buffer<DLight> lights;
};
FlattenScene get_flatten_scene(const Scene &scene);
void intersect(const Scene &scene,
const BufferView<int> &active_pixels,
const BufferView<Ray> &rays,
BufferView<Intersection> intersections,
BufferView<SurfacePoint> surface_points);
// Set intersection to invalid if occluded
void occluded(const Scene &scene,
const BufferView<int> &active_pixels,
const BufferView<Ray> &rays,
BufferView<Intersection> intersections);
void sample_point_on_light(const Scene &scene,
const BufferView<int> &active_pixels,
const BufferView<SurfacePoint> &shading_points,
const BufferView<LightSample> &samples,
BufferView<Intersection> light_isects,
BufferView<SurfacePoint> light_points,
BufferView<Ray> shadow_ray);
void test_scene_intersect(bool use_gpu);
void test_sample_point_on_light(bool use_gpu);