Nori  24
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 
48  : wi(wi), measure(EUnknownMeasure), uv(uv) { }
49 
52  const Vector3f &wo, EMeasure measure, const Point2f& uv)
53  : wi(wi), wo(wo), measure(measure), uv(uv) { }
54 
55 };
56 
60 class BSDF : public NoriObject {
61 public:
76  virtual Color3f sample(BSDFQueryRecord &bRec, const Point2f &sample) const = 0;
77 
87  virtual Color3f eval(const BSDFQueryRecord &bRec) const = 0;
88 
104  virtual float pdf(const BSDFQueryRecord &bRec) const = 0;
105 
110  virtual EClassType getClassType() const override { return EBSDF; }
111 
117  virtual bool isDiffuse() const { return false; }
118 };
119 
120 NORI_NAMESPACE_END
121 
122 #endif /* __NORI_BSDF_H */
Superclass of all bidirectional scattering distribution functions.
Definition: bsdf.h:60
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:110
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:117
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, const Point2f &uv)
Create a new record for querying the BSDF.
Definition: bsdf.h:51
Vector3f wi
Incident direction (in the local frame)
Definition: bsdf.h:32
EMeasure measure
Measure associated with the sample.
Definition: bsdf.h:41
Point2f uv
UV associated with the point.
Definition: bsdf.h:44
BSDFQueryRecord(const Vector3f &wi, const Point2f &uv)
Create a new record for sampling the BSDF.
Definition: bsdf.h:47
float eta
Relative refractive index in the sampled direction.
Definition: bsdf.h:38
Represents a linear RGB color value.
Definition: color.h:29