From 20642d8b5c478e50e59feb27073ad665664b8bd3 Mon Sep 17 00:00:00 2001 From: Rosyid Haryadi Date: Mon, 3 Mar 2025 16:53:07 +0700 Subject: pic --- img/output.png | Bin 109437 -> 129953 bytes src/common.rs | 6 +----- src/main.rs | 17 ++++++++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/img/output.png b/img/output.png index 9d1fbd8..8ccf097 100644 Binary files a/img/output.png and b/img/output.png differ diff --git a/src/common.rs b/src/common.rs index 3f111ec..d591207 100644 --- a/src/common.rs +++ b/src/common.rs @@ -6,10 +6,6 @@ pub const ASPECT_RATIO: f32 = 16.0 / 9.0; pub const IMG_WIDTH: usize = 400; pub const IMG_HEIGHT: usize = get_image_height(IMG_WIDTH, ASPECT_RATIO); -pub const VIEWPORT_HEIGHT: f32 = 2.0; -pub const FOCAL_LENGTH: f32 = 1.0; -pub const CAMERA_CENTER: Point3 = Point3 { x: 0.0, y: 0.0, z: 0.0 }; - pub const SAMPLES_PER_PIXEL: usize = 100; pub const MAX_DEPTH: usize = 50; @@ -18,7 +14,7 @@ pub const LOOK_FROM: Point3 = Point3 { x: -2.0, y: 2.0, z: 1.0 }; pub const LOOK_AT: Point3 = Point3 { x: 0.0, y: 0.0, z: -1.0 }; pub const VUP: Vec3 = Vec3 { x: 0.0, y: 1.0, z: 0.0 }; -pub const DEFOCUS_ANGLE: f32 = 10.0; +pub const DEFOCUS_ANGLE: f32 = 0.0; pub const FOCUS_DIST: f32 = 4.0; pub const fn get_image_height(image_width: usize, aspect_ratio: f32) -> usize { diff --git a/src/main.rs b/src/main.rs index b33664e..864fd4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,25 +17,32 @@ fn main() { let mut display_buffer: DisplayBuffer = [[Pixel::default(); IMG_WIDTH]; IMG_HEIGHT]; let mut world = HittableList::new(); - let ground = Material::new(Color::from_name(ColorName::Maroon), MaterialType::Diffuse); - let stone = Material::new(Color::from_name(ColorName::Gray), MaterialType::Diffuse); + let ground = Material::new(Color::from_name(ColorName::Gray), MaterialType::Diffuse); + let stone = Material::new(Color::from_name(ColorName::Navy), MaterialType::Diffuse); let steel = Material::new(Color::from_name(ColorName::Silver), MaterialType::Metallic(0.1)); // let gold = Material::new(Color::from_name(ColorName::Yellow), MaterialType::Metallic(0.0)); let glass = Material::new(Color::from_name(ColorName::White), MaterialType::Transparent(1.5)); - let bubble = Material::new(Color::from_name(ColorName::White), MaterialType::Transparent(1.0 / 1.3)); + let rare_metal = Material::new(Color::from_name(ColorName::Red), MaterialType::Metallic(0.0)); world.push( Sphere::new(Point3::new(0.0, -100.5, -1.0), 100.0, ground) ); world.push( - Sphere::new(Point3::new(0.0, 0.0, -1.2), 0.5, stone) + Sphere::new(Point3::new(0.0, 0.0, -1.0), 0.5, stone) ); world.push( - Sphere::new(Point3::new(-1.0, 0.0, -1.0), 0.5, glass) + Sphere::new(Point3::new(-1.0, 0.0, -1.0), 0.5, glass.clone()) ); world.push( Sphere::new(Point3::new(1.0, 0.0, -1.0), 0.5, steel) ); + world.push( + Sphere::new(Point3::new(1.0, -0.3, 0.0), 0.3, rare_metal) + ); + world.push( + Sphere::new(Point3::new(0.3, -0.4, 0.0), 0.4, glass.clone()) + ); + let camera = Camera::default(); -- cgit v1.2.3-70-g09d2