Nori  23
dielectric.cpp
1 /*
2  This file is part of Nori, a simple educational ray tracer
3 
4  Copyright (c) 2015 by Wenzel Jakob
5 
6  Nori is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Nori is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include <nori/bsdf.h>
20 #include <nori/frame.h>
21 
22 NORI_NAMESPACE_BEGIN
23 
25 class Dielectric : public BSDF {
26 public:
27  Dielectric(const PropertyList &propList) {
28  /* Interior IOR (default: BK7 borosilicate optical glass) */
29  m_intIOR = propList.getFloat("intIOR", 1.5046f);
30 
31  /* Exterior IOR (default: air) */
32  m_extIOR = propList.getFloat("extIOR", 1.000277f);
33  }
34 
35  virtual Color3f eval(const BSDFQueryRecord &) const override {
36  /* Discrete BRDFs always evaluate to zero in Nori */
37  return Color3f(0.0f);
38  }
39 
40  virtual float pdf(const BSDFQueryRecord &) const override {
41  /* Discrete BRDFs always evaluate to zero in Nori */
42  return 0.0f;
43  }
44 
45  virtual Color3f sample(BSDFQueryRecord &bRec, const Point2f &sample) const override {
46  throw NoriException("Unimplemented!");
47  }
48 
49  virtual std::string toString() const override {
50  return tfm::format(
51  "Dielectric[\n"
52  " intIOR = %f,\n"
53  " extIOR = %f\n"
54  "]",
55  m_intIOR, m_extIOR);
56  }
57 private:
58  float m_intIOR, m_extIOR;
59 };
60 
61 NORI_REGISTER_CLASS(Dielectric, "dielectric");
62 NORI_NAMESPACE_END
Superclass of all bidirectional scattering distribution functions.
Definition: bsdf.h:63
Ideal dielectric BSDF.
Definition: dielectric.cpp:25
virtual float pdf(const BSDFQueryRecord &) const override
Compute the probability of sampling bRec.wo (conditioned on bRec.wi).
Definition: dielectric.cpp:40
virtual Color3f eval(const BSDFQueryRecord &) const override
Evaluate the BSDF for a pair of directions and measure specified in code bRec.
Definition: dielectric.cpp:35
virtual Color3f sample(BSDFQueryRecord &bRec, const Point2f &sample) const override
Sample the BSDF and return the importance weight (i.e. the value of the BSDF * cos(theta_o) divided b...
Definition: dielectric.cpp:45
virtual std::string toString() const override
Return a brief string summary of the instance (for debugging purposes)
Definition: dielectric.cpp:49
Simple exception class, which stores a human-readable error description.
Definition: common.h:148
This is an associative container used to supply the constructors of NoriObject subclasses with parame...
Definition: proplist.h:32
float getFloat(const std::string &name) const
Get a float property, and throw an exception if it does not exist.
Convenience data structure used to pass multiple parameters to the evaluation and sampling routines i...
Definition: bsdf.h:30
Represents a linear RGB color value.
Definition: color.h:29