void render(pbrt::Scene const& scene)
{
auto const light_distribution = pbrt::ComputeLightPowerDistribution(scene);
std::unordered_map<pbrt::Light const*, std::size_t> light_to_index;
for (std::size_t i = 0; i < scene.lights.size(); ++i)
light_to_index[scene.lights[i].get()] = i;
std::vector<vertex> z(m_t),
y(m_s);
std::size_t const a = m_camera->film->GetSampleBounds().pMax.y,
b = m_camera->film->GetSampleBounds().pMax.x;
std::vector<pbrt::Spectrum> image(a * b);
std::vector<std::size_t> n(a * b);
pbrt::MemoryArena arena;
for (std::size_t i = 0; i < m_n; ++i)
{
pbrt::Point2f raster_point;
auto const contribution = sample_path(scene, *m_camera, *light_distribution, light_to_index,
arena, m_k, m_s, *m_sampler, raster_point, z.data(), y.data());
arena.Reset();
std::size_t const index = static_cast<std::size_t>(raster_point.y) * b + static_cast<std::size_t>(raster_point.x);
image[index] += contribution.value_or(0);
++n[index];
}
for (std::size_t i = 0; i < n.size(); ++i)
{
if (n[i] > 0)
image[i] = image[i] / (n[i] /** a * b*/);
}
m_camera->film->SetImage(image.data());
m_camera->film->WriteImage();
}
void render(pbrt::Scene const& scene)
{
auto const light_distribution = pbrt::ComputeLightPowerDistribution(scene);
std::unordered_map<pbrt::Light const*, std::size_t> light_to_index;
for (std::size_t i = 0; i < scene.lights.size(); ++i)
light_to_index[scene.lights[i].get()] = i;
std::vector<vertex> z(m_t),
y(m_s);
std::size_t const a = m_camera->film->GetSampleBounds().pMax.y,
b = m_camera->film->GetSampleBounds().pMax.x;
std::vector<pbrt::Spectrum> image(a * b);
std::vector<std::size_t> n(a * b);
pbrt::MemoryArena arena;
for (std::size_t i = 0; i < m_n; ++i)
{
pbrt::Point2f raster_point;
auto const contribution = sample_path(scene, *m_camera, *light_distribution, light_to_index,
arena, m_k, m_s, *m_sampler, raster_point, z.data(), y.data());
arena.Reset();
std::size_t const index = static_cast<std::size_t>(raster_point.y) * b + static_cast<std::size_t>(raster_point.x);
image[index] += contribution.value_or(0);
++n[index];
}
for (std::size_t i = 0; i < n.size(); ++i)
{
if (n[i] > 0)
image[i] = image[i] / (n[i] /** a * b*/);
}
m_camera->film->SetImage(image.data());
m_camera->film->WriteImage();
}