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.89k stars 454 forks source link

Fixing Time Sampling/Motion Blur for SPPM #441

Closed paulgrassler closed 3 weeks ago

paulgrassler commented 2 months ago

Small changes allow SPPM to converge to the correct image for animated scenes. Before. Rays and photons were individually sampling a separate timestamp leading to many inconsistencies, see #440. This approach can not work without significant changes (e.g. implementing a time kernel). Using a single timestamp per iteration and using it for all rays and photons of that iteration instead provides a straightforward solution to this problem with minimal additions. Because of the numerous iterations/samples of SPPM, it reliably converges to the correct result without any sampling artifacts. I am fairly certain that this is also how they did it in the original paper.

Image with Path Tracer Integrator:

cornell-box_path_gt

Image with existing SPPM implementation (RMSE: 0.001364; PSNR: 57.31529; SSIM: 0.99679):

cornell-box-sppm

Image with fixed SPPM implementation (RMSE: 0.00074; PSNR: 62.55448; SSIM: 0.99938):

cornell-box_sppm_fix

For reference: I found this issue while working on a seminar paper about Photon Mapping at the Institute of Computer Graphics and Knowledge Visualisation, Graz University of Technology.

My contact information:

My supervisor:

Scene used in the example images:

#Integrator "path"
Integrator "sppm"
    "float radius" [ 0.005 ]
Transform [ 1 -0 -0 -0 -0 1 -0 -0 -0 -0 -1 -0 -0 -1 6.8 1  ]
Sampler "paddedsobol"
    "integer pixelsamples" [ 2048 ]
Film "rgb"
    "string filename" [ "cornell-box.png" ]
    "integer yresolution" [ 1024 ]
    "integer xresolution" [ 1024 ]
Camera "perspective"
    "float fov" [ 19.5 ]
TransformTimes 0 1

WorldBegin

MakeNamedMaterial "LeftWall"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0.75 0.25 0.25 ]
MakeNamedMaterial "RightWall"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0.25 0.25 0.75 ]
MakeNamedMaterial "Floor"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0.725 0.71 0.68 ]
MakeNamedMaterial "Ceiling"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0.725 0.71 0.68 ]
MakeNamedMaterial "BackWall"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0.725 0.71 0.68 ]
MakeNamedMaterial "ShortBox"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0.25 0.75 0.25 ]
MakeNamedMaterial "TallBox"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0.25 0.75 0.25 ]
MakeNamedMaterial "Light"
    "string type" [ "diffuse" ]
    "rgb reflectance" [ 0 0 0 ]
NamedMaterial "Floor"
Shape "trianglemesh"
    "point2 uv" [ 0 0 1 0 1 1 0 1 
        ]
    "normal N" [ 4.37114e-8 1 1.91069e-15 4.37114e-8 1 1.91069e-15 4.37114e-8 1 1.91069e-15 
                 4.37114e-8 1 1.91069e-15 ]
    "point3 P" [ -1 1.74846e-7 -1 -1 1.74846e-7 1 1 -1.74846e-7 1 1 -1.74846e-7 -1 ]
    "integer indices" [ 0 1 2 0 2 3 ]
NamedMaterial "Ceiling"
Shape "trianglemesh"
    "point2 uv" [ 0 0 1 0 1 1 0 1 
        ]
    "normal N" [ -8.74228e-8 -1 -4.37114e-8 -8.74228e-8 -1 -4.37114e-8 -8.74228e-8 
                 -1 -4.37114e-8 -8.74228e-8 -1 -4.37114e-8 ]
    "point3 P" [ 1 2 1 -1 2 1 -1 2 -1 1 2 -1 ]
    "integer indices" [ 0 1 2 0 2 3 ]
NamedMaterial "BackWall"
Shape "trianglemesh"
    "point2 uv" [ 0 0 1 0 1 1 0 1 
        ]
    "normal N" [ 8.74228e-8 -4.37114e-8 -1 8.74228e-8 -4.37114e-8 -1 8.74228e-8 -4.37114e-8 
                 -1 8.74228e-8 -4.37114e-8 -1 ]
    "point3 P" [ -1 0 -1 -1 2 -1 1 2 -1 1 0 -1 ]
    "integer indices" [ 0 1 2 0 2 3 ]
NamedMaterial "RightWall"
Shape "trianglemesh"
    "point2 uv" [ 0 0 1 0 1 1 0 1 
        ]
    "normal N" [ 1 -4.37114e-8 1.31134e-7 1 -4.37114e-8 1.31134e-7 1 -4.37114e-8 
                 1.31134e-7 1 -4.37114e-8 1.31134e-7 ]
    "point3 P" [ 1 0 -1 1 2 -1 1 2 1 1 0 1 ]
    "integer indices" [ 0 1 2 0 2 3 ]
NamedMaterial "LeftWall"

AttributeBegin
    Translate 0 1.9 0
    AreaLightSource "diffuse" "rgb L" [ 40 40 40 ] 
    NamedMaterial "Light" 
    Shape "sphere" "float radius" [ 0.1 ] 
AttributeEnd
Shape "trianglemesh"
    "point2 uv" [ 0 0 1 0 1 1 0 1 
        ]
    "normal N" [ -1 -4.37114e-8 -4.37114e-8 -1 -4.37114e-8 -4.37114e-8 -1 -4.37114e-8 
                 -4.37114e-8 -1 -4.37114e-8 -4.37114e-8 ]
    "point3 P" [ -1 0 1 -1 2 1 -1 2 -1 -1 0 -1 ]
    "integer indices" [ 0 1 2 0 2 3 ]

AttributeBegin
    NamedMaterial "ShortBox"
    Translate 0 0.2 0
    ActiveTransform EndTime
    Translate 0 0.2 0
    Shape "sphere"
        "float radius" [ 0.2 ]
AttributeEnd
paulgrassler commented 3 weeks ago

It should be fixed now!

mmp commented 3 weeks ago

Looks great-thank you!