25 template<
typename CONF, string_literal NAME=
"Phong">
requires concepts::config<CONF>
52 if(bbm::none(mask))
return Spectrum(0);
55 Value cosAlpha = bbm::max(bbm::dot(
reflect(in), out), 0);
84 mask &= (xi[0] >= 0) && (xi[1] >= 0) && (xi[0] <= 1) && (xi[1] <= 1);
87 if(bbm::none(mask))
return sample;
90 Vec2d csp = bbm::cossin(xi[0] * Constants::Pi(2));
91 Value cosTheta = bbm::pow(xi[1], 1.0 / (
sharpness + 1));
92 Value sinTheta = bbm::safe_sqrt( 1.0 - cosTheta*cosTheta );
127 if(bbm::none(mask))
return 0;
130 Value cosAlpha = bbm::max(bbm::dot(
reflect(in), out), 0);
All includes and helpers needed for declaring new bsdfmodels.
#define BBM_EXPORT_BSDFMODEL(BsdfModel)
Definition: bbm_fromstring.h:49
The modified Phong BSDF model. This is the classic Phong BSDF model with appropriate normalization an...
Definition: phong.h:27
Spectrum eval(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t=unit_t::Radiance, Mask mask=true) const
Evaluate the BSDF for a given in and out direction.
Definition: phong.h:43
BsdfSample sample(const Vec3d &out, const Vec2d &xi, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const
Sample the BSDF given a direction and two random variables.
Definition: phong.h:76
BBM_ATTRIBUTES(albedo, sharpness)
specular_sharpness< Value > sharpness
Definition: phong.h:156
BBM_BSDF_FORWARD
Definition: phong.h:31
BBM_DEFAULT_CONSTRUCTOR(phong)
Default constructor.
Definition: phong.h:162
specular_scale< Spectrum > albedo
Definition: phong.h:155
Value pdf(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t=unit_t::Radiance, Mask mask=true) const
Compute the pdf given an in and out direction.
Definition: phong.h:118
Spectrum reflectance(const Vec3d &, BsdfFlag component=bsdf_flag::All, unit_t=unit_t::Radiance, Mask mask=true) const
Return the (approximate) hemispherical reflectance of the BSDF.
Definition: phong.h:146
static constexpr string_literal name
Definition: phong.h:30
bsdfmodel concept
Definition: bsdfmodel.h:33
#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
mat3d< std::decay_t< T > > toGlobalShadingFrame(const vec3d< T > &normal)
Construct a local shading frame to global frame transformation given a normal direction.
Definition: shading_frame.h:26
vec3d< T > reflect(const vec3d< T > &v, const vec3d< T > &normal)
Reflects a 3D vector.
Definition: vec_transform.h:44
constexpr auto is_set(const FLAGNAME &a, const FLAG &flag)
Check if all in 'flag' are also set in 'a'; compatible with packet types.
Definition: flags.h:100
unit_t
Light Unit.
Definition: unit.h:21
Base declaration of attribute; further specialized below.
Definition: attribute.h:26
Definition: string_literal.h:16