-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpathTracer.hpp
49 lines (41 loc) · 1.26 KB
/
pathTracer.hpp
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
#ifndef __PATHTRACER__
#define __PATHTRACER__
#include "rng.hpp"
#include "Scene.hpp"
#include "imaging/Image.hpp"
#include "color/RGB.hpp"
#include "shapes/Shape.hpp"
#include "vfield/Point.hpp"
#include "vfield/Direction.hpp"
#include "vfield/Operations.hpp"
#include "Ray.hpp"
#include <random>
#include <vector>
#include <memory>
#include <limits>
#include <iomanip>
#include <thread>
#include <math.h>
#include <mutex>
#include <atomic>
#include <condition_variable>
using namespace std;
//***********************************************************************
// Path Tracer implementation
//***********************************************************************
class PathTracer{
private:
int current_width = 0;
int current_height = 0;
mutex mtx;
condition_variable cv;
bool ready = true;
atomic_int pixelsLeftToGenerate;
void threadWork(Image& img, Scene scene, int rpp, int subdivisions);
void applyToSubimage(Image& img, Scene scene, int rpp, int subdivisions);
int numberOfSubdivisions(int width, int height);
void getSubdivision(const int w, const int h, const int n, int& w0, int& wf, int& h0, int& hf);
public:
void pathTrace(Image& img, Scene scene, int rpp);
};
#endif