|
332 | 332 | }
|
333 | 333 | ...
|
334 | 334 | 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 |
335 | 341 | ...
|
| 342 | + void initialize() { |
| 343 | + ... |
| 344 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
| 345 | + |
| 346 | + |
336 | 347 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 | + ... |
337 | 358 | ray get_ray(int i, int j, int s_i, int s_j) const {
|
338 | 359 | // Get a randomly-sampled camera ray for the pixel at location i,j, originating from
|
339 | 360 | // the camera defocus disk, and randomly sampled around the pixel location.
|
|
2802 | 2823 |
|
2803 | 2824 | std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
|
2804 | 2825 |
|
2805 |
| - int sqrt_spp = int(sqrt(samples_per_pixel)); |
2806 | 2826 | for (int j = 0; j < image_height; j++) {
|
2807 | 2827 | std::clog << "\rScanlines remaining: " << (image_height - j) << ' ' << std::flush;
|
2808 | 2828 | for (int i = 0; i < image_width; i++) {
|
|
0 commit comments