3 #include "raytracer/histogram.h" 4 #include "raytracer/simulation_parameters.h" 5 #include "raytracer/stochastic/finder.h" 6 #include "raytracer/stochastic/postprocessing.h" 8 #include "core/attenuator/hrtf.h" 9 #include "core/environment.h" 10 #include "core/spatial_division/scene_buffers.h" 15 namespace reflection_processor {
17 template <
typename T,
typename U,
typename Alloc>
18 void energy_histogram_sum(
const T& item,
20 std::vector<U, Alloc>& ret) {
21 ret[time(item) * sample_rate] += volume(item);
24 template <
typename T,
typename U,
typename Alloc,
size_t Az,
size_t El>
25 void energy_histogram_sum(
28 core::vector_look_up_table<std::vector<U, Alloc>, Az, El>& ret) {
29 using table = std::decay_t<decltype(ret)>;
30 ret.at(table::index(item.pointing))[time(item) * sample_rate] +=
35 template <
typename T,
typename Ret>
36 void operator()(
const T& item,
double sample_rate, Ret& ret)
const {
37 energy_histogram_sum(item, sample_rate, ret);
43 template <
typename Histogram>
50 const glm::vec3& source,
51 const glm::vec3& receiver,
54 size_t max_image_source_order,
55 float receiver_radius,
56 float histogram_sample_rate,
63 stochastic::compute_ray_energy(
64 total_rays, source, receiver, receiver_radius))
66 , environment_{environment}
67 , max_image_source_order_{max_image_source_order}
68 , histogram_{histogram_sample_rate} {}
70 template <
typename It>
76 const auto output = finder_.process(b, e, buffers);
78 struct intermediate_impulse final {
79 core::bands_type volume;
84 const auto intermediate = [&] {
85 util::aligned::vector<intermediate_impulse> ret;
86 ret.reserve(output.stochastic.size() + output.specular.size());
88 const auto push_vector = [&](
const auto& vec) {
89 for (
const auto&
impulse : vec) {
90 ret.emplace_back(intermediate_impulse{
92 impulse.distance / environment_.speed_of_sound,
98 push_vector(output.stochastic);
99 if (max_image_source_order_ <= step) {
100 push_vector(output.specular);
106 incremental_histogram(histogram_.histogram,
109 histogram_.sample_rate,
113 Histogram get_results()
const {
return histogram_; }
119 size_t max_image_source_order_;
120 Histogram histogram_;
125 template <
typename Histogram>
129 const glm::vec3& source,
130 const glm::vec3& receiver,
133 size_t max_image_source_order,
134 float receiver_radius,
135 float histogram_sample_rate)
138 , receiver_{receiver}
139 , environment_{environment}
140 , total_rays_{total_rays}
141 , max_image_source_order_{max_image_source_order}
142 , receiver_radius_{receiver_radius}
143 , histogram_sample_rate_{histogram_sample_rate}
144 , histogram_{histogram_sample_rate} {}
147 size_t num_directions)
const {
153 max_image_source_order_,
155 histogram_sample_rate_,
160 sum_histograms(histogram_, processor.get_results());
163 Histogram get_results()
const {
return histogram_; }
171 size_t max_image_source_order_;
172 float receiver_radius_;
173 float histogram_sample_rate_;
175 Histogram histogram_;
183 size_t max_image_source_order,
184 float receiver_radius,
185 float histogram_sample_rate);
189 const glm::vec3& source,
190 const glm::vec3& receiver,
198 size_t max_image_source_order_;
199 float receiver_radius_;
200 float histogram_sample_rate_;
206 size_t max_image_source_order,
207 float receiver_radius,
208 float histogram_sample_rate);
213 const glm::vec3& source,
214 const glm::vec3& receiver,
222 size_t max_image_source_order_;
223 float receiver_radius_;
224 float histogram_sample_rate_;
Definition: stochastic_histogram.h:44
Definition: stochastic_histogram.h:180
Definition: scene_buffers.h:12
Definition: stochastic_histogram.h:203
Definition: stochastic_histogram.h:126
Definition: pressure.h:22
Definition: environment.h:6
Definition: capsule_base.h:9
stochastic_group_processor(const core::compute_context &cc, const glm::vec3 &source, const glm::vec3 &receiver, const core::environment &environment, size_t total_rays, size_t max_image_source_order, float receiver_radius, float histogram_sample_rate, size_t group_items)
Definition: stochastic_histogram.h:49
invariant: device is a valid device for the context
Definition: common.h:13
Definition: conversions.h:26
Definition: stochastic_histogram.h:34
Definition: voxelised_scene_data.h:14