-
Notifications
You must be signed in to change notification settings - Fork 2
/
PPMRenderer.h
70 lines (53 loc) · 2.06 KB
/
PPMRenderer.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
61
62
63
64
65
66
67
68
69
70
//
// Created by lazycal on 2017/6/20.
//
#ifndef RAY_TRACING_PPMRENDERER_H
#define RAY_TRACING_PPMRENDERER_H
#include "Camera.h"
#include "header.h"
#include "World.h"
#include "RtHitPoint.h"
#include "PhotonMap.h"
#include <string>
#include <iostream>
#include <thread>
#include <mutex>
class PPMRenderer {
public:
int H, W, PHONG_SEC_POW;
int RAY_TRACING_DEPTH;
int RESAMPLE_QUALITY;
int ITERS;
int MAX_THREADS;
int PHOTONS_PER_ITER;
int PHOTON_TRACING_DEPTH;
constexpr static double ALPHA = 0.7;
World world;
PPMRenderer(std::string input_file, std::string output_file);
void run();
void output(std::string suf="");
private:
int rt_i, rt_j;
std::mutex mt;
std::string output_file;
PhotonMap photonMap;
Mat res, oid, rt_res;
std::vector< std::vector<RtHitPoint> > rtHitMap;
Color rayTrace(Ray ray, int depth, Color weight, bool inside, int &hashId, std::vector<RtHitPoint> &hitPoints, Mat res = cv::Mat());
Color phong(const Collision &collision, const Ray &ray, int &hashId);
Color calcRefr(const Collision &collision, const Ray &ray, int depth, const Color &weight, bool inside, int &hashId,
std::vector<RtHitPoint> &hitPoints, Mat &);
void drawSegment(Vector3 u, Vector3 v, cv::Mat &img, Scalar color = cv::Scalar(0,0,255));
bool inBoundary(int i, int j);
int HASH_BASE, MOD;
Color calcRefl(const Collision &collision, const Ray &ray, int depth, Color weight, bool inside, int &hashId,
std::vector<RtHitPoint> &hitPoints, Mat &img);
void photonTrace(const Photon &photon, int depth, bool inside);
bool calcPhotonRefr(const Collision &collision, const Photon &photon, int depth, bool inside, double &ksi);
bool calcPhotonRefl(const Collision &collision, const Photon &photon, int depth, bool inside, double &ksi);
bool calcPhotonDiff(const Collision &collision, const Photon &photon, int depth, bool inside, double &ksi);
Scalar _color;
void multithreadRayTrace();
void nextRow(int &i);
};
#endif //RAY_TRACING_PPMRENDERER_H