-
Notifications
You must be signed in to change notification settings - Fork 1
/
all-materials-spheres.rs
67 lines (61 loc) · 1.51 KB
/
all-materials-spheres.rs
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use glam::DVec3;
use raytracer::{
camera::Camera, material::Material,
shapes::sphere::Sphere,
};
use std::io;
fn main() -> io::Result<()> {
let mut world = vec![];
let material_ground = Material::Lambertian {
albedo: DVec3::new(0.8, 0.8, 0.0),
};
let material_center = Material::Lambertian {
albedo: DVec3::new(0.1, 0.2, 0.5),
};
let material_left = Material::Dielectric {
index_of_refraction: 1.5,
};
let material_right = Material::Metal {
albedo: DVec3::new(0.8, 0.6, 0.2),
fuzz: 0.0,
};
world.push(Sphere::new(
DVec3::new(0.0, -100.5, -1.0),
100.0,
material_ground,
));
world.push(Sphere::new(
DVec3::new(0.0, 0.0, -1.0),
0.5,
material_center,
));
world.push(Sphere::new(
DVec3::new(-1.0, 0.0, -1.0),
0.5,
material_left.clone(),
));
world.push(Sphere::new(
DVec3::new(-1.0, 0.0, -1.0),
-0.4,
material_left,
));
world.push(Sphere::new(
DVec3::new(1.0, 0.0, -1.0),
0.5,
material_right,
));
let camera = Camera::init()
.image_width(800)
.aspect_ratio(16.0 / 9.0)
.look_from(DVec3::new(-2., 2., 1.))
.look_at(DVec3::NEG_Z)
.vup(DVec3::Y)
// .focus_dist(10.0)
// .defocus_angle(0.0)
.samples_per_pixel(500)
.max_depth(50)
.build();
camera
.render_to_disk("all-materials-spheres", world)?;
Ok(())
}