forked from wjakob/nori
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmirror.cpp
63 lines (48 loc) · 1.68 KB
/
mirror.cpp
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
/*
This file is part of Nori, a simple educational ray tracer
Copyright (c) 2015 by Wenzel Jakob
Nori is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.
Nori 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <nori/bsdf.h>
#include <nori/frame.h>
NORI_NAMESPACE_BEGIN
/// Ideal mirror BRDF
class Mirror : public BSDF {
public:
Mirror(const PropertyList &) { }
Color3f eval(const BSDFQueryRecord &) const {
/* Discrete BRDFs always evaluate to zero in Nori */
return Color3f(0.0f);
}
float pdf(const BSDFQueryRecord &) const {
/* Discrete BRDFs always evaluate to zero in Nori */
return 0.0f;
}
Color3f sample(BSDFQueryRecord &bRec, const Point2f &) const {
if (Frame::cosTheta(bRec.wi) <= 0)
return Color3f(0.0f);
// Reflection in local coordinates
bRec.wo = Vector3f(
-bRec.wi.x(),
-bRec.wi.y(),
bRec.wi.z()
);
bRec.measure = EDiscrete;
/* Relative index of refraction: no change */
bRec.eta = 1.0f;
return Color3f(1.0f);
}
std::string toString() const {
return "Mirror[]";
}
};
NORI_REGISTER_CLASS(Mirror, "mirror");
NORI_NAMESPACE_END