3 #include "raytracer/cl/structs.h" 5 #include "core/conversions.h" 6 #include "core/scene_data.h" 7 #include "core/surfaces.h" 8 #include "core/unit_constructor.h" 10 #include "utilities/aligned/vector.h" 11 #include "utilities/map_to_vector.h" 22 namespace image_source {
25 cl_uint surface_index;
31 template <
typename Channels,
typename It>
32 auto compute_fast_pressure(
const glm::vec3& receiver,
33 const util::aligned::vector<Channels>& impedance,
34 const util::aligned::vector<Channels>& scattering,
36 const glm::vec3& image_source,
39 constexpr
auto channels = ::detail::components_v<Channels>;
41 const auto surface_attenuation = std::accumulate(
44 core::unit_constructor_v<
45 ::detail::cl_vector_constructor_t<float, channels>>,
47 const auto surface_impedance = impedance[j.surface_index];
48 const auto surface_scattering = scattering[j.surface_index];
50 const auto reflectance =
51 core::average_wall_impedance_to_pressure_reflectance(
52 surface_impedance, j.cos_angle);
53 const auto outgoing = core::specular_pressure(
54 i * reflectance, surface_scattering);
56 return outgoing * (flip_phase ? -1 : 1);
61 glm::distance(image_source, receiver)};
68 template <
typename multichannel_type>
71 template <
typename It>
74 const glm::vec3& receiver,
77 , surface_impedances_{util::map_to_vector(
80 [](
const auto& surface) {
82 pressure_reflectance_to_average_wall_impedance(
83 core::absorption_to_pressure_reflectance(
86 , surface_scattering_{util::map_to_vector(
89 [](
const auto& surface) {
return surface.scattering; })}
90 , flip_phase_{flip_phase} {}
92 using return_type = decltype(compute_fast_pressure(
93 std::declval<glm::vec3>(),
94 std::declval<util::aligned::vector<multichannel_type>>(),
95 std::declval<util::aligned::vector<multichannel_type>>(),
97 std::declval<glm::vec3>(),
98 std::declval<const reflection_metadata*>(),
99 std::declval<const reflection_metadata*>()));
101 template <
typename It>
102 return_type operator()(
const glm::vec3& image_source,
105 return compute_fast_pressure(receiver_,
116 util::aligned::vector<multichannel_type> surface_impedances_;
117 util::aligned::vector<multichannel_type> surface_scattering_;
121 template <
typename It>
122 constexpr
auto make_fast_pressure_calculator(It b_surfaces,
124 const glm::vec3& receiver,
126 using multichannel_type =
127 std::decay_t<decltype(std::declval<It>()->absorption)>;
129 std::move(b_surfaces), std::move(e_surfaces), receiver, flip_phase};
Definition: fast_pressure_calculator.h:69
Definition: conversions.h:10
Definition: pressure.h:22
Definition: capsule_base.h:9