1#ifndef _BBM_PHONG_NDF_H_
2#define _BBM_PHONG_NDF_H_
26 template<
typename CONF, string_literal NAME=
"Phong">
requires concepts::config<CONF>
46 if(bbm::none(mask))
return 0;
49 Value normalization = (
sharpness + 2) / Constants::Pi(2);
64 Vec3d
sample(
const Vec3d& ,
const Vec2d& xi, Mask mask=
true)
const
67 mask &= (xi[0] >= 0) && (xi[1] >= 0) && (xi[0] <= 1) && (xi[1] <= 1);
70 if(bbm::none(mask))
return 0;
73 Value cosTheta = bbm::pow( xi[0], 1.0 / (
sharpness + 2) );
74 Value sinTheta = bbm::safe_sqrt(1.0 - cosTheta*cosTheta);
75 Vec2d csp = bbm::cossin( xi[1] * Constants::Pi(2) );
89 Value
pdf(
const Vec3d& ,
const Vec3d& m, Mask mask=
true)
const
95 if(bbm::none(mask))
return 0;
115 Value
G1(
const Vec3d& v,
const Vec3d& m, Mask mask=
true)
const
118 mask &= (
vec::z(v) > 0) && (bbm::dot(v, m) > 0);
121 if(bbm::none(mask))
return 0;
127 Value g =
bbm::select(a < 1.6, (3.535*a + 2.181*a*a) / (1 + 2.276*a + 2.577*a*a), 1.0);
All includes and helpers needed for declaring new ndfs.
The Phong Microfacet distribution.
Definition: phong.h:28
Value G1(const Vec3d &v, const Vec3d &m, Mask mask=true) const
Monodirectional shadowing and masking term.
Definition: phong.h:115
specular_sharpness< Value > sharpness
Definition: phong.h:136
Value pdf(const Vec3d &, const Vec3d &m, Mask mask=true) const
PDF of sampling the NDF.
Definition: phong.h:89
Value eval(const Vec3d &halfway, Mask mask=true) const
Evaluate the NDF.
Definition: phong.h:40
Vec3d sample(const Vec3d &, const Vec2d &xi, Mask mask=true) const
Sample the NDF.
Definition: phong.h:64
BBM_ATTRIBUTES(sharpness)
BBM_DEFAULT_CONSTRUCTOR(phong)
Default constructor.
Definition: phong.h:142
static constexpr string_literal name
Definition: phong.h:31
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
T cosTheta(const vec2d< T > &v)
Definition: spherical.h:109
T tanTheta(const vec2d< T > &v)
Definition: spherical.h:177
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