Loading...
Searching...
No Matches
bsdf.h
Go to the documentation of this file.
1#ifndef _BBM_BSDF_H_
2#define _BBM_BSDF_H_
3
4#include "concepts/bsdf.h"
5
6#include "bbm/config.h"
7#include "bbm/bsdf_base.h"
9
10/************************************************************************/
11/*! \file bsdf.h
12 \brief Connects a BSDF model and a BSDF.
13
14 This class provides a simple interface for connecting BSDF models
15 (without virtual functions) to a BSDF (with virtual functions). In
16 essence, this class just passes through the method call to the BSDF
17 model.
18*************************************************************************/
19
20namespace bbm {
21
22
23 /**********************************************************************/
24 /*! \brief BSDF implementation of a BSDF model
25
26 \tparam BSDFMODEL = the BSDF model to transform into a BSDF
27 ***********************************************************************/
28 template<typename BSDFMODEL> requires concepts::bsdfmodel<BSDFMODEL>
29 class bsdf : virtual public bsdf_base< get_config<BSDFMODEL>>, public BSDFMODEL
30 {
31 public:
32 BBM_BASETYPES(BSDFMODEL);
33 BBM_IMPORT_CONFIG( BSDFMODEL );
34 static constexpr string_literal name = "Bsdf";
36
37 //! \brief Inherit all constructors
38 using BSDFMODEL::BSDFMODEL;
39
40 //! \brief Construct directly from a BSDF model
41 bsdf(const BSDFMODEL& model) : BSDFMODEL(model) {}
42
43 //! \brief Assignment operator
44 using BSDFMODEL::operator=;
45
46 /********************************************************************/
47 /*! \brief Virtual passthrough of eval function
48
49 \param in = incoming direction
50 \param out = exitant direction
51 \param component = which reflectance component to eval
52 \param unit = unit of computation
53 \param mask = mask to enable/disable lanes
54 \returns the resulting Spectrum of the evaluation.
55 ********************************************************************/
56 virtual Spectrum eval(const Vec3d& in, const Vec3d& out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
57 {
58 return BSDFMODEL::eval(in, out, component, unit, mask);
59 }
60
61
62 /********************************************************************/
63 /*! \brief Virtual passthrough of sample function
64
65 \param out = the outgoing direction
66 \param xi = two random variables stored in a Vec2d used to sample
67 \param component = which reflectance component to sample
68 \param unit = unit of computation
69 \param mask = mask to enable/disable lanes
70 \returns a BsdfSample that contains the sampled direction
71 and the corresponding pdf.
72 ********************************************************************/
73 virtual BsdfSample sample(const Vec3d& out, const Vec2d& xi, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
74 {
75 return BSDFMODEL::sample(out, xi, component, unit, mask);
76 }
77
78
79 /********************************************************************/
80 /*! \brief Virtual passthrough of the pdf function
81
82 \param in = the incoming sampled direction
83 \param out = the exitant (given) direction
84 \param component = which reflectance component was sampled
85 \param unit = unit of computation
86 \param mask = mask to enable/disable lanes
87 \returns the pdf of samling the in-out direction conbination.
88 *********************************************************************/
89 virtual Value pdf(const Vec3d& in, const Vec3d& out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
90 {
91 return BSDFMODEL::pdf(in, out, component, unit, mask);
92 }
93
94
95 /********************************************************************/
96 /*! \brief Virtual passthrough of the hemispherical reflectance function
97
98 \param out = the outgoing direction
99 \param component = which reflectance component to eval
100 \param unit = unit of computation
101 \param mask = mask to enable/disable lanes
102 \returns the approximate hemispherical reflectance (Spectrum) of the BSDF
103 *********************************************************************/
104 virtual Spectrum reflectance(const Vec3d& out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
105 {
106 return BSDFMODEL::reflectance(out, component, unit, mask);
107 }
108
109
110 /********************************************************************/
111 /*! \brief Pipe toString to BSDFMODEL
112 ********************************************************************/
113 virtual std::string toString(void) const override final
114 {
115 return bbm::toString( static_cast<const BSDFMODEL&>(*this) );
116 }
117
118 /*********************************************************************/
119 /*! \brief construct the bsdf from a string
120 *********************************************************************/
121 static bsdf fromString(const std::string& str)
122 {
123 return bsdf( bbm::fromString<BSDFMODEL>(str) );
124 }
125
126 /*********************************************************************/
127 /*! \name Parameter Enumeration
128 *********************************************************************/
130 {
131 return bbm::parameter_values(dynamic_cast<BSDFMODEL&>(*this), flags);
132 }
133
135 {
136 return bbm::parameter_values(dynamic_cast<const BSDFMODEL&>(*this), flags);
137 }
138
140 {
141 return bbm::parameter_default_values(dynamic_cast<const BSDFMODEL&>(*this), flags);
142 }
143
145 {
146 return bbm::parameter_lower_bound(dynamic_cast<const BSDFMODEL&>(*this), flags);
147 }
148
150 {
151 return bbm::parameter_upper_bound(dynamic_cast<const BSDFMODEL&>(*this), flags);
152 }
153 //! @}
154 };
155
157
158} // end bbm namespace
159
160#endif /* _BBM_BSDF_H_ */
All BBM methods are defined to operate on a variety of value types and spectrum types....
Abstract base definition of a BSDF (with virtual functions)
Enumerate all BSDF parameters (e.g., stack in a vector).
BSDF implementation of a BSDF model.
Definition: bsdf.h:30
virtual bbm::vector< Value > parameter_upper_bound(bsdf_attr flags=bsdf_attr::All) const override final
Definition: bsdf.h:149
virtual bbm::vector< Value > parameter_lower_bound(bsdf_attr flags=bsdf_attr::All) const override final
Definition: bsdf.h:144
virtual bbm::vector< Value > parameter_default_values(bsdf_attr flags=bsdf_attr::All) const override final
Definition: bsdf.h:139
virtual Value pdf(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
Virtual passthrough of the pdf function.
Definition: bsdf.h:89
virtual Spectrum eval(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
Virtual passthrough of eval function.
Definition: bsdf.h:56
virtual BsdfSample sample(const Vec3d &out, const Vec2d &xi, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
Virtual passthrough of sample function.
Definition: bsdf.h:73
BBM_BSDF_FORWARD
Definition: bsdf.h:35
BBM_BASETYPES(BSDFMODEL)
virtual bbm::vector< Value & > parameter_values(bsdf_attr flags=bsdf_attr::All) override final
Definition: bsdf.h:129
BBM_IMPORT_CONFIG(BSDFMODEL)
virtual bbm::vector< const Value & > parameter_values(bsdf_attr flags=bsdf_attr::All) const override final
Definition: bsdf.h:134
virtual Spectrum reflectance(const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const override final
Virtual passthrough of the hemispherical reflectance function.
Definition: bsdf.h:104
static constexpr string_literal name
Definition: bsdf.h:34
bsdf(const BSDFMODEL &model)
Construct directly from a BSDF model.
Definition: bsdf.h:41
virtual std::string toString(void) const override final
Pipe toString to BSDFMODEL.
Definition: bsdf.h:113
static bsdf fromString(const std::string &str)
construct the bsdf from a string
Definition: bsdf.h:121
Definition: vector_util.h:27
bsdf concept
Definition: bsdf.h:29
bsdf contract: virtual interface wrapper around bsdfmodels
#define BBM_CHECK_CONCEPT(CONCEPTNAME, CLASSNAME,...)
Check a class for a concept with bbm::concepts::archetypes in the namespace.
Definition: macro.h:35
Definition: aggregatebsdf.h:29
auto parameter_default_values(MODEL &&model, bsdf_attr flag=bsdf_attr::All)
Enumerate the default parameters of a BSDF model in a vector.
Definition: bsdf_enumerate.h:142
auto parameter_upper_bound(MODEL &&model, bsdf_attr flag=bsdf_attr::All)
Enumerate the upper bound of the parameters of a BSDF model in a vector.
Definition: bsdf_enumerate.h:213
std::string toString(const T &)
toString alias
Definition: stringconvert.h:594
auto parameter_lower_bound(MODEL &&model, bsdf_attr flag=bsdf_attr::All)
Enumerate the lower bound of the parameters of a BSDF model in a vector.
Definition: bsdf_enumerate.h:178
auto parameter_values(MODEL &&model, bsdf_attr flag=bsdf_attr::All)
Enumerate the parameters of a BSDF model in a vector.
Definition: bsdf_enumerate.h:103
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
Definition: string_literal.h:16