1#ifndef _BBM_MERL_LINEARIZER_H_
2#define _BBM_MERL_LINEARIZER_H_
21 template<
typename CONF>
requires concepts::config<CONF>
50 Vec3dPair
operator()(
const Size_t& idx, Mask mask=
true)
const
52 Vec3dPair result = {0,0};
55 mask &= (idx <
size());
56 if(bbm::none(mask))
return result;
59 vec2d<Size_t> idxH(0);
60 vec2d<Size_t> idxD(0);
61 Size_t temp_idx = idx;
72 Vec2d half_sph = bbm::pow(bbm::cast<Vec2d>(idxH) /
_samplesH, 2.0) * (0.5 * Constants::Sphere());
73 Vec2d diff_sph = (bbm::cast<Vec2d>(idxD) /
_samplesD) * (0.5 * Constants::Sphere());
94 Size_t
operator()(
const Vec3d& in,
const Vec3d& out, Mask mask=
true)
const
100 if(bbm::none(mask))
return size();
114 auto idxD = bbm::floor((
difference/Constants::Sphere(0.5) + Constants::Epsilon()) *
_samplesD);
115 auto idxH = bbm::floor(bbm::safe_sqrt(
halfway/Constants::Sphere(0.5) + Constants::Epsilon()) *
_samplesH);
118 idxD = bbm::clamp(idxD, 0,
_samplesD - 1);
119 idxH = bbm::clamp(idxH, 0,
_samplesH - 1);
All BBM methods are defined to operate on a variety of value types and spectrum types....
inout_linearizer concept
Definition: inout_linearizer.h:28
inout_linearizer contract
Macros for checking if a class meets a concept.
#define BBM_CHECK_CONCEPT(CONCEPTNAME, CLASSNAME,...)
Check a class for a concept with bbm::concepts::archetypes in the namespace.
Definition: macro.h:35
T & phi(vec2d< T > &v)
Definition: spherical.h:39
vec2d< T > convert(const vec3d< T > &v)
Definition: spherical.h:53
T & theta(vec2d< T > &v)
Definition: spherical.h:23
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
vec3d< T > difference(const vec3d< T > &a, const vec3d< T > &b)
Difference vector.
Definition: vec_transform.h:106
std::pair< vec3d< T >, vec3d< T > > convertFromHalfwayDifference(const vec3d< T > &half, const vec3d< T > &diff)
Convert from Halfway-Difference to Canonical parameterization.
Definition: vec_transform.h:118
std::pair< vec3d< T >, vec3d< T > > convertToHalfwayDifference(const vec3d< T > &a, const vec3d< T > &b)
Convert fro Canonical to the Halfway-Difference parameterization.
Definition: vec_transform.h:91
Definition: merl_linearizer.h:23
Size_t size(void) const
Size of the linearized 'array' of direction pairs.
Definition: merl_linearizer.h:34
Size_t operator()(const Vec3d &in, const Vec3d &out, Mask mask=true) const
Map a coordinate to an linear index.
Definition: merl_linearizer.h:94
vec2d< Size_t > _samplesH
Definition: merl_linearizer.h:129
merl_linearizer(const vec2d< Size_t > &h=vec2d< Size_t >(1, 90), const vec2d< Size_t > &d=vec2d< Size_t >(180, 90))
Constructor.
Definition: merl_linearizer.h:29
Vec3dPair operator()(const Size_t &idx, Mask mask=true) const
The in-out coordinate of the idx-th sample.
Definition: merl_linearizer.h:50
vec2d< Size_t > _samplesD
Definition: merl_linearizer.h:130
Structure to hold a pair of directions.