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

Microfacet BxDF with small roughness does not match specular BxDF #214

Closed alekseyvo closed 4 years ago

alekseyvo commented 5 years ago

Hi,

I expect the glass material with very small roughness to almost exactly match the glass material with zero roughness (while the first one uses microfacet BSDFs and the second one uses specular BSDFs). However, the difference is quite visible.

In this example scene left sphere has roughness 0.0 and right sphere has roughness 0.000001. Note the left sphere has clearly visible highlight on top while the right one misses this highlight.

scene1_glass

Integrator "path" "integer maxdepth" [ 65 ] 
LookAt 0 4 -10  0 0 0  0 1 0
Sampler "stratified" "integer xsamples" [ 100 ] "integer ysamples" [ 100 ] "bool jitter" [ "true" ]
Film "image" "integer xresolution" [ 640 ] "integer yresolution" [ 360 ] "string filename" [ "scene1.png" ] 
Camera "perspective" "float fov" [ 45 ] 
WorldBegin
    AttributeBegin
        AreaLightSource "diffuse" "rgb L" [ 4.0 4.0 4.0 ] 
        Material "matte" "rgb Kd" [ 0 0 0 ]
        Shape "trianglemesh" "integer indices" [ 0 1 2 0 2 3 ] "point P" [ -4 8 -4   4 8 -4   4 8 4    -4 8 4 ]
    AttributeEnd

    AttributeBegin
        Translate 3 1 0
        Material "glass" "rgb Kr" [ 1.0 1.0 1.0 ] "rgb Kt" [ 1.0 1.0 1.0 ] "float eta" [1.5] "float uroughness" [0.000001] "float vroughness" [0.000001] "bool remaproughness" [ "false" ]
        Shape "sphere" "float radius" [2.0]
    AttributeEnd

    AttributeBegin
        Translate -3 1 0
        Material "glass" "rgb Kr" [ 1.0 1.0 1.0 ] "rgb Kt" [ 1.0 1.0 1.0 ] "float eta" [1.5] "float uroughness" [0.0] "float vroughness" [0.0] "bool remaproughness" [ "false" ]
        Shape "sphere" "float radius" [2.0]
    AttributeEnd

    AttributeBegin
        Texture "checks" "spectrum" "checkerboard" "float uscale" [100] "float vscale" [100] "rgb tex1" [1 1 1] "rgb tex2" [0.98 0.98 0.98]
        Material "matte" "texture Kd" "checks"
        Shape "trianglemesh"  "integer indices" [0 1 2 0 3 2 ] "point P" [50 -1 -50    -50 -1 -50    -50 -1 50    50 -1 50 ]
    AttributeEnd
WorldEnd
TzuChieh commented 5 years ago

IIRC, pbrt uses a function to re-map user specified roughness values. The roughness value used for BSDF evaluation will not match the one you specified. I'm not sure, however, that it can cause such a big difference in rendered images.

mmp commented 4 years ago

The issue seems to be that total internal reflection isn't handled properly (cf. #254). Fix forthcoming.

mmp commented 4 years ago

Fixed now. This scene is a good test case--I've added it to my little pbrt test suite.