Nori  23
bsdf.h
1 /*
2  This file is part of Nori, a simple educational ray tracer
3 
4  Copyright (c) 2015 by Wenzel Jakob, 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 #if !defined(__NORI_BSDF_H)
20 #define __NORI_BSDF_H
21 
22 #include <nori/object.h>
23 
24 NORI_NAMESPACE_BEGIN
25 
33 
36 
38  float eta;
39 
41  EMeasure measure;
42 
45  : wi(wi), measure(EUnknownMeasure) { }
46 
49  const Vector3f &wo, EMeasure measure)
50  : wi(wi), wo(wo), measure(measure) { }
51 
52 
58 };
59 
63 class BSDF : public NoriObject {
64 public:
79  virtual Color3f sample(BSDFQueryRecord &bRec, const Point2f &sample) const = 0;
80 
90  virtual Color3f eval(const BSDFQueryRecord &bRec) const = 0;
91 
107  virtual float pdf(const BSDFQueryRecord &bRec) const = 0;
108 
113  virtual EClassType getClassType() const override { return EBSDF; }
114 
120  virtual bool isDiffuse() const { return false; }
121 };
122 
123 NORI_NAMESPACE_END
124 
125 #endif /* __NORI_BSDF_H */
Superclass of all bidirectional scattering distribution functions.
Definition: bsdf.h:63
virtual Color3f eval(const BSDFQueryRecord &bRec) const =0
Evaluate the BSDF for a pair of directions and measure specified in code bRec.
virtual EClassType getClassType() const override
Return the type of object (i.e. Mesh/BSDF/etc.) provided by this instance.
Definition: bsdf.h:113
virtual Color3f sample(BSDFQueryRecord &bRec, const Point2f &sample) const =0
Sample the BSDF and return the importance weight (i.e. the value of the BSDF * cos(theta_o) divided b...
virtual float pdf(const BSDFQueryRecord &bRec) const =0
Compute the probability of sampling bRec.wo (conditioned on bRec.wi).
virtual bool isDiffuse() const
Return whether or not this BRDF is diffuse. This is primarily used by photon mapping to decide whethe...
Definition: bsdf.h:120
Base class of all objects.
Definition: object.h:32
Convenience data structure used to pass multiple parameters to the evaluation and sampling routines i...
Definition: bsdf.h:30
Vector3f wo
Outgoing direction (in the local frame)
Definition: bsdf.h:35
BSDFQueryRecord(const Vector3f &wi, const Vector3f &wo, EMeasure measure)
Create a new record for querying the BSDF.
Definition: bsdf.h:48
Vector3f wi
Incident direction (in the local frame)
Definition: bsdf.h:32
Point3f p
Point associated with the point.
Definition: bsdf.h:57
BSDFQueryRecord(const Vector3f &wi)
Create a new record for sampling the BSDF.
Definition: bsdf.h:44
EMeasure measure
Measure associated with the sample.
Definition: bsdf.h:41
Point2f uv
Definition: bsdf.h:55
float eta
Relative refractive index in the sampled direction.
Definition: bsdf.h:38
Represents a linear RGB color value.
Definition: color.h:29