Random unit vector optimization #941
-
In section 8.5 of Ray Tracking in One Weekend, to achieve "True Lambertian Reflection" the function I have run the code myself and the results look incredibly similar but not identical (from my understanding the images will never be identical; even with subsequent runs). If my intuition about the two algorithms leading to accurate images, could anyone explain where I've gone wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you use the On normalization, these points are "squished" (projected) to the point on the surface of the embedded sphere. As a result, you get an uneven distribution of points on the surface of this sphere. In contrast, the rejection method presented in the book ensures that only points within the sphere are accepted, and such points have no bias toward any particular region of the sphere. |
Beta Was this translation helpful? Give feedback.
If you use the
vec3::random(double,double)
function, you're essentially generating random points in the cube with vertices at (-1,-1,-1) and (+1,+1,+1). However, the diameter from the center of one side to the opposite side is smaller than the diameter from one corner to the opposite corner. In fact, it's ≅ 1.7 times (√3) longer, so more points are generated along this diameter than along the center-to-center diameter.On normalization, these points are "squished" (projected) to the point on the surface of the embedded sphere. As a result, you get an uneven distribution of points on the surface of this sphere.
In contrast, the rejection method presented in the book ensures that only point…