mmp / pbrt-v4

Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.
https://pbrt.org
Apache License 2.0
2.8k stars 429 forks source link

fix unreachable branch and unnecessary samples #354

Closed w3ntao closed 1 year ago

w3ntao commented 1 year ago

There are 3 changes, each in 1 commit:

  1. src/pbrt/cpu/integrators.cpp: RayIntegrator::EvaluatePixelSample(): previously when cameraRay not generated, the debug infomation logging macro could never be reached, because it is in a if (cameraRay) block. So I rearrange a bit to have this function return early, after printing out debug information, when no cameraRay generated.

  2. also in src/pbrt/cpu/integrators.cpp, in function RayIntegrator::EvaluatePixelSample() and LightPathIntegrator::EvaluatePixelSample(), there are 2 pieces of identical code (line 230 and line 513):

    Float lu = sampler.Get1D();
    if (Options->disableWavelengthJitter)
        lu = 0.5;

    sampler.Get1D() is invoked even it is not used (when Options->disableWavelengthJitter evaluated to true). So I delete it for such cases:

    Float lu = Options->disableWavelengthJitter ? 0.5 : sampler.Get1D();
  3. Similar to the 2nd change, src/pbrt/samplers.hGetCameraSample(): when GetOptions().disablePixelJitter evaluated to true, 2 2DSample and 1 1DSample are generated. I have them deleted to save several samples for later usage.