Loading...
Searching...
No Matches
vgroove.h
Go to the documentation of this file.
1#ifndef _BBM_MASKINGSHADOWING_VGROOVE_H_
2#define _BBM_MASKINGSHADOWING_VGROOVE_H_
3
5
6/************************************************************************/
7/*! \file vgroove.h
8
9 \brief Vgroove shadowing and masking. Based on Torrance and Sparrow, 19967,
10 "Theory for off-specular reflection from roughened surfaces":
11 https://dl.acm.org/doi/10.5555/136913.136924
12*************************************************************************/
13
14namespace bbm {
15 namespace maskingshadowing {
16
17 /********************************************************************/
18 /*! \brief Vgroove shadowing and masking.
19
20 Based on Torrance and Sparrow, 19967, "Theory for off-specular
21 reflection from roughened surfaces":
22 https://dl.acm.org/doi/10.5555/136913.136924
23 *********************************************************************/
24 template<typename CONF> requires concepts::config<CONF>
25 struct vgroove
26 {
28
29 template<typename NDF> requires concepts::ndf<NDF> && concepts::matching_config<CONF, NDF>
30 static constexpr Value 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 // eval.
41 auto G = bbm::min( 1.0, bbm::min(
42 2.0 * vec::z(m) * vec::z(in) / bbm::dot(in, m),
43 2.0 * vec::z(m) * vec::z(out) / bbm::dot(out, m)) );
44
45 // Done.
46 return return_t( bbm::select(mask, G, 0) );
47 }
48 };
49
51
52 } // end maskingshadowing namespace
53} // end bbm namespace
54
55#endif /* _BBM_MASKINGSHADOWING_VGROOVE_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
constexpr decltype(auto) z(bbm::vec3d< T > &v)
Definition: vec.h:26
Definition: aggregatebsdf.h:29
constexpr auto select(MASK &&mask, const A &a, const A &b)
Definition: backbone.h:255
Vgroove shadowing and masking.
Definition: vgroove.h:26
static constexpr Value eval(const NDF &ndf, const Vec3d &in, const Vec3d &out, const Vec3d &m, Mask mask=true)
Definition: vgroove.h:30