mmp / pbrt-v2

Source code for the version of pbrt described in the second edition of "Physically Based Rendering"
http://pbrt.org
990 stars 343 forks source link

Ambient occlusion in scenes with light sources #54

Closed matt77hias closed 6 years ago

matt77hias commented 8 years ago

Using an AmbientOcclusionIntegrator (or another SurfaceIntegrator which Li method does not return physical radiance values) in open scenes with light sources results in some dual behavior:

Spectrum SamplerRenderer::Li(...) const {
    ...
    if (scene->Intersect(ray, isect))
        Li = surfaceIntegrator->Li(...);       // Could be any spectrum
    else {
        // Handle ray that doesn't intersect any geometry
        for (uint32_t i = 0; i < scene->lights.size(); ++i)
            Li += scene->lights[i]->Le(ray); // Always physical radiance spectrum
    }
    ...
}

This dual behavior is illustrated in the image below: am_bunny1-1_grid_test_s4

The easiest way to fix this is to let the user take care of it by not adding light sources in the .pbrt file. Or refactor the else part to a new abstract method in the SurfaceIntegrator hierarchy.

mmp commented 6 years ago

pbrt-v3 doesn't have this bug; marking will not fix for v2