Loading...
Searching...
No Matches
fresnel_schlick.h
Go to the documentation of this file.
1#ifndef _BBM_FRESNEL_SCHLICK_H_
2#define _BBM_FRESNEL_SCHLICK_H_
3
4#include "concepts/fresnel.h"
5#include "bbm/config.h"
6
7namespace bbm {
8 namespace fresnel {
9
10 /*******************************************************************/
11 /*! \brief Implements the Fresnel reflectance equation as proposed by
12 Schlick [Comp. Graph. Forum '94]:
13 https://doi.org/10.1111%2F1467-8659.1330233
14
15 \tparam CONF = bbm configuration
16
17 Implements: concepts::fresnel
18 ********************************************************************/
19 template<typename CONF, typename PARAM=ior::reflectance<Value_t<CONF>>> requires concepts::config<CONF>
20 struct schlick
21 {
23
24 //! \brief Fresnel Parameter Type
25 using parameter_type = PARAM;
26
27 /*****************************************************************/
28 /*! \brief Evaluate Fresnel reflectance
29
30 This method follows Schlick's approximation [Comp. Graph. Forum' 94]
31 of the Fresnel reflectance
32 (https://doi.org/10.1111%2F1467-8659.1330233). The method takes either
33 ior or reflectance (relies on auto-conversion to reflectance), as well
34 as the dot product between view and halfway vector (cosTheta) as
35 input.
36
37 \param param = reflectance at normal incidence
38 \param cosTheta = dot product between view and halfway.
39 \param mask = mask compute lines
40 \returns Approximate Fresnel reflectance
41 *******************************************************************/
42 static constexpr typename std::decay_t<parameter_type>::type eval(const parameter_type& param, const Value& cosTheta, Mask mask=true)
43 {
44 // quick bail out
45 if(bbm::none(mask)) return 0;
46
47 // do computations with ior::reflectance
49
50 // Done.
51 return bbm::select(mask, R0 + (Scalar(1.0) - R0) * bbm::pow(Scalar(1.0) - cosTheta, 5.0), 0);
52 }
53 };
54
55 // check Value_t variant
58
59 // check Spectrum_t variant
62
63 } // end fresnel namespace
64} // end bbm namespace
65
66
67#endif /* _BBM_FRESNEL_SCHLICK_H_ */
All BBM methods are defined to operate on a variety of value types and spectrum types....
fresnel concept
Definition: fresnel.h:27
fresnel contract
#define BBM_CHECK_CONCEPT(CONCEPTNAME, CLASSNAME,...)
Check a class for a concept with bbm::concepts::archetypes in the namespace.
Definition: macro.h:35
void fresnel(py::module &m, const std::string &prefix="")
Define a python interface for ior::ior and ior::reflectance given a value type T.
Definition: py_fresnel.h:22
Definition: aggregatebsdf.h:29
constexpr auto select(MASK &&mask, const A &a, const A &b)
Definition: backbone.h:255
typename get_config< T >::Value Value_t
Definition: config.h:67
typename get_config< T >::Spectrum Spectrum_t
Definition: config.h:68
Base declaration of attribute; further specialized below.
Definition: attribute.h:26
Implements the Fresnel reflectance equation as proposed by Schlick [Comp. Graph. Forum '94]: https://...
Definition: fresnel_schlick.h:21
PARAM parameter_type
Fresnel Parameter Type.
Definition: fresnel_schlick.h:25
static constexpr std::decay_t< parameter_type >::type eval(const parameter_type &param, const Value &cosTheta, Mask mask=true)
Evaluate Fresnel reflectance.
Definition: fresnel_schlick.h:42