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
120
121
122
123
124
125 | /*
Copyright 2018 Lingqi Yan
This file is part of WaveOpticsBrdf.
WaveOpticsBrdf is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WaveOpticsBrdf is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WaveOpticsBrdf. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef WDF_H
#define WDF_H
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <complex>
#include <vector>
#include <Eigen/Dense>
#include "exrimage.h"
#include "gaborkernel.h"
using namespace std;
using namespace Eigen;
class EXRImage;
struct Query {
Vector2 mu_p;
Float sigma_p;
Vector2 omega_i;
Vector2 omega_o;
Float lambda; // in microns.
};
// Heightfield.
// Suppose it starts from (0, 0) and
// extends to positive (w * mTexelWidth, h * mTexelWidth) and
// is tiling along both axes.
class Heightfield {
public:
Heightfield() {}
Heightfield(EXRImage *heightfieldImage, Float texelWidth = 1.0, Float vertScale = 1.0)
: mHeightfieldImage(heightfieldImage), mTexelWidth(texelWidth), mVertScale(vertScale) {}
GaborKernel g(int i, int j, Float F, Float lambda);
Vector2 n(Float i, Float j);
public:
EXRImage *mHeightfieldImage;
Float mTexelWidth; // in microns.
Float mVertScale;
};
class BrdfBase {
public:
BrdfBase() {}
BrdfBase(Heightfield *heightfield) : mHeightfield(heightfield) {}
public:
virtual Float queryBrdf(const Query &query) = 0;
virtual Float* genBrdfImage(const Query &query, int resolution) = 0;
protected:
Heightfield *mHeightfield;
};
class GeometricBrdf: public BrdfBase {
public:
GeometricBrdf() {}
GeometricBrdf(Heightfield *heightfield, int sampleNum = 10000000) : mHeightfield(heightfield), mSampleNum(sampleNum) {}
Float* genNdfImage(const Query &query, int resolution);
virtual Float queryBrdf(const Query &query);
virtual Float* genBrdfImage(const Query &query, int resolution);
protected:
Heightfield *mHeightfield;
private:
int mSampleNum;
};
class WaveBrdf: public BrdfBase {
public:
WaveBrdf() {}
WaveBrdf(Heightfield *heightfield) : mHeightfield(heightfield) {}
virtual Float queryBrdf(const Query &query);
virtual Float* genBrdfImage(const Query &query, int resolution);
protected:
Heightfield *mHeightfield;
};
class WaveBrdfAccel: public WaveBrdf {
public:
WaveBrdfAccel() {}
WaveBrdfAccel(Heightfield *heightfield, string method);
comp queryIntegral(const Query &query, int layer, int xIndex, int yIndex);
virtual Float queryBrdf(const Query &query);
virtual Float* genBrdfImage(const Query &query, int resolution);
protected:
Heightfield *mHeightfield;
private:
vector<vector<GaborKernelPrime>> gaborKernelPrime;
vector<vector<vector<AABB>>> angularBB;
int mTopLayer;
public:
string mMethod;
};
#endif
|