@@ -151,12 +151,27 @@ scene many_spheres()
151151{
152152 scene s;
153153
154- s.add (make_shared<sphere>(point3 (0 , -500 .5 , -1 ), 500 ));
154+ s.add (make_shared<sphere>(point3 (0 , -1000 .5 , -1 ), 1000 ));
155155 s.add (make_shared<sphere>(point3 (0 , 0 , 0 ), .5 ));
156- s.add (make_shared<sphere>(point3 (-1 , 1 , -1 ), .8 ));
157156
158- for (int i = 0 ; i < 10 ; i++)
159- s.add (make_shared<sphere>(point3 (RndGen::random_double (-4 , 4 ), 0 , RndGen::random_double (0 , -4 )), .3 ));
157+ auto leftSphere = make_shared<sphere>(point3 (-1 , 1 , -1 ), .8 );
158+ leftSphere.get ()->isMirror = true ;
159+ s.add (leftSphere);
160+
161+ for (int i = 0 ; i < 180 ; i++){
162+ auto obj = make_shared<sphere>(
163+ point3 (
164+ RndGen::random_normal (-2 , 2 ),
165+ RndGen::random_normal (-0.5 , 0.4 ),
166+ RndGen::random_normal (-0.5 , -4 )),
167+ .1 + RndGen::random_double (0 , 0.2 ));
168+
169+ if (RndGen::random_double () < 0.3 ){
170+ obj.get ()-> isMirror = true ;
171+ }
172+
173+ s.add (obj);
174+ }
160175
161176 return s;
162177}
@@ -165,7 +180,7 @@ scene single_cube()
165180{
166181 scene s;
167182
168- s.add (make_shared<sphere>(point3 (0 , -500 .5 , -1 ), 500 ));
183+ s.add (make_shared<sphere>(point3 (0 , -1000 .5 , -1 ), 1000 ));
169184 s.add (make_shared<sphere>(point3 (-1 , 1 , -1 ), .5 ));
170185 auto rotatedCube = make_shared<cube>(point3 (0 , 0 , -1 ), 1 , vec3 (0 , 45 , 0 ));
171186 s.add (rotatedCube);
@@ -174,37 +189,28 @@ scene single_cube()
174189
175190int main ()
176191{
177- vec3 v1 (0.2 , 0.2 , 0.2 );
178- cout << v1 << " : " << v1.length_squared () <<endl;
179- auto l = v1.length_squared ();
180-
181- // normalizing the vector
182- v1 = unit_vector (v1);
192+ const int samples_per_pixel = 64 ;
183193
184- cout << v1 / sqrt (l) << " : " << v1. length_squared () <<endl ;
194+ Camera c ( vec3 ( 0 , 0 , 0 ), 1080 , channels, samples_per_pixel) ;
185195
186- const int samples_per_pixel = 32 ;
187- Camera c (vec3 (0 , 0 , 0 ), 720 , channels, samples_per_pixel);
188196 image_width = c.image_width ;
189197 image_height = c.image_height ;
190198
191199 vector<unsigned char > image (c.image_width * c.image_height * channels);
192200
193- // scene.add(make_shared<sphere>(point3(0, 0, -1), .5));
194-
195- std::cout << " 🖼️ resolution: " << c.image_width << " x " << c.image_height << " pixels" << std::endl;
201+ std::cout << " Rendering at resolution: " << c.image_width << " x " << c.image_height << " pixels" << std::endl;
196202
197203 // Create a new scene for this frame
198204 int i = 0 ;
199205
200- RndGen::set_seed (12 );
206+ RndGen::set_seed (123 );
201207
202208 scene s = many_spheres ();
203209 // scene s = single_cube();
204210
205211 // frameScene.add(rotatedCube);
206212 vector<unsigned char > localImage (image.size ());
207- c.renderPixelsParallel (s, localImage);
213+ c.renderPixelsParallelWithTiming (s, localImage);
208214 dumpImageToFile (localImage, " res/output" + to_string (i) + " .png" );
209215
210216 // std::function<void(int)> renderFrame = [&](int i)
0 commit comments