Spectrum G(const Scene &scene, Sampler &sampler, const Vertex &v0, const Vertex &v1) { Vector3f d = v0.p() - v1.p(); Float g = 1 / d.LengthSquared(); d *= std::sqrt(g); if (v0.IsOnSurface()) g *= AbsDot(v0.ns(), d); if (v1.IsOnSurface()) g *= AbsDot(v1.ns(), d); VisibilityTester vis(v0.GetInteraction(), v1.GetInteraction()); return g * vis.Tr(scene, sampler); }
Spectrum GeometryTerm(const Scene &scene, Sampler &sampler, const Vertex &v0, const Vertex &v1) { Vector3f d = v0.GetPosition() - v1.GetPosition(); Float G = 1.f / d.LengthSquared(); d *= std::sqrt(G); if (v0.IsOnSurface()) G *= Dot(v0.GetShadingNormal(), d); if (v1.IsOnSurface()) G *= Dot(v1.GetShadingNormal(), d); VisibilityTester vis(v0.GetInteraction(), v1.GetInteraction()); return std::abs(G) * vis.T(scene, sampler); }
Float ConvertDensity(const Vertex &cur, Float pdf, const Vertex &next) { // Return solid angle density if _next_ is an infinite area light if (next.IsInfiniteLight()) return pdf; Vector3f d = next.GetPosition() - cur.GetPosition(); Float invL2 = 1.f / d.LengthSquared(); if (next.IsOnSurface()) pdf *= AbsDot(next.GetGeoNormal(), d * std::sqrt(invL2)); return pdf * invL2; }