Loading...
Searching...
No Matches
uncorrelated.h
Go to the documentation of this file.
1#ifndef _BBM_MASKINGSHADOWING_UNCORRELATED_H_
2#define _BBM_MASKINGSHADOWING_UNCORRELATED_H_
3
5
6/************************************************************************/
7/*! \file uncorrelated.h
8
9 \brief Uncorrelated joint masking and shadowing. Follows Eq. 98 from
10 "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"
11 [Heitz 2014]: https://jcgt.org/published/0003/02/03/
12*************************************************************************/
13
14namespace bbm {
15 namespace maskingshadowing {
16
17 /*******************************************************************/
18 /*! \brief Uncorrelated joint masking and shadowing.
19
20 Follows Eq. 98 from "Understanding the Masking-Shadowing Function in
21 Microfacet-Based BRDFs" [Heitz 2014]:
22 https://jcgt.org/published/0003/02/03/
23 ********************************************************************/
24 template<typename CONF> requires concepts::config<CONF>
26 {
28
29 template<typename NDF> requires concepts::ndf<NDF> && concepts::matching_config<CONF, NDF>
30 static constexpr auto eval(const NDF& ndf, const Vec3d& in, const Vec3d& out, const Vec3d& m, Mask mask=true)
31 {
32 using return_t = decltype(ndf.G1(in, m, mask));
33
34 // check dot
35 mask &= (bbm::dot(in, m) > 0) && (bbm::dot(out, m) > 0);
36
37 // Quick bailout
38 if(bbm::none(mask)) return return_t(0);
39
40 // Done.
41 return bbm::select(mask, ndf.G1(in, m, mask) * ndf.G1(out, m, mask), 0);
42 }
43 };
44
46
47 } // end maskingshadowing namespace
48} // end bbm namespace
49
50#endif /* _BBM_MASKINGSHADOWING_UNCORRELATED_H_ */
All necessary include files for defining new joint masking and shadowing functions.
maskingshadowing concept
Definition: maskingshadowing.h:24
matching_config concept
Definition: config.h:63
ndf concept
Definition: ndf.h:29
#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
constexpr auto select(MASK &&mask, const A &a, const A &b)
Definition: backbone.h:255
Uncorrelated joint masking and shadowing.
Definition: uncorrelated.h:26
static constexpr auto eval(const NDF &ndf, const Vec3d &in, const Vec3d &out, const Vec3d &m, Mask mask=true)
Definition: uncorrelated.h:30