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.74k stars 402 forks source link

Uniformgrid/NanoVDB Artifacts #175

Closed shadeops closed 2 years ago

shadeops commented 2 years ago

Summary

Howdy, I'm abusing Mediums again. :grimacing: This time I noticed some artifacts when rendering with gpu/wavefront uniform grids with a directional light. (I see the same artifacts when rendering with a NanoVDB instead of uniformgrid.)

The top medium is a uniform grid, the bottom grid with a homogeneous grid with the same scattering parameters.

CPU

cpu pbrt --outfile cpu.png artifacts.pbrt

GPU

gpu pbrt --outfile gpu.png --gpu artifacts.pbrt

Wavefront

wavefront pbrt --outfile wavefront.png --wavefront artifacts.pbrt

Scene File

Film "rgb"
    "integer yresolution" [ 200 ]
    "integer xresolution" [ 600 ]
    "string filename" [ "pbrt.exr" ]

PixelFilter "gaussian"
    "float yradius" [ 2 ]
    "float xradius" [ 2 ]

Sampler "zsobol"
    "integer pixelsamples" [ 512 ]

Integrator "volpath"
    "integer maxdepth" [ 20 ]

Accelerator "bvh"

Transform [ 1 0 0 0 0 1 0 0 0 0 -1 0 0 0 4 1  ]

Camera "orthographic"
    "float screenwindow" [ -3.5 3.5 -1.1666666 1.1666666 ]

WorldBegin

AttributeBegin
    Transform [ 0 0 1 0 0 1 0 0 -1 0 0 0 -4 0 0 1  ]
    Scale 1 1 -1
    Scale 1 -1 1
    LightSource "distant"
        "float scale" [ 4 ]
AttributeEnd

MakeNamedMaterial "/mat/interface"
    "string type" [ "interface" ]

MakeNamedMedium "/mat/homogeneous"
    "rgb sigma_s" [ 10 1 0.1 ]
    "rgb sigma_a" [ 0 0 0 ]
    "string type" [ "homogeneous" ]

AttributeBegin
    Translate 0 0.6 0

    AttributeBegin
        ConcatTransform [ 3 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 1  ]
        MakeNamedMedium "/obj/uniformgrid_box/RENDER[0]"
            "rgb sigma_s" [ 10 1 0.1 ]
            "rgb sigma_a" [ 0 0 0 ]
            "point3 p1" [ 1 1 1 ]
            "point3 p0" [ -1 -1 -1 ]
            "integer nz" [ 3 ]
            "integer ny" [ 3 ]
            "integer nx" [ 18 ]
            "float density" [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
                              1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
                              1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
                              1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
                              1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
                              1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
                              1 1 1 1 1 1 ]
            "string type" [ "uniformgrid" ]

        Material "interface"
        MediumInterface "/obj/uniformgrid_box/RENDER[0]" ""
        Shape "trianglemesh"
            "integer indices" [ 0 3 1 0 2 3 4 7 5 4 6 7 6 2 7 6 3 2 5 1 4 5 0 1 5 
                                2 0 5 7 2 1 6 4 1 3 6 ]
            "point3 P" [ 1 -1 1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 
                         -1 ]
    AttributeEnd
AttributeEnd

AttributeBegin
    Translate 0 -0.6 0
    NamedMaterial "/mat/interface"
    MediumInterface "/mat/homogeneous" ""
    ConcatTransform [ 3 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 1  ]
    Shape "trianglemesh"
        "integer indices" [ 0 3 1 0 2 3 4 7 5 4 6 7 6 2 7 6 3 2 5 1 4 5 0 1 5 
                            2 0 5 7 2 1 6 4 1 3 6 ]
        "point3 P" [ 1 -1 1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 
                     -1 ]
AttributeEnd
shadeops commented 2 years ago

As a side note, applying a Rotate 0.1 0 1 0 to the uniform grid medium clears most (all?) of the artifacts.

GPU with Rotate 0.1 0 1 0

gpu_rotate

mmp commented 2 years ago

Thanks for reporting this! I've done some rudimentary investigation and will work on this properly tomorrow. The fact that a mini rotate gets rid of those artifacts is especially weird/interesting.

Initial results/notes:

mmp commented 2 years ago

This was a fascinating one to chase down--thanks again for reporting it. After many theories were tested and discarded, it all boiled down to undesired correlation in seeding the RNG used for sampling the medium.