File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,18 @@ class scene {
24
24
25
25
std::cout << " P3\n " << image_width << ' ' << image_height << " \n 255\n " ;
26
26
27
+ int sqrt_spp = int (sqrt (samples_per_pixel));
27
28
for (int j = image_height-1 ; j >= 0 ; --j) {
28
29
std::clog << " \r Scanlines remaining: " << j << ' ' << std::flush;
29
30
for (int i = 0 ; i < image_width; ++i) {
30
31
color pixel_color (0 ,0 ,0 );
31
- for (int sample = 0 ; sample < samples_per_pixel; ++sample) {
32
- auto u = (i + random_double ()) / (image_width-1 );
33
- auto v = (j + random_double ()) / (image_height-1 );
34
- ray r = cam.get_ray (u, v);
35
- pixel_color += ray_color (r, max_depth);
32
+ for (int s_j = 0 ; s_j < sqrt_spp; ++s_j) {
33
+ for (int s_i = 0 ; s_i < sqrt_spp; ++s_i) {
34
+ auto u = (i + (s_i + random_double ()) / sqrt_spp) / (image_width-1 );
35
+ auto v = (j + (s_j + random_double ()) / sqrt_spp) / (image_height-1 );
36
+ ray r = cam.get_ray (u, v);
37
+ pixel_color += ray_color (r, max_depth);
38
+ }
36
39
}
37
40
write_color (std::cout, pixel_color, samples_per_pixel);
38
41
}
You can’t perform that action at this time.
0 commit comments