pbrt-v3 icon indicating copy to clipboard operation
pbrt-v3 copied to clipboard

problem about bump

Open shihaoL opened this issue 5 years ago • 1 comments

According to the formula, dpdu is not a normalized vector, but si->shading.dpdu is normalized.

// Compute bump-mapped differential geometry
    Vector3f dpdu = si->shading.dpdu +
                    (uDisplace - displace) / du * Vector3f(si->shading.n) +
                    displace * Vector3f(si->shading.dndu);


    Vector3f dpdv = si->shading.dpdv +
                    (vDisplace - displace) / dv * Vector3f(si->shading.n) +
                    displace * Vector3f(si->shading.dndv);

This is a part of code in "Triangle::Intersect", ts and ss are normalized, the values are assigned to shading.dpdu and shading.dpdv.

        Vector3f ts = Cross(ss, ns);
        if (ts.LengthSquared() > 0.f) {
            ts = Normalize(ts);
            ss = Cross(ts, ns);
        } else
            CoordinateSystem((Vector3f)ns, &ss, &ts);
        isect->SetShadingGeometry(ss, ts, dndu, dndv, true);

Is the code wrong?

shihaoL avatar Dec 01 '19 08:12 shihaoL

The code is indeed wrong. :-(. I'm going to defer fixing this until pbrt-v4, however, since doing so can cause rendered images to change significantly.

mmp avatar Jun 26 '20 17:06 mmp