Loading...
Searching...
No Matches
ndf.h
Go to the documentation of this file.
1#ifndef _BBM_NDF_CONCEPT_H_
2#define _BBM_NDF_CONCEPT_H_
3
4#include "concepts/config.h"
5#include "concepts/named.h"
6#include "concepts/util.h"
7
8/************************************************************************/
9/*! \file ndf.h
10
11 \brief Microfacet Normal Distribution contract
12*************************************************************************/
13
14namespace bbm {
15 namespace concepts {
16
17 /********************************************************************/
18 /*! \brief ndf concept
19
20 Each ndf requires:
21 + concepts::has_config
22 + concepts::named
23 + Value/Spectrum eval(const Vec3d& halfway, Mask mask=true) const
24 + Vec3d sample(const Vec3d& view, const Vec2d& xi, Mask mask=true) const
25 + Value pdf(const Vec3d& view, const Vec3d& m, Mask mask=true) const
26 + Value/Spectrum G1(const Vec3d& v, const Vec3d& m, Mask mask=true) const
27 *********************************************************************/
28 template<typename NDF>
29 concept ndf = requires(const NDF& ndf)
30 {
32 requires concepts::named<NDF>;
33
34 /******************************************************************/
35 /*! \brief Evaluate the NDF given an in and out direction
36
37 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
38 Value/Spectrum eval(const Vec3d& halfway, Mask mask=true) const
39 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40
41 \param halfway = hafway vector
42 \param mask = mask to enable/disable lanes [default = true]
43 \returns the resulting Value (or Spectrum) of the evaluation.
44 *******************************************************************/
45 { ndf.eval(std::declval<Vec3d_t<NDF>>(), std::declval<Mask_t<NDF>>()) } -> concepts::same_as_any<Value_t<NDF>, Spectrum_t<NDF>>;
46
47 //! \brief mask has default value
48 { ndf.eval(std::declval<Vec3d_t<NDF>>()) } -> concepts::same_as_any<Value_t<NDF>, Spectrum_t<NDF>>;
49
50
51 /******************************************************************/
52 /*! \brief Samples a microfacet normal with a pdf proportional to the NDF
53
54 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
55 Vec3d sample(const Vec3d& view, const Vec2d& xi, Mask mask=true) const
56 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57
58 \param view = view direction (to determine visible normals)
59 \param xi = two random variables stored in a Vec2d used to sample
60 \param mask = mask to enable/disable lanes [default=true]
61 \returns a Vec3d with the sampled microfacet normal vector.
62 *******************************************************************/
63 { ndf.sample(std::declval<Vec3d_t<NDF>>(), std::declval<Vec2d_t<NDF>>(), std::declval<Mask_t<NDF>>()) } -> std::same_as<Vec3d_t<NDF>>;
64
65 //! \brief mask has default value
66 { ndf.sample(std::declval<Vec3d_t<NDF>>(), std::declval<Vec2d_t<NDF>>()) } -> std::same_as<Vec3d_t<NDF>>;
67
68 /******************************************************************/
69 /*! \brief The pdf of the sampled microfacet normal.
70
71 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
72 Value pdf(const Vec3d& view, const Vec3d& m, Mask mask=true) const
73 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
75 \param view = view direction (to determine visible normals)
76 \param m = microfacet normal
77 \param mask = mask to enable/disable lanes [default=true]
78 \returns the pdf (Value) of sampling the halfway vector
79 *******************************************************************/
80 { ndf.pdf(std::declval<Vec3d_t<NDF>>(), std::declval<Vec3d_t<NDF>>(), std::declval<Mask_t<NDF>>()) } -> std::same_as<Value_t<NDF>>;
81
82 //! \brief has default mask value
83 { ndf.pdf(std::declval<Vec3d_t<NDF>>(), std::declval<Vec3d_t<NDF>>()) } -> std::same_as<Value_t<NDF>>;
84
85 /******************************************************************/
86 /*! \brief The unidirectional geometrical attenuation of shadowing and masking
87
88 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
89 Value/Spectrum G1(const Vec3d in, const Vec3d& out, const Vec3d& m, Mask mask=true) const
90 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91
92 \param v = incident/outgoing direction of transport
93 \param m = microfacet normal
94 \param mask = mask to enable/disable lanes [default=true]
95 \returns the geometrical attenuation factor (Value or Spectrum).
96 *******************************************************************/
97 { ndf.G1(std::declval<Vec3d_t<NDF>>(), std::declval<Vec3d_t<NDF>>(), std::declval<Mask_t<NDF>>()) } -> concepts::same_as_any<Value_t<NDF>, Spectrum_t<NDF>>;
98
99 //! \brief mask has default value
100 { ndf.G1(std::declval<Vec3d_t<NDF>>(), std::declval<Vec3d_t<NDF>>()) } -> concepts::same_as_any<Value_t<NDF>, Spectrum_t<NDF>>;
101 };
102
103
104 /********************************************************************/
105 /*! \brief ndf archetype for concept checking
106
107 \tparam CONF = specify config if a particular config is required. Default is archetype::config
108 *******************************************************************/
109 namespace archetype {
110 template<typename CONF=config> requires concepts::config<CONF>
111 struct ndf
112 {
113 using Config = CONF;
114 static constexpr string_literal name = "archetype::ndf";
115 Value_t<Config> eval(Vec3d_t<Config>, Mask_t<Config> = true) const;
116 Vec3d_t<Config> sample(Vec3d_t<Config>, Vec2d_t<Config>, Mask_t<Config> = true) const;
117 Value_t<Config> pdf(Vec3d_t<Config>, Vec3d_t<Config>, Mask_t<Config> = true) const;
118 Value_t<Config> G1(Vec3d_t<Config>, Vec3d_t<Config>, Mask_t<Config> = true) const;
119 };
120 } // end archetype namespace
121
123
124 } // end concepts namespace
125} // end bbm namespace
126
127#endif /* _BBM_NDF_CONCEPT_H_ */
128
config concept
Definition: config.h:31
has_config
Definition: config.h:53
A named class is a class that contains a static constexpr string_literal name.
Definition: named.h:19
ndf concept
Definition: ndf.h:29
true if type is the same as any of the listed types
Definition: util.h:31
config contract
named (class) concept.
#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
typename get_config< T >::Value Value_t
Definition: config.h:67
Definition: ndf.h:112
Value_t< Config > G1(Vec3d_t< Config >, Vec3d_t< Config >, Mask_t< Config >=true) const
Value_t< Config > eval(Vec3d_t< Config >, Mask_t< Config >=true) const
Value_t< Config > pdf(Vec3d_t< Config >, Vec3d_t< Config >, Mask_t< Config >=true) const
Vec3d_t< Config > sample(Vec3d_t< Config >, Vec2d_t< Config >, Mask_t< Config >=true) const
static constexpr string_literal name
Definition: ndf.h:114
CONF Config
Definition: ndf.h:113
Definition: string_literal.h:16
Additional basic helper concepts.