void SphericalMapping2D::sphere(const Point &p, float *s, float *t) const { Vector vec = Normalize(WorldToTexture(p) - Point(0,0,0)); float theta = SphericalTheta(vec); float phi = SphericalPhi(vec); *s = theta * INV_PI; *t = phi * INV_TWOPI; }
void CylindricalMapping2D::cylinder(const Point &p, float *s, float *t) const { Vector vec = Normalize(WorldToTexture(p) - Point(0,0,0)); *s = (M_PI + atan2f(vec.y, vec.x)) / (2.f * M_PI); *t = vec.z; }
Point IdentityMapping3D::Map(const DifferentialGeometry &dg, Vector *dpdx, Vector *dpdy) const { *dpdx = WorldToTexture(dg.dpdx); *dpdy = WorldToTexture(dg.dpdy); return WorldToTexture(dg.p); }
Point3f IdentityMapping3D::Map(const SurfaceInteraction &isect, Vector3f *dpdx, Vector3f *dpdy) const { *dpdx = WorldToTexture(isect.dpdx); *dpdy = WorldToTexture(isect.dpdy); return WorldToTexture(isect.p); }
Point2f SphericalMapping2D::sphere(const Point3f &p) const { Vector3f vec = Normalize(WorldToTexture(p) - Point3f(0, 0, 0)); Float theta = SphericalTheta(vec), phi = SphericalPhi(vec); return Point2f(theta * InvPi, phi * Inv2Pi); }