-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (42 loc) · 1.51 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "common.h"
#include "color.h"
#include "hittable.h"
#include "hittable_list.h"
#include "sphere.h"
#include "interval.h"
#include "camera.h"
#include "material.h"
#include <iostream>
int main()
{
clock_t start, end;
hittable_list world;
auto R = cos(pi / 4);
auto material_ground = make_shared<lambertian>(color(0.8, 0.8, 0.0));
auto material_center = make_shared<lambertian>(color(0.1, 0.2, 0.5));
auto material_left = make_shared<dielectric>(1.5);
auto material_right = make_shared<metal>(color(0.8, 0.6, 0.2), 0.0);
world.add(make_shared<sphere>(point3(0.0, -100.5, -1.0), 100.0, material_ground));
world.add(make_shared<sphere>(point3(0.0, 0.0, -1.0), 0.5, material_center));
world.add(make_shared<sphere>(point3(-1.0, 0.0, -1.0), 0.5, material_left));
world.add(make_shared<sphere>(point3(-1.0, 0.0, -1.0), -0.4, material_left));
world.add(make_shared<sphere>(point3(1.0, 0.0, -1.0), 0.5, material_right));
camera cam;
cam.aspect_ratio = 16.0 / 9.0;
cam.image_width = 400;
cam.samples_per_pixel = 10;
cam.max_depth = 50;
cam.vfov = 90;
cam.lookfrom = point3(-2, 2, 1);
cam.lookat = point3(0, 0, -1);
cam.vup = vec3(0, 1, 0);
cam.defocus_angle = 10.0;
cam.focus_dist = 3.4;
cam.vfov = 20;
start = clock();
cam.render(world);
end = clock();
double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
std::clog << "Time taken by program: " << time_taken << " sec " << std::endl
<< std::flush;
}