You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two dimensional coordinates (u,v) correspond to the location at which a ray hit the (2D) surface of an object (sphere).
Listing 21 then updates scatter to pass in the rec.u and rec.v values from hit_record rec:
attenuation = albedo->value(rec.u, rec.v, rec.p);
However, Chapter 4 does not explain how coordinates (u,v) are calculated and set in the hit_record, presumably when sphere::hit() is called with an incoming ray.
Skipping ahead to Chapter 6, get_sphere_uv() in Listing 42 seems to solve this problem, which is what I eventually added to my hit() for my updates for Chapter 4 to compile. It produces a plausible result: