mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.87k stars 1.18k forks source link

Path tracer and bdpt give different results for the "Bathroom" scene #229

Closed pgrit closed 4 years ago

pgrit commented 5 years ago

Hi,

The "bathroom" scene from the repository produces different results with bdpt and path (the latter being significantly brighter in the direct illumination). The images below are the results from bdpt (first) and path (second). The difference is particularly visible on the towel in the back and on the basin and glossy surfaces in the front. Both are brighter with the path tracer (2nd image). bdpt pt (There is an inf in the path tracer image, too, btw)

I managed to boil the issue down to the simple example below, with one triangle mesh illuminating another. The problem occurs when combining negative scaling: Scale -1 1 1 with per-vertex normals on the light source: "normal N" [ 1 0 0 1 0 0 1 0 0]. Removing either results in consistent estimates from all sampling techniques. (When removing scale, make sure to flip camera direction)

The following image is a rendering of the scene provided below. Although the light is not "twosided", it is emitting light to the camera and at the same time illuminating the other triangle.

combined

Looking at the full pyramid of sampling techniques shows that the unidir. technique ("hitting the light") is responsible:

t=2, s=0 "directly visible light": the light is visible although it should not be bdpt_d00_s00_t02

t=3, s=0 "hitting light after one bounce": the image is completely black although the light is intersected multiple times. The check whether the light is intersected from the correct side always fails. bdpt_d01_s00_t03

t=2, s=1 "next event": produces the expected image bdpt_d01_s01_t02

t=1, s=2 "light tracer": also produces the expected image bdpt_d01_s02_t01

The individual techniques in the path integrator produce the same results (i.e., the problem is independent of the integrator).

Lines 53-61 in triangle.cpp suggest that the example (and the "bathroom" scene) should render correctly: The comments state that scaling should not be an issue for triangular lights. Also, for a scaling term of Scale -1 1 1 the HasScale() function returns false.

LookAt 0 0 0   -1 0 0   0 1 0

Camera "perspective" "float fov" 45
Sampler "random" "integer pixelsamples" 1
Integrator "bdpt" "integer maxdepth" 1 "bool visualizestrategies" "true"

WorldBegin

Scale -1 1 1

AttributeBegin
    AreaLightSource "diffuse" "blackbody L" [6500 100]
    Shape "trianglemesh"
        "integer indices" [0 1 2]
        "point P" [ 5 -1 -1   5 1 -1   5 1 1]
        "normal N" [ 1 0 0   1 0 0   1 0 0]
AttributeEnd

AttributeBegin
    Material "matte"
    Shape "trianglemesh"
        "integer indices" [0 1 2]
        "point P" [ 15 -10 -10   15 10 -10   15 0 10 ]
AttributeEnd

WorldEnd
mmp commented 5 years ago

Thank you very much for chasing this down so far and sending along a short test case!

Work is currently fairly busy for me, so it may be a few more days before I can properly look into this and get a fix checked in.

Thanks!!

XBOOS commented 5 years ago

@pgrit Hi, I wonder whether you have encountered "segmentation fault" when rendering the "bathroom" scene. Actually, I tried a few scenes and all of them crashed after parsing scenes and just before doing the rendering. Only the example scene "killeroo-simple.pbrt" succeeded. Any advice would be appreciated. Thank you~

mmp commented 5 years ago

@XBOOS please file a separate bug if you're seeing crashes from pbrt. Please include detailed information about your system/OS, how you build pbrt, and the program's output before it crashes. It's most likely that it's a problem with your build of it, given that no one else has reported this and a fair number of people use it.

moranzcw commented 5 years ago

@XBOOS Maybe you lost some files in your scenes, every scene should include a "geometry" folder, Just check it out.

TzuChieh commented 5 years ago

Maybe this is somewhat related to #179 In both cases BDPT produces darker image.

mmp commented 4 years ago

This took some time to chase down once I finally found time to dig in. Many many thanks for providing that simple repro case and my apologies for not fixing this sooner.