hologram hologram_reconstructor::reconstruct(const hologram& h, const window& hw, vec3 light_direction, float_t light_distance) {
    hologram image(width, height);
    boost::timer timer;
    vec3 direction = normalize(output_window.direction());
    std::complex<float_t> ilambda(0, wavelength);
#pragma omp parallel for schedule(dynamic, 1)
    for (std::size_t y = 0; y < height; ++y) {
        for (std::size_t x = 0; x < width; ++x) {
            vec3 op = output_window.unproj(vec2(float_t(x) / h.width(), float_t(y) / h.height()));
            std::complex<float_t> wave(0);
            for (std::size_t hy = 0; hy < h.height(); ++hy) {
                for (std::size_t hx = 0; hx < h.width(); ++hx) {
                    vec3 hp = hw.unproj(vec2(float_t(hx) / width, float_t(hy) / height));
                    //float_t hp_to_light = dot(hp, light_direction) + light_distance;
                    vec3 op_to_hp = hp - op;
                    float_t op_to_hp_len2 = cml::length_squared(op_to_hp);
                    float_t op_to_hp_len = std::sqrt(op_to_hp_len2);
                    wave += std::polar(h(hx, hy) / op_to_hp_len2, wavenumber * op_to_hp_len) / ilambda * dot(direction, op_to_hp);
                }
            }
            image(x, y) = std::abs(wave);
        }
        std::clog << (y + 1) << "/" << height << " " << int(timer.elapsed() / (y + 1) * (height - y - 1)) << " s left" << std::endl;
    }
    return image;
}