30 template<
typename CONF, string_literal NAME=
"Low">
requires concepts::config<CONF>
50 if(bbm::none(mask))
return 0;
67 Vec3d
sample(
const Vec3d& ,
const Vec2d& xi, Mask mask=
true)
const
70 mask &= (xi[0] >= 0) && (xi[1] >= 0) && (xi[0] <= 1) && (xi[1] <= 1);
73 if(bbm::none(mask))
return 0.0;
76 Value term =
bbm::select( bbm::abs(
C-1) < Constants::Epsilon(),
77 bbm::exp( xi[0] * bbm::log(1.0 +
B) ),
78 bbm::pow(1.0 + xi[0] * (bbm::pow(1.0+
B, 1.0-
C) - 1.0), -1.0 / (
C - 1.0))
80 Value cosTheta = (1.0 +
B - term) /
B;
81 Value sinTheta = bbm::safe_sqrt( 1.0 - cosTheta*cosTheta );
82 Vec2d csp = bbm::cossin( xi[1] * Constants::Pi(2) );
96 Value
pdf(
const Vec3d& ,
const Vec3d& m, Mask mask=
true)
const
102 if(bbm::none(mask))
return 0;
105 Value normalization =
bbm::select( bbm::abs(
C-1) < Constants::Epsilon(),
106 1.0f / bbm::log(1.0+
B),
107 (
C-1.0) / (1.0 - bbm::pow(1.0+
B, 1.0-
C))
109 Value
pdf =
eval(m, mask) *
B * (Constants::InvPi(0.5) * normalization);
129 Value
G1(
const Vec3d& ,
const Vec3d& , Mask =
true)
const
All includes and helpers needed for declaring new ndfs.
The Low Microfacet distribution.
Definition: low.h:32
bsdf_parameter< Value, bsdf_attr::SpecularParameter > B
Definition: low.h:137
Value pdf(const Vec3d &, const Vec3d &m, Mask mask=true) const
PDF of sampling the NDF.
Definition: low.h:96
Value eval(const Vec3d &halfway, Mask mask=true) const
Evaluate the NDF.
Definition: low.h:44
Vec3d sample(const Vec3d &, const Vec2d &xi, Mask mask=true) const
Sample the NDF.
Definition: low.h:67
bsdf_parameter< Value, bsdf_attr::SpecularParameter > C
Definition: low.h:138
Value G1(const Vec3d &, const Vec3d &, Mask=true) const
Monodirectional shadowing and masking factor.
Definition: low.h:129
static constexpr string_literal name
Definition: low.h:35
BBM_DEFAULT_CONSTRUCTOR(low)
Default constructor.
Definition: low.h:144
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 const vec3d< T > expand(const vec2d< T > &v, V &&a)
Definition: vec.h:55
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
vec3d< T > halfway(const vec3d< T > &a, const vec3d< T > &b)
Halfway vector (3D)
Definition: vec_transform.h:77
Base declaration of attribute; further specialized below.
Definition: attribute.h:26
Definition: string_literal.h:16