http://sidneys77crlfslcr7zmj3msmxchgnxhrxlp3p3kbaswo7twchjnicid.onion/programming/2022/03/23/raytracing.html
Finally, we’ll normalize the light ray’s direction. // ---✂--- In SampleRay(), replace our current diffuse lighting with the following: // Apply lighting // First we'll get the un-normalized ray from our intersection point to the light source. ray light_ray = ray ( intersection_point , light_point - intersection_point ); // Get the distance to the light (equal to the length of the un-normalized ray). float light_distance = light_ray . direction . length (); // We'll also offset the origin of the light ray...