Beispiel #1
0
LightSampler::LightSampler(const Scene& scene)
  : m_total_emissive_area(0.0)
{
    RENDERER_LOG_INFO("collecting light emitters...");

    // Collect all lights and light-emitting triangles.
    collect_lights(scene);
    collect_emitting_triangles(scene);

    // Precompute some values.
    m_light_count = m_lights.size();
    m_rcp_total_emissive_area = 1.0 / m_total_emissive_area;

    // Prepare the CDFs for sampling.
    if (m_emitter_cdf.valid())
        m_emitter_cdf.prepare();
    if (m_emitting_triangle_cdf.valid())
        m_emitting_triangle_cdf.prepare();

    RENDERER_LOG_INFO(
        "found %s %s, %s emitting %s.",
        pretty_int(m_light_count).c_str(),
        plural(m_light_count, "light").c_str(),
        pretty_int(m_emitting_triangles.size()).c_str(),
        plural(m_emitting_triangles.size(), "triangle").c_str());
}
LightSampler::LightSampler(const Scene& scene)
  : m_total_emissive_area(0.0)
{
    RENDERER_LOG_INFO("collecting light emitters...");

    // Collect all lights and light-emitting triangles.
    for (const_each<AssemblyInstanceContainer> i = scene.assembly_instances(); i; ++i)
    {
        const AssemblyInstance& assembly_instance = *i;
        const Assembly& assembly = assembly_instance.get_assembly();

        collect_lights(assembly, assembly_instance);

        if (has_emitting_materials(assembly))
            collect_emitting_triangles(assembly, assembly_instance);
    }

    // Precompute some values.
    m_light_count = m_lights.size();
    m_rcp_total_emissive_area = 1.0 / m_total_emissive_area;

    // Prepare the CDFs for sampling.
    if (m_emitter_cdf.valid())
        m_emitter_cdf.prepare();
    if (m_emitting_triangle_cdf.valid())
        m_emitting_triangle_cdf.prepare();

    RENDERER_LOG_INFO(
        "found %s %s, %s emitting %s.",
        pretty_int(m_light_count).c_str(),
        plural(m_light_count, "light").c_str(),
        pretty_int(m_emitting_triangles.size()).c_str(),
        plural(m_emitting_triangles.size(), "triangle").c_str());
}
Beispiel #3
0
void LightSampler::collect_lights(const Scene& scene)
{
    for (const_each<AssemblyInstanceContainer> i = scene.assembly_instances(); i; ++i)
        collect_lights(*i);
}