-
Notifications
You must be signed in to change notification settings - Fork 0
/
MCRenderer.h
120 lines (72 loc) · 2.52 KB
/
MCRenderer.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
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
115
116
117
118
119
#pragma once
#include "Renderer.h"
#include "macros.h"
#include <io.h>
#include <math.h>
typedef vector<Ray> Path;
class Renderer;
class MCRenderer
{
friend void mouseEvent (int evt, int x, int y, int flags, void* param);
public:
enum {SHOW_PATH, SHOW_PIXEL_VALUE, NO_EVENT} showEvent;
struct IntersectInfo
{
SceneObject *intersectObject;
unsigned triangleID;
float dist;
};
protected:
Renderer *renderer;
void samplePath(Path& path, Ray& prevRay, unsigned depth, bool firstDiff = false) const;
string savePath;
vec4<float> connectColorProb(const Path& connectedPath, int connectIndex, bool merged = false);
protected:
string response(const IplImage* currentImage = NULL);
bool useMerge;
unsigned maxDepth;
unsigned pathPixelID;
int outputIter;
vector<Ray> showPath;
void samplePath(Path& path, Ray& startRay) const;
vector<Path> samplePathList(const vector<Ray>& startRayList) const;
vector<Path> sampleMergePathList(const vector<Ray>& startRayList) const;
void showCurrentResult(const vector<vec3f>& pixelColors , unsigned* time = NULL , unsigned* iter = NULL);
void eliminateVignetting(vector<vec3f>& pixelColors);
SceneObject* findInsideObject(const vec3f& origin, const vec3f& direction);
IntersectInfo intersect(const vec3f& origin, const vec3f& direction, KDTree::Condition* condition = NULL);
void preprocessEmissionSampler();
void preprocessOtherSampler(bool isUniformOrigin);
void preprocessVolumeSampler(bool isUniformOrigin , float mergeRadius);
Ray genEmissiveSurfaceSample(bool isUniformOrigin , bool isUniformDir) const;
Ray genOtherSurfaceSample(bool isUniformOrigin , bool isUniformDir) const;
Ray genVolumeSample(bool isUniformDir = false) const;
void resetInsideObject(Ray& ray);
bool testVisibility(const Ray& startRay, const Ray& endRay);
vector<vector<unsigned>> testPathListVisibility(const vector<Path>& startPathList, const vector<Path>& endPathList);
void saveImagePFM(const string& fileName, const IplImage* image);
bool connectRays(Path& path, int connectIndex, bool merged = false);
public:
void setMaxDepth(const int _maxDepth)
{
maxDepth = (unsigned)_maxDepth;
}
int getMaxDepth()
{
return maxDepth;
}
void setSavePath(const string& savePath);
MCRenderer(Renderer *renderer)
{
this->renderer = renderer;
maxDepth = 20;
pathPixelID = -1;
useMerge = false;
outputIter = 5;
}
virtual void preprocess(){}
virtual vector<vec3f> renderPixels(const Camera& camera)
{
return vector<vec3f>(camera.generateRays().size(), vec3f(0, 0, 0));
}
};