Loading...
Searching...
No Matches
bsdf_base.h
Go to the documentation of this file.
1#ifndef _BBM_BSDF_BASE_H_
2#define _BBM_BSDF_BASE_H_
3
4#include <string>
5
6#include "concepts/bsdf.h"
7#include "util/vector_util.h"
8#include "bbm/bsdfmodel.h"
9
10
11/***********************************************************************/
12/*! \file bsdf_base.h
13 \brief Abstract base definition of a BSDF (with virtual functions)
14
15 The key difference between a bsdfmodel and the bsdf_model below
16 is that bsdfmodel does not feature virtual functions, and thus which
17 function to call is deciced at compile time. bsdf_base on the other
18 hand declares all methods as virtual, and thus which method to call
19 is decided that run-time.
20
21************************************************************************/
22
23namespace bbm {
24
25 /********************************************************************/
26 /* \brief Abstract base class of BSDFs (with virtual methods)
27
28 Each BSDF implements four __virtual__ method classes (each having two
29 methods ending on _radiance or _importance):
30
31 + \b eval: evaluates the BSDF given an in and out direction.
32 + \b sample: samples the in direction with a pdf proportional BSDF given
33 an out direction and 2 random values
34 + \b pdf: the PDF of sampling a given in and out direction
35 + \b albedo: the albedo of the BSDF given an out direction
36
37 In addition virtual utility methods are included:
38 + \b toString: fancy print the bsdf
39 + \b parameter_values : get the bsdf model parameters
40 + \b parameter_default_values : get the default bsdf model parameters
41 + \b parameter_lower_bound: lower bound of the bsdf model parameters
42 + \b parameter_upper_bound: upper bound of the bsdf model parameters
43
44 A bsdf_base is also a bsdfmodel as it immplements the full interface.
45
46 Similar as with bsdfmodels, brdfs follow the in-out convention of
47 Eric Veach, namely 'in' is the sampled direction, and transport flows
48 from -in to out. The physical meaning of 'in' and 'out' switches
49 between the regular bsdf (Radiance) and the adjoint bsdf (Importance).
50
51 Implements: concepts::bsdf
52 **********************************************************************/
53 template<typename CONF> requires concepts::config<CONF>
54 struct bsdf_base
55 {
56 public:
58 static constexpr string_literal name = "bsdf_base";
60
61 //! \brief empty virtual destructor
62 virtual ~bsdf_base(void) {}
63
64 /*******************************************************************/
65 /*! \brief Evaluate the BSDF given an in and out direction
66
67 \param in = incoming direction of transport
68 \param out = exitant direction of transport
69 \param component = which reflectance component to eval
70 \param unit = unit of computation
71 \param mask = mask to enable/disable lanes
72 \returns the resulting Spectrum of the evaluation.
73
74 IMPORTANT: The foreshortning (i.e., cosine) is __NOT__ included.
75 ********************************************************************/
76 virtual Spectrum eval(const Vec3d& in, const Vec3d& out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const = 0;
77
78 /*******************************************************************/
79 /*! \brief Samples the BSDF given an out direction and 2 random variables.
80
81 \param out = the outgoing direction
82 \param xi = two random variables stored in a Vec2d used to sample
83 \param component = which reflectance component to sample
84 \param unit = unit of computation
85 \param mask = mask to enable/disable lanes
86 \returns a BsdfSample that contains the sampled direction
87 and the corresponding pdf.
88 ********************************************************************/
89 virtual BsdfSample sample(const Vec3d& out, const Vec2d& xi, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const = 0;
90
91
92 /*******************************************************************/
93 /*! \brief The pdf of the in-out direction combination.
94
95 \param in = the incoming sampled direction
96 \param out = the exitant (given) direction
97 \param component = which reflectance component was sampled
98 \param unit = unit of computation
99 \param mask = mask to enable/disable lanes
100 \returns the pdf of samling the in-out direction conbination.
101 ********************************************************************/
102 virtual Value pdf(const Vec3d& in, const Vec3d& out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const = 0;
103
104
105 /*******************************************************************/
106 /*! \brief the (approximate) hemispherical reflectance of the BSDF
107
108 \param out = the outgoing direction
109 \param component = which reflectance component to eval
110 \param unit = unit of computation
111 \param mask = mask to enable/disable lanes
112 \returns the approximate hemispherical reflectance (Spectrum) of the BSDF
113 ********************************************************************/
114 virtual Spectrum reflectance(const Vec3d& out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const = 0;
115
116
117 /*******************************************************************/
118 /*! \brief Fancy print the BSDF to a string
119 *******************************************************************/
120 virtual std::string toString(void) const = 0;
121
122 /*******************************************************************/
123 /*! @{ \name Parameter Enumeration
124 *******************************************************************/
130 //! @}
131
132 };
133
134 /////////////////////
135 // ostream support
136 /////////////////////
137 template<typename BSDF> requires bbm::concepts::bsdf<BSDF>
138 std::ostream& operator<<(std::ostream& s, const BSDF& bsdf)
139 {
140 s << bbm::toString(bsdf);
141 return s;
142 }
143
144} // end bbm namespace
145
146#endif /* _BBM_BSDF_BASE_H_ */
All includes and helpers needed for declaring new bsdfmodels.
BSDF implementation of a BSDF model.
Definition: bsdf.h:30
Definition: vector_util.h:27
bsdf concept
Definition: bsdf.h:29
bsdf contract: virtual interface wrapper around bsdfmodels
Definition: aggregatebsdf.h:29
std::ostream & operator<<(std::ostream &s, const BSDF &bsdf)
Definition: bsdf_base.h:138
std::string toString(const T &)
toString alias
Definition: stringconvert.h:594
bsdf_attr
Attribute Property Flags.
Definition: bsdf_attr_flag.h:17
unit_t
Light Unit.
Definition: unit.h:21
Forward declaration.
Definition: bsdf_base.h:55
virtual bbm::vector< Value > parameter_lower_bound(bsdf_attr flags=bsdf_attr::All) const =0
BBM_IMPORT_CONFIG(CONF)
virtual Spectrum eval(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const =0
Evaluate the BSDF given an in and out direction.
BBM_BSDF_FORWARD
Definition: bsdf_base.h:59
virtual BsdfSample sample(const Vec3d &out, const Vec2d &xi, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const =0
Samples the BSDF given an out direction and 2 random variables.
virtual bbm::vector< Value & > parameter_values(bsdf_attr flags=bsdf_attr::All)=0
virtual bbm::vector< const Value & > parameter_values(bsdf_attr flags=bsdf_attr::All) const =0
virtual Value pdf(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const =0
The pdf of the in-out direction combination.
virtual Spectrum reflectance(const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const =0
the (approximate) hemispherical reflectance of the BSDF
virtual ~bsdf_base(void)
empty virtual destructor
Definition: bsdf_base.h:62
static constexpr string_literal name
Definition: bsdf_base.h:58
virtual bbm::vector< Value > parameter_upper_bound(bsdf_attr flags=bsdf_attr::All) const =0
virtual std::string toString(void) const =0
Fancy print the BSDF to a string.
virtual bbm::vector< Value > parameter_default_values(bsdf_attr flags=bsdf_attr::All) const =0
Definition: string_literal.h:16
Extensions for the STL vector class.