-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrenderer.h
45 lines (35 loc) · 1.17 KB
/
renderer.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
#ifndef RENDERER_H
#define RENDERER_H
#include <cfloat>
#include "bvh.h"
#include "camera.h"
#include "sampler.h"
class Renderer
{
public:
Renderer(int height, int width, int spp, int max_nb_bounces, float3 max_sample_value = float3(FLT_MAX))
: m_height(height), m_width(width), m_spp(spp), m_max_nb_bounces(max_nb_bounces), max_sample_value(max_sample_value)
{
m_sampler = Sampler(m_spp, 2 + 4 * m_max_nb_bounces, m_height, m_width, Sampler::SOBOL);
m_image.resize(m_height * m_width, float3(0.0f));
m_verbose = true;
m_scene_epsilon = 1e-3f;
}
inline void set_camera(Camera &camera) { m_camera = &camera; }
inline void set_mesh(Mesh &mesh) { m_mesh = &mesh; m_bvh = BVH(m_mesh); }
void render();
float3 sample_ray(ray r, int sp, int sample_id, int i, int j);
std::vector<float3> &get_image() { return m_image; }
private:
int m_height, m_width;
int m_spp, m_max_nb_bounces;
std::vector<float3> m_image;
BVH m_bvh;
Mesh *m_mesh;
Camera *m_camera;
Sampler m_sampler;
bool m_verbose;
float m_scene_epsilon;
float3 max_sample_value;
};
#endif // RENDERER_H