1#ifndef _BBM_ASHIKHMIN_SHIRLEY_FULL_H_
2#define _BBM_ASHIKHMIN_SHIRLEY_FULL_H_
31 template<
typename CONF,
32 typename Fresnel = fresnel::schlick<CONF, ior::reflectance<Spectrum_t<CONF>>>,
34 string_literal NAME=
"AshikhminShirleyFull"
35 >
requires concepts::config<CONF> && concepts::fresnel<Fresnel> && concepts::matching_config<CONF, Fresnel>
61 if(bbm::none(mask))
return Spectrum(0);
64 Spectrum spec =
base::eval(in, out, component, unit, mask);
68 if(bbm::none(mask))
return spec;
71 Value scale = bbm::hprod( Scalar(1.0) - bbm::pow(Scalar(1.0) - 0.5*Vec2d(
vec::z(in),
vec::z(out)), 5.0) );
72 Value normalization = 28.0 / (23.0 * Constants::Pi());
100 Value diff_weight = diff_albedo / (diff_albedo + spec_albedo);
101 Value spec_weight = Scalar(1.0) - diff_weight;
104 Value xi0_spec =
bbm::select( spec_weight > Constants::Epsilon(), xi[0] / spec_weight, 0.0);
105 BsdfSample spec_sample =
base::sample(out, Vec2d(xi0_spec, xi[1]), component, unit, mask);
108 Value xi0_diff =
bbm::select(diff_weight > Constants::Epsilon(), (xi[0] - spec_weight) / diff_weight, 0.0);
113 sample.pdf = spec_weight * spec_sample.pdf + diff_weight * diff_sample.pdf;
138 Value diff_weight =
bbm::select( diff_albedo > Constants::Epsilon(), diff_albedo / (diff_albedo + spec_albedo), 0);
139 Value spec_weight = 1.0 - diff_weight;
142 Value spec_pdf =
base::pdf(in, out, component, unit, mask);
146 return (spec_weight*spec_pdf + diff_weight*diff_pdf);
162 mask &= (
vec::z(out) > 0);
165 if(bbm::none(mask))
return 0;
172 if(bbm::none(mask))
return spec;
Implements the specular component from: "An anisotropic phong BRDF model" [Ashikhmin and Shirley 2000...
#define BBM_EXPORT_BSDFMODEL(BsdfModel)
Definition: bbm_fromstring.h:49
bsdfmodel concept
Definition: bsdfmodel.h:33
The classic diffuse Lambertian BSDF model.
#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) z(bbm::vec3d< T > &v)
Definition: vec.h:26
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
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
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
the Anisotropic Phong BSSF model by Ashikhmin and Shirley. This implements the combined diffuse+specu...
Definition: ashikhminshirleyfull.h:37
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: ashikhminshirleyfull.h:89
BBM_BSDF_FORWARD
Definition: ashikhminshirleyfull.h:43
Value pdf(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const
Compute the pdf given an in and out direction.
Definition: ashikhminshirleyfull.h:129
BBM_ATTRIBUTES(diffuseReflectance)
Spectrum eval(const Vec3d &in, const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const
Evaluate the BSDF for a given in and out direction.
Definition: ashikhminshirleyfull.h:55
Spectrum reflectance(const Vec3d &out, BsdfFlag component=bsdf_flag::All, unit_t unit=unit_t::Radiance, Mask mask=true) const
Return the (approximate) reflectance of the BSDF.
Definition: ashikhminshirleyfull.h:159
static constexpr string_literal name
Definition: ashikhminshirleyfull.h:42
BBM_DEFAULT_CONSTRUCTOR(ashikhminshirleyfull)
Default constructor.
Definition: ashikhminshirleyfull.h:190
diffuse_scale< Spectrum > diffuseReflectance
Class Attributes.
Definition: ashikhminshirleyfull.h:184
The classic diffuse Lambertian BSDF model.
Definition: lambertian.h:24
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 diffuse BSDF given a direction and two random variables.
Definition: lambertian.h:76
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: lambertian.h:115
Definition: string_literal.h:16