1#ifndef _BBM_ASHIKHMIN_SHIRLEY_H_
2#define _BBM_ASHIKHMIN_SHIRLEY_H_
29 template<
typename CONF,
30 typename Fresnel = fresnel::schlick<CONF, ior::reflectance<Spectrum_t<CONF>>>,
32 string_literal NAME=
"AshikhminShirley"
33 >
requires concepts::config<CONF> && concepts::fresnel<Fresnel> && concepts::matching_config<CONF, Fresnel>
60 if(bbm::none(mask))
return Spectrum(0);
64 Value h_dot_in = bbm::dot(h, in);
65 Value denominator = h_dot_in * bbm::max(
vec::z(in),
vec::z(out) );
68 Value exponent, normalization;
77 normalization = (
sharpness + 1) / Constants::Pi(8);
81 return bbm::select(mask, normalization * bbm::pow(
vec::z(h), exponent ) * F / denominator, 0);
103 mask &= (xi[0] >= 0) && (xi[1] >= 0) && (xi[0] <= 1) && (xi[1] <= 1);
106 if(bbm::none(mask))
return sample;
118 phi =
bbm::select( (xi[0] > 0.25) && (xi[0] < 0.75), phi + Constants::Pi(), phi );
121 csp = bbm::cossin(phi);
126 csp = bbm::cossin(xi[0] * Constants::Pi(2));
127 cosTheta = bbm::pow(xi[1], 1.0 / (
sharpness + 1.0));
130 Value sinTheta = bbm::safe_sqrt(1.0 - cosTheta*cosTheta);
161 if(bbm::none(mask))
return 0;
165 auto h_dot_in = bbm::dot(h, in);
167 Value exponent, normalization;
176 normalization = (
sharpness + 1.0) / Constants::Pi(2);
179 auto pdf = normalization * bbm::pow(
vec::z(h), exponent) / (4.0 * h_dot_in);
201 mask &= (
vec::z(out) > 0);
204 if(bbm::none(mask))
return 0;
All includes and helpers needed for declaring new bsdfmodels.
#define BBM_EXPORT_BSDFMODEL(BsdfModel)
Definition: bbm_fromstring.h:49
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 decltype(auto) u(bbm::vec2d< T > &v)
Definition: vec.h:37
constexpr const vec3d< T > expand(const vec2d< T > &v, V &&a)
Definition: vec.h:55
constexpr decltype(auto) y(bbm::vec3d< T > &v)
Definition: vec.h:23
constexpr decltype(auto) z(bbm::vec3d< T > &v)
Definition: vec.h:26
constexpr decltype(auto) v(bbm::vec2d< T > &v)
Definition: vec.h:40
constexpr decltype(auto) x(bbm::vec3d< T > &v)
Definition: vec.h:20
Definition: aggregatebsdf.h:29
symmetry_v
symmetry variants.
Definition: bsdf_symmetry.h:19
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
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
the Anisotropic Phong BSSF model by Ashikhmin and Shirley. This implements the specular component of ...
Definition: ashikhminshirley.h:35
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: ashikhminshirley.h:51
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: ashikhminshirley.h:95
fresnel_parameter< typename Fresnel::parameter_type > fresnelReflectance
Class Attributes.
Definition: ashikhminshirley.h:213
BBM_DEFAULT_CONSTRUCTOR(ashikhminshirley)
Default constructor.
Definition: ashikhminshirley.h:220
BBM_BSDF_FORWARD
Definition: ashikhminshirley.h:39
specular_sharpness< symmetry_t< Symmetry, Value > > sharpness
Definition: ashikhminshirley.h:214
Spectrum reflectance(const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t=unit_t::Radiance, Mask mask=true) const
Return the (approximate) reflectance of the BSDF.
Definition: ashikhminshirley.h:195
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: ashikhminshirley.h:152
static constexpr string_literal name
Definition: ashikhminshirley.h:38
BBM_ATTRIBUTES(fresnelReflectance, sharpness)
Definition: string_literal.h:16