Skip to content

Commit 09f034e

Browse files
committed
Rename refactor: nx,ny to image_width,_height
This change also fixes an erroneous inversion in computing the aspect ratio for theRestOfYourLife.
1 parent 08ec4ab commit 09f034e

File tree

6 files changed

+97
-89
lines changed

6 files changed

+97
-89
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@
7070
#include <iostream>
7171

7272
int main() {
73-
int nx = 200;
74-
int ny = 100;
73+
int image_width = 200;
74+
int image_height = 100;
7575

76-
std::cout << "P3\n" << nx << ' ' << ny << "\n255\n";
76+
std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
7777

78-
for (int j = ny-1; j >= 0; --j) {
79-
for (int i = 0; i < nx; ++i) {
80-
auto r = double(i) / nx;
81-
auto g = double(j) / ny;
78+
for (int j = image_height-1; j >= 0; --j) {
79+
for (int i = 0; i < image_width; ++i) {
80+
auto r = double(i) / image_width;
81+
auto g = double(j) / image_height;
8282
auto b = 0.2;
8383
int ir = static_cast<int>(255.999 * r);
8484
int ig = static_cast<int>(255.999 * g);
@@ -165,13 +165,13 @@
165165
instead write to the error output stream (`std::cerr`):
166166

167167
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
168-
for (int j = ny-1; j >= 0; --j) {
168+
for (int j = image_height-1; j >= 0; --j) {
169169
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
170170
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
171171
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
172-
for (int i = 0; i < nx; ++i) {
173-
auto r = double(i) / nx;
174-
auto g = double(j) / ny;
172+
for (int i = 0; i < image_width; ++i) {
173+
auto r = double(i) / image_width;
174+
auto g = double(j) / image_height;
175175
auto b = 0.2;
176176
int ir = static_cast<int>(255.999 * r);
177177
int ig = static_cast<int>(255.999 * g);
@@ -318,16 +318,16 @@
318318
#include <iostream>
319319

320320
int main() {
321-
int nx = 200;
322-
int ny = 100;
321+
int image_width = 200;
322+
int image_height = 100;
323323

324-
std::cout << "P3\n" << nx << ' ' << ny << "\n255\n";
324+
std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
325325

326-
for (int j = ny-1; j >= 0; --j) {
326+
for (int j = image_height-1; j >= 0; --j) {
327327
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
328-
for (int i = 0; i < nx; ++i) {
328+
for (int i = 0; i < image_width; ++i) {
329329
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
330-
vec3 color(double(i)/nx, double(j)/ny, 0.2);
330+
vec3 color(double(i)/image_width, double(j)/image_height, 0.2);
331331
color.write_color(std::cout);
332332
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
333333
}
@@ -419,21 +419,21 @@
419419
}
420420

421421
int main() {
422-
int nx = 200;
423-
int ny = 100;
424-
std::cout << "P3\n" << nx << " " << ny << "\n255\n";
422+
int image_width = 200;
423+
int image_height = 100;
424+
std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
425425
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
426426
vec3 lower_left_corner(-2.0, -1.0, -1.0);
427427
vec3 horizontal(4.0, 0.0, 0.0);
428428
vec3 vertical(0.0, 2.0, 0.0);
429429
vec3 origin(0.0, 0.0, 0.0);
430430
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
431-
for (int j = ny-1; j >= 0; --j) {
431+
for (int j = image_height-1; j >= 0; --j) {
432432
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
433-
for (int i = 0; i < nx; ++i) {
433+
for (int i = 0; i < image_width; ++i) {
434434
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
435-
auto u = double(i) / nx;
436-
auto v = double(j) / ny;
435+
auto u = double(i) / image_width;
436+
auto v = double(j) / image_height;
437437
ray r(origin, lower_left_corner + u*horizontal + v*vertical);
438438
vec3 color = ray_color(r);
439439
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -1078,10 +1078,10 @@
10781078
}
10791079

10801080
int main() {
1081-
int nx = 200;
1082-
int ny = 100;
1081+
int image_width = 200;
1082+
int image_height = 100;
10831083

1084-
std::cout << "P3\n" << nx << ' ' << ny << "\n255\n";
1084+
std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
10851085

10861086
vec3 lower_left_corner(-2.0, -1.0, -1.0);
10871087
vec3 horizontal(4.0, 0.0, 0.0);
@@ -1095,11 +1095,11 @@
10951095
world.add(make_shared<sphere>(vec3(0,-100.5,-1), 100));
10961096
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
10971097

1098-
for (int j = ny-1; j >= 0; --j) {
1098+
for (int j = image_height-1; j >= 0; --j) {
10991099
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
1100-
for (int i = 0; i < nx; ++i) {
1101-
auto u = double(i) / nx;
1102-
auto v = double(j) / ny;
1100+
for (int i = 0; i < image_width; ++i) {
1101+
auto u = double(i) / image_width;
1102+
auto v = double(j) / image_height;
11031103
ray r(origin, lower_left_corner + u*horizontal + v*vertical);
11041104

11051105

@@ -1260,13 +1260,13 @@
12601260

12611261
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
12621262
int main() {
1263-
int nx = 200;
1264-
int ny = 100;
1263+
int image_width = 200;
1264+
int image_height = 100;
12651265
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
12661266
int num_samples = 100;
12671267
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
12681268

1269-
std::cout << "P3\n" << nx << " " << ny << "\n255\n";
1269+
std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
12701270

12711271
hittable_list world;
12721272
world.add(make_shared<sphere>(vec3(0,0,-1), 0.5));
@@ -1275,14 +1275,14 @@
12751275
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
12761276
camera cam;
12771277
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1278-
for (int j = ny-1; j >= 0; --j) {
1278+
for (int j = image_height-1; j >= 0; --j) {
12791279
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
1280-
for (int i = 0; i < nx; ++i) {
1280+
for (int i = 0; i < image_width; ++i) {
12811281
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
12821282
vec3 color(0, 0, 0);
12831283
for (int s = 0; s < num_samples; ++s) {
1284-
auto u = (i + random_double()) / nx;
1285-
auto v = (j + random_double()) / ny;
1284+
auto u = (i + random_double()) / image_width;
1285+
auto v = (j + random_double()) / image_height;
12861286
ray r = cam.get_ray(u, v);
12871287
color += ray_color(r, world);
12881288
}
@@ -1425,21 +1425,21 @@
14251425
}
14261426
...
14271427
int main() {
1428-
int nx = 200;
1429-
int ny = 100;
1428+
int image_width = 200;
1429+
int image_height = 100;
14301430
int num_samples = 100;
14311431
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
14321432
int max_depth = 50;
14331433
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
14341434

14351435
...
1436-
for (int j = ny-1; j >= 0; --j) {
1436+
for (int j = image_height-1; j >= 0; --j) {
14371437
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
1438-
for (int i = 0; i < nx; ++i) {
1438+
for (int i = 0; i < image_width; ++i) {
14391439
vec3 color(0, 0, 0);
14401440
for (int s = 0; s < num_samples; ++s) {
1441-
auto u = (i + random_double()) / nx;
1442-
auto v = (j + random_double()) / ny;
1441+
auto u = (i + random_double()) / image_width;
1442+
auto v = (j + random_double()) / image_height;
14431443
ray r = cam.get_ray(u, v);
14441444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
14451445
color += ray_color(r, world, max_depth);
@@ -1897,11 +1897,11 @@
18971897

18981898
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
18991899
int main() {
1900-
int nx = 200;
1901-
int ny = 100;
1900+
int image_width = 200;
1901+
int image_height = 100;
19021902
int num_samples = 100;
19031903
int max_depth = 50;
1904-
std::cout << "P3\n" << nx << " " << ny << "\n255\n";
1904+
std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
19051905

19061906

19071907
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
@@ -1918,13 +1918,13 @@
19181918
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
19191919

19201920
camera cam;
1921-
for (int j = ny-1; j >= 0; --j) {
1921+
for (int j = image_height-1; j >= 0; --j) {
19221922
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
1923-
for (int i = 0; i < nx; ++i) {
1923+
for (int i = 0; i < image_width; ++i) {
19241924
vec3 color(0, 0, 0);
19251925
for (int s = 0; s < num_samples; ++s) {
1926-
auto u = (i + random_double()) / nx;
1927-
auto v = (j + random_double()) / ny;
1926+
auto u = (i + random_double()) / image_width;
1927+
auto v = (j + random_double()) / image_height;
19281928
ray r = cam.get_ray(u, v);
19291929
color += ray_color(r, world, max_depth);
19301930
}
@@ -2363,7 +2363,7 @@
23632363
</div>
23642364

23652365
<div class='together'>
2366-
When calling it with camera `cam(90, double(nx)/ny)` and these spheres:
2366+
When calling it with camera `cam(90, double(image_width)/image_height)` and these spheres:
23672367

23682368
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
23692369
auto R = cos(pi/4);
@@ -2449,7 +2449,8 @@
24492449
This allows us to change the viewpoint:
24502450

24512451
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2452-
camera cam(vec3(-2,2,1), vec3(0,0,-1), vec3(0,1,0), 90, double(nx)/ny);
2452+
auto aspect_ratio = double(image_width) / image_height;
2453+
camera cam(vec3(-2,2,1), vec3(0,0,-1), vec3(0,1,0), 90, aspect_ratio);
24532454
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24542455
[Listing [scene-free-view]: <kbd>[main.cc]</kbd> Scene with alternate viewpoint]
24552456

@@ -2587,7 +2588,8 @@
25872588
auto dist_to_focus = (lookfrom-lookat).length();
25882589
auto aperture = 2.0;
25892590

2590-
camera cam(lookfrom, lookat, vec3(0,1,0), 20, double(nx)/ny, aperture, dist_to_focus);
2591+
auto aspect_ratio = double(image_width) / image_height;
2592+
camera cam(lookfrom, lookat, vec3(0,1,0), 20, aspect_ratio, aperture, dist_to_focus);
25912593
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25922594
[Listing [scene-camera-dof]: <kbd>[main.cc]</kbd> Scene camera with depth-of-field]
25932595

books/RayTracingTheNextWeek.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@
323323
auto dist_to_focus = 10.0;
324324
auto aperture = 0.0;
325325

326-
camera cam(lookfrom, lookat, vec3(0,1,0), 20, double(nx)/ny, aperture, dist_to_focus, 0.0, 1.0);
326+
auto aspect_ratio = double(image_width) / image_height;
327+
camera cam(lookfrom, lookat, vec3(0,1,0), 20, aspect_ratio, aperture, dist_to_focus, 0.0, 1.0);
327328
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328329
[Listing [scene-spheres-moving-camera]: <kbd>[main.cc]</kbd> Viewing parameters]
329330

@@ -1012,7 +1013,8 @@
10121013
auto dist_to_focus = 10.0;
10131014
auto aperture = 0.0;
10141015

1015-
camera cam(lookfrom, lookat, vec3(0,1,0), 20, double(nx)/ny, aperture, dist_to_focus, 0.0, 1.0);
1016+
auto aspect_ratio = double(image_width) / image_height;
1017+
camera cam(lookfrom, lookat, vec3(0,1,0), 20, aspect_ratio, aperture, dist_to_focus, 0.0, 1.0);
10161018
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10171019
[Listing [scene-two-checker-view]: <kbd>[main.cc]</kbd> Viewing parameters]
10181020

@@ -1165,7 +1167,9 @@
11651167
vec3 lookat(0,0,0);
11661168
auto dist_to_focus = 10.0;
11671169
auto aperture = 0.0;
1168-
camera cam(lookfrom, lookat, vec3(0,1,0), 20, double(nx)/ny, aperture, dist_to_focus, 0.0, 1.0);
1170+
1171+
auto aspect_ratio = double(image_width) / image_height;
1172+
camera cam(lookfrom, lookat, vec3(0,1,0), 20, aspect_ratio, aperture, dist_to_focus, 0.0, 1.0);
11691173
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11701174
[Listing [scene-perlin-view]: <kbd>[main.cc]</kbd> Viewing parameters]
11711175
</div>
@@ -1988,8 +1992,9 @@
19881992
auto aperture = 0.0;
19891993
auto vfov = 40.0;
19901994

1991-
camera cam(lookfrom, lookat, vec3(0,1,0), vfov, double(nx)/ny,
1992-
aperture, dist_to_focus, 0.0, 1.0);
1995+
auto aspect_ratio = double(image_width) / image_height;
1996+
camera cam(
1997+
lookfrom, lookat, vec3(0,1,0), vfov, aspect_ratio, aperture, dist_to_focus, 0.0, 1.0);
19931998
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19941999
[Listing [cornell-box-view]: <kbd>[main.cc]</kbd> Viewing parameters]
19952000
</div>

books/RayTracingTheRestOfYourLife.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,13 +2166,13 @@
21662166
shared_ptr<hittable> light_shape = make_shared<xz_rect>(213, 343, 227, 332, 554, 0);
21672167
shared_ptr<hittable> glass_sphere = make_shared<sphere>(vec3(190, 90, 190), 90, 0);
21682168

2169-
for (int j = ny-1; j >= 0; --j) {
2169+
for (int j = image_height-1; j >= 0; --j) {
21702170
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
2171-
for (int i = 0; i < nx; ++i) {
2171+
for (int i = 0; i < image_width; ++i) {
21722172
vec3 col(0, 0, 0);
21732173
for (int s=0; s < ns; ++s) {
2174-
auto u = (i + random_double()) / nx;
2175-
auto v = (j + random_double()) / ny;
2174+
auto u = (i + random_double()) / image_width;
2175+
auto v = (j + random_double()) / image_height;
21762176
ray r = cam->get_ray(u, v);
21772177
col += ray_color(r, world, glass_sphere, max_depth);
21782178
}

src/InOneWeekend/main.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ hittable_list random_scene() {
8282

8383

8484
int main() {
85-
int nx = 1200;
86-
int ny = 800;
85+
int image_width = 1200;
86+
int image_height = 800;
8787
int num_samples = 10;
8888
int max_depth = 50;
8989

90-
std::cout << "P3\n" << nx << ' ' << ny << "\n255\n";
90+
std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
9191

9292
auto world = random_scene();
9393

@@ -96,15 +96,16 @@ int main() {
9696
auto dist_to_focus = 10.0;
9797
auto aperture = 0.1;
9898

99-
camera cam(lookfrom, lookat, vec3(0,1,0), 20, double(nx)/ny, aperture, dist_to_focus);
99+
auto aspect_ratio = double(image_width) / image_height;
100+
camera cam(lookfrom, lookat, vec3(0,1,0), 20, aspect_ratio, aperture, dist_to_focus);
100101

101-
for (int j = ny-1; j >= 0; --j) {
102+
for (int j = image_height-1; j >= 0; --j) {
102103
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
103-
for (int i = 0; i < nx; ++i) {
104+
for (int i = 0; i < image_width; ++i) {
104105
vec3 color;
105106
for (int s = 0; s < num_samples; ++s) {
106-
auto u = double(i + random_double()) / double(nx);
107-
auto v = double(j + random_double()) / double(ny);
107+
auto u = (i + random_double()) / image_width;
108+
auto v = (j + random_double()) / image_height;
108109
ray r = cam.get_ray(u, v);
109110
color += ray_color(r, world, max_depth);
110111
}

src/TheNextWeek/main.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,12 @@ hittable_list final_scene() {
346346

347347

348348
int main() {
349-
int nx = 600;
350-
int ny = 600;
349+
int image_width = 600;
350+
int image_height = 600;
351351
int num_samples = 100;
352352
int max_depth = 50;
353353

354-
std::cout << "P3\n" << nx << ' ' << ny << "\n255\n";
354+
std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
355355

356356
auto R = cos(pi/4);
357357

@@ -381,16 +381,17 @@ int main() {
381381
auto aperture = 0.0;
382382
auto vfov = 40.0;
383383

384+
auto aspect_ratio = double(image_width) / image_height;
384385
camera cam(
385-
lookfrom, lookat, vec3(0,1,0), vfov, double(nx)/ny, aperture, dist_to_focus, 0.0, 1.0);
386+
lookfrom, lookat, vec3(0,1,0), vfov, aspect_ratio, aperture, dist_to_focus, 0.0, 1.0);
386387

387-
for (int j = ny-1; j >= 0; --j) {
388+
for (int j = image_height-1; j >= 0; --j) {
388389
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
389-
for (int i = 0; i < nx; ++i) {
390+
for (int i = 0; i < image_width; ++i) {
390391
vec3 color;
391392
for (int s = 0; s < num_samples; ++s) {
392-
auto u = (i + random_double()) / nx;
393-
auto v = (j + random_double()) / ny;
393+
auto u = (i + random_double()) / image_width;
394+
auto v = (j + random_double()) / image_height;
394395
ray r = cam.get_ray(u, v);
395396
color += ray_color(r, world, max_depth);
396397
}

0 commit comments

Comments
 (0)