53 if(bbm::none(mask))
return Spectrum(0);
60 Value exponent = bbm::squared_norm(
vec::xy(H) / r) / bbm::pow(
vec::z(H), 2);
63 result *= bbm::exp(-exponent) / normalizationFactor;
87 mask &= (xi[0] >= 0) && (xi[1] >= 0) && (xi[0] <= 1) && (xi[1] <= 1);
90 if(bbm::none(mask))
return sample;
94 Vec2d csp = bbm::normalize(bbm::cossin(Constants::Pi(2) * xi[0]) * r);
97 Value cosTheta = bbm::rsqrt( 1.0 - (bbm::log(xi[1]) / bbm::squared_norm(csp / r)) );
98 Value sinTheta = bbm::safe_sqrt(1.0 - cosTheta*cosTheta);
129 if(bbm::none(mask))
return 0;
136 Value exponent = bbm::squared_norm(
vec::xy(h) / r) / bbm::pow(
vec::z(h), 2);
137 Value
pdf = bbm::exp(-exponent) / normalizationFactor;
All includes and helpers needed for declaring new bsdfmodels.
#define BBM_EXPORT_BSDFMODEL(BsdfModel)
Definition: bbm_fromstring.h:49
The anisotropic Ward BSDF model.
Definition: ward.h:28
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: ward.h:44
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: ward.h:79
specular_roughness< symmetry_t< Symmetry, Value > > roughness
Definition: ward.h:161
BBM_DEFAULT_CONSTRUCTOR(ward)
Default constructor.
Definition: ward.h:167
BBM_BSDF_FORWARD
Definition: ward.h:32
BBM_ATTRIBUTES(albedo, roughness)
specular_scale< Spectrum > albedo
Definition: ward.h:160
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: ward.h:120
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: ward.h:152
static constexpr string_literal name
Definition: ward.h:31
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
T cosTheta(const vec2d< T > &v)
Definition: spherical.h:109
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) x(bbm::vec3d< T > &v)
Definition: vec.h:20
constexpr const vec2d< T > xy(const vec3d< T > &v)
Definition: vec.h:47
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
Definition: string_literal.h:16