-
Notifications
You must be signed in to change notification settings - Fork 958
Closed
Milestone
Description
In section 4.2 of RayTracingInOneWeekend it is stated:
"I will traverse the screen from the lower left hand corner, and use two offset vectors along the screen sides to move the ray endpoint across the screen."
which refers to this piece of code in Listing 9:
for (int j = image_height-1; j >= 0; --j) {
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
for (int i = 0; i < image_width; ++i) {
auto u = double(i) / (image_width-1);
auto v = double(j) / (image_height-1);
ray r(origin, lower_left_corner + u*horizontal + v*vertical - origin);
color pixel_color = ray_color(r);
write_color(std::cout, pixel_color);
}
}
While the offset vectors are relative to the lower_left_corner, it seems to me that the rays actually start in the upper left hand corner and traverse to the lower right. For each j, starting at image_height - 1 and decreasing to 0, we increase i from 0 by image_width times.