better image
This commit is contained in:
parent
63d4cbb042
commit
5857244ca8
2 changed files with 4 additions and 7 deletions
|
|
@ -14,11 +14,9 @@ use std::sync::Arc;
|
|||
|
||||
fn main() {
|
||||
let aspect_ratio = 16.0 / 9.0;
|
||||
let image_width = 800;
|
||||
let image_width = 1920;
|
||||
let focal_length = 1.0;
|
||||
let viewport_height = 2.0;
|
||||
let camera_center = Point3::new(0.0, 0.0, 0.0);
|
||||
|
||||
|
||||
let m = Lambertian::new(Vec3::new(0.5,0.5,0.5));
|
||||
let world_m: Arc <dyn Material> = Arc::new(m);
|
||||
|
|
@ -29,11 +27,10 @@ fn main() {
|
|||
let m = Metal::new(Vec3::new(0.8, 0.8, 0.8), 0.3);
|
||||
let left_m: Arc <dyn Material> = Arc::new(m);
|
||||
|
||||
|
||||
let m = Metal::new(Vec3::new(0.8, 0.6, 0.2), 0.5);
|
||||
let right_m: Arc <dyn Material> = Arc::new(m);
|
||||
|
||||
let mut camera = Camera::new(aspect_ratio,image_width,focal_length,Point3::new(-2.0,2.0,1.0),Point3::new(0.0,0.0,-1.0),90.0);
|
||||
let mut camera = Camera::new(aspect_ratio,image_width,focal_length,Point3::new(-1.0,1.0,1.0),Point3::new(0.0,0.0,-1.0),90.0);
|
||||
let mut world = World::new();
|
||||
world.add(Sphere::new(0.5, Point3::new(0.0, 0.0, -1.0),center_m));
|
||||
world.add(Sphere::new(0.5, Point3::new(-1.0, 0.0, -1.0),left_m));
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ impl Camera {
|
|||
let height = self.img.height;
|
||||
let width = self.img.width;
|
||||
let total_pixels = height*width;
|
||||
let num_samples = 5;
|
||||
let num_samples = 25;
|
||||
|
||||
//cast to const ref
|
||||
let const_self = &*self;
|
||||
|
|
@ -97,8 +97,8 @@ impl Camera {
|
|||
let x = i%width;
|
||||
let y = i/width;
|
||||
let (mut r,mut g,mut b) = (0.0,0.0,0.0);
|
||||
let ray = const_self.get_ray(x,y,&mut rng);
|
||||
for _ in 0..num_samples{
|
||||
let ray = const_self.get_ray(x,y,&mut rng);
|
||||
let (tr,tg,tb) = trace(ray, &world,10,&mut rng);
|
||||
r+=tr;
|
||||
g+=tg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue