pbrt-v3
pbrt-v3 copied to clipboard
problem about bump
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?
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.