Skip to content

Commit b2206cb

Browse files
authored
Merge pull request #1400 from RayTracing/fix-1309
[Book 3] Fix missing declarations for sqrt_spp and recip_sqrt_spp
2 parents aa99223 + 198935b commit b2206cb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

books/RayTracingTheRestOfYourLife.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,29 @@
332332
}
333333
...
334334
private:
335+
int image_height; // Rendered image height
336+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
337+
int sqrt_spp; // Square root of number of samples per pixel
338+
double recip_sqrt_spp; // 1 / sqrt_spp
339+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
340+
point3 center; // Camera center
335341
...
342+
void initialize() {
343+
...
344+
auto viewport_width = viewport_height * (double(image_width)/image_height);
345+
346+
336347
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
348+
sqrt_spp = int(sqrt(samples_per_pixel));
349+
recip_sqrt_spp = 1.0 / sqrt_spp;
350+
351+
352+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
353+
// Calculate the u,v,w unit basis vectors for the camera coordinate frame.
354+
w = unit_vector(lookfrom - lookat);
355+
...
356+
}
357+
...
337358
ray get_ray(int i, int j, int s_i, int s_j) const {
338359
// Get a randomly-sampled camera ray for the pixel at location i,j, originating from
339360
// the camera defocus disk, and randomly sampled around the pixel location.
@@ -2802,7 +2823,6 @@
28022823

28032824
std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
28042825

2805-
int sqrt_spp = int(sqrt(samples_per_pixel));
28062826
for (int j = 0; j < image_height; j++) {
28072827
std::clog << "\rScanlines remaining: " << (image_height - j) << ' ' << std::flush;
28082828
for (int i = 0; i < image_width; i++) {

0 commit comments

Comments
 (0)