mitsuba-renderer / mitsuba

Mitsuba renderer main repository
GNU General Public License v3.0
1.05k stars 321 forks source link

Silhouette edge issues on triangle meshes with per-vertex normals #77

Open andrewvarga opened 6 years ago

andrewvarga commented 6 years ago

I'm moving this issue over from here since I have the very same problem: https://www.mitsuba-renderer.org/tracker/issues/277

The interpolated normals are causing some unexpected visual artifacts at steep viewing angles.

I believe this is described in the documentation at the "strictNormals" parameter.

I tried to apply the fix suggested by @wjakob in the original issue in diffuse.cpp so that this function:

 Spectrum eval(const BSDFSamplingRecord &bRec, EMeasure measure) const {
        if (!(bRec.typeMask & EDiffuseReflection) || measure != ESolidAngle
            || Frame::cosTheta(bRec.wi) <= 0
            || Frame::cosTheta(bRec.wo) <= 0)
            return Spectrum(0.0f);

        return m_reflectance->eval(bRec.its)
            * (INV_PI * Frame::cosTheta(bRec.wo));
    }

becomes this:

 Spectrum eval(const BSDFSamplingRecord &bRec, EMeasure measure) const {
        if (!(bRec.typeMask & EDiffuseReflection) || measure != ESolidAngle)
            return Spectrum(0.0f);

        return m_reflectance->eval(bRec.its)
            * (INV_PI * std::abs(Frame::cosTheta(bRec.wo)));
    }

which kind of has an inverse effect: the black silhouettes are removed but in their places (and in other, previously correct some bright highlights appear, that seem to be wrong also.

I can upload a sample scene where this problem can be seen easily.

andrewvarga commented 6 years ago

Here's a sample scene attached (just open with the GUI and press render): render_jjl1j5k5.zip

And the screenshot with the problem: screen shot 2018-07-09 at 18 14 32

And finally, a comparison for the original issue, vs the "fix" which introduces the bright highlights (here the chair material is changed to yellow but that's irrelevant): screen shot 2018-07-09 at 15 34 12

I wonder if I made an obvious mistke in the "fix" and if there's a proper way to eliminate the black silhouettes?