Nori  23
arealight.cpp
1 /*
2  This file is part of Nori, a simple educational ray tracer
3 
4  Copyright (c) 2015 by Romain Prévost
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/emitter.h>
20 #include <nori/warp.h>
21 #include <nori/shape.h>
22 
23 NORI_NAMESPACE_BEGIN
24 
25 class AreaEmitter : public Emitter {
26 public:
27  AreaEmitter(const PropertyList &props) {
28  m_radiance = props.getColor("radiance");
29  }
30 
31  virtual std::string toString() const override {
32  return tfm::format(
33  "AreaLight[\n"
34  " radiance = %s,\n"
35  "]",
36  m_radiance.toString());
37  }
38 
39  virtual Color3f eval(const EmitterQueryRecord & lRec) const override {
40  if(!m_shape)
41  throw NoriException("There is no shape attached to this Area light!");
42 
43  throw NoriException("To implement...");
44  }
45 
46  virtual Color3f sample(EmitterQueryRecord & lRec, const Point2f & sample) const override {
47  if(!m_shape)
48  throw NoriException("There is no shape attached to this Area light!");
49 
50  throw NoriException("To implement...");
51  }
52 
53  virtual float pdf(const EmitterQueryRecord &lRec) const override {
54  if(!m_shape)
55  throw NoriException("There is no shape attached to this Area light!");
56 
57  throw NoriException("To implement...");
58  }
59 
60 
61  virtual Color3f samplePhoton(Ray3f &ray, const Point2f &sample1, const Point2f &sample2) const override {
62  throw NoriException("To implement...");
63  }
64 
65 
66 protected:
67  Color3f m_radiance;
68 };
69 
70 NORI_REGISTER_CLASS(AreaEmitter, "area")
71 NORI_NAMESPACE_END
virtual float pdf(const EmitterQueryRecord &lRec) const override
Compute the probability of sampling lRec.p.
Definition: arealight.cpp:53
virtual Color3f sample(EmitterQueryRecord &lRec, const Point2f &sample) const override
Sample the emitter and return the importance weight (i.e. the value of the Emitter divided by the pro...
Definition: arealight.cpp:46
virtual Color3f samplePhoton(Ray3f &ray, const Point2f &sample1, const Point2f &sample2) const override
Sample a photon.
Definition: arealight.cpp:61
virtual std::string toString() const override
Return a brief string summary of the instance (for debugging purposes)
Definition: arealight.cpp:31
virtual Color3f eval(const EmitterQueryRecord &lRec) const override
Evaluate the emitter.
Definition: arealight.cpp:39
Superclass of all emitters.
Definition: emitter.h:64
Shape * m_shape
Pointer to the shape if the emitter is attached to a shape.
Definition: emitter.h:129
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
Color3f getColor(const std::string &name) const
Get a color property, and throw an exception if it does not exist.
Represents a linear RGB color value.
Definition: color.h:29
std::string toString() const
Return a human-readable string summary.
Definition: color.h:79
Data record for conveniently querying and sampling the direct illumination technique implemented by a...
Definition: emitter.h:31