From 89a5c9a8a0cdf627cda0e31da454f83ca21315ce Mon Sep 17 00:00:00 2001 From: lamp Date: Sun, 21 Jan 2024 16:40:16 +0000 Subject: implement beer's law for colourful dielectrics --- src/scenes.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/scenes.rs') diff --git a/src/scenes.rs b/src/scenes.rs index 7cdce86..54f6eb3 100644 --- a/src/scenes.rs +++ b/src/scenes.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use crate::hittable::{ConstantMedium, Hittable}; use crate::hittable::HittableBox; use crate::hittable::HittableList; -use crate::material::{Dielectric, DiffuseLight, Lambertian, Material, Metal}; +use crate::material::{Dielectric, DielectricAttenuation, DiffuseLight, Lambertian, Material, Metal}; use crate::hittable::instance::RotateY; use crate::hittable::instance::RotateX; use crate::hittable::instance::RotateZ; @@ -59,14 +59,14 @@ fn random_scene() -> (Arc, Point3, Point3, f64, f64, Color) { sphere_material = Arc::new(Metal { albedo, fuzz }); world.add(Arc::new(Sphere { center, radius: 0.2, material: sphere_material })); } else { - sphere_material = Arc::new(Dielectric { index_of_refraction: 1.5 }); + sphere_material = Arc::new(Dielectric { index_of_refraction: 1.5, attenuation: Some(DielectricAttenuation { albedo: Color { x: 0.5, y: 0.5, z: 0.8 }, constant: 0.8 } ) }); world.add(Arc::new(Sphere { center, radius: 0.2, material: sphere_material })); } } } } - let material1 = Arc::new(Dielectric { index_of_refraction: 1.5 }); + let material1 = Arc::new(Dielectric { index_of_refraction: 1.5, attenuation: Some(DielectricAttenuation { albedo: Color { x: 0.5, y: 0.5, z: 0.8 }, constant: 0.8 } ) }); world.add(Arc::new(Sphere { center: Point3 { x: 0.0, y: 1.0, z: 0.0 }, radius: 1.0, material: material1 })); let material2 = Arc::new(Lambertian { albedo: Arc::new(SolidColor::from_color(Color { x: 0.4, y: 0.2, z: 0.1 })) }); @@ -199,13 +199,13 @@ fn final_scene() -> (Arc, Point3, Point3, f64, f64, Color) { let moving_sphere_material = Arc::new(Lambertian::from_color(Color { x: 0.7, y: 0.3, z: 0.1 })); objects.add(Arc::new(Moving { hittable: Arc::new(Sphere { center: Point3::new(), radius: 50.0, material: moving_sphere_material }), offset_start: center_1, offset_end: center_2, time_start: 0.0, time_end: 1.0, })); - objects.add(Arc::new(Sphere { center: Point3 { x: 260.0, y: 150.0, z: 45.0 }, radius: 50.0, material: Arc::new(Dielectric { index_of_refraction: 1.5 }) })); + objects.add(Arc::new(Sphere { center: Point3 { x: 260.0, y: 150.0, z: 45.0 }, radius: 50.0, material: Arc::new(Dielectric { index_of_refraction: 1.5, attenuation: None }) })); objects.add(Arc::new(Sphere { center: Point3 { x: 0.0, y: 150.0, z: 145.0 }, radius: 50.0, material: Arc::new(Metal { albedo: Color { x: 0.8, y: 0.8, z: 0.9 }, fuzz: 1.0 }) })); - let boundary = Arc::new(Sphere { center: Point3 { x: 360.0, y: 150.0, z: 145.0 }, radius: 70.0, material: Arc::new(Dielectric { index_of_refraction: 1.5 }) }); + let boundary = Arc::new(Sphere { center: Point3 { x: 360.0, y: 150.0, z: 145.0 }, radius: 70.0, material: Arc::new(Dielectric { index_of_refraction: 1.5, attenuation: None }) }); objects.add(boundary.clone()); objects.add(Arc::new(ConstantMedium::new(boundary.clone(), 0.2, Arc::new(SolidColor::from_color(Color { x: 0.2, y: 0.4, z: 0.9 }))))); - let boundary = Arc::new(Sphere { center: Point3 { x: 0.0, y: 0.0, z: 0.0 }, radius: 5000.0, material: Arc::new(Dielectric { index_of_refraction: 1.5 }) }); + let boundary = Arc::new(Sphere { center: Point3 { x: 0.0, y: 0.0, z: 0.0 }, radius: 5000.0, material: Arc::new(Dielectric { index_of_refraction: 1.5, attenuation: None }) }); objects.add(Arc::new(ConstantMedium::new(boundary.clone(), 0.0001, Arc::new(SolidColor::from_color(Color { x: 1.0, y: 1.0, z: 1.0 }))))); let emat = Arc::new(Lambertian { albedo: Arc::new(ImageTexture::from_bmp_data(&include_bytes!("../res/earthmap.bmp").to_vec())) }); @@ -242,8 +242,8 @@ fn triangle_scene() -> (Arc, Point3, Point3, f64, f64, Color) { //let pertext = Arc::new(Lambertian { albedo: Arc::new(NoiseTexture::new(4.0)) }); //let pertext = Arc::new(Lambertian { albedo: Arc::new(SolidColor::from_color(Color {x: 0.0, y: 0.0, z: 0.0}) ) }); //objects.add(Arc::new(Triangle { material: Arc::new(Metal { albedo: Color { x: 0.7, y: 0.6, z: 0.5 }, fuzz: 0.0 }), v0 : Vec3::new(), v1: Vec3 { x: 0.0, y: 0.0, z: 1.0 }, v2: Vec3 { x: 0.0, y: 1.0, z: 0.5 } })); - //let monkey = Arc::new(Model::from_obj(include_str!("../res/monkey.obj"), Arc::new(Dielectric { index_of_refraction: 1.5 }))); - let monkey = Arc::new(Model::from_obj(include_str!("../res/monkey.obj"), Arc::new(Metal { albedo: Color { x: 0.7, y: 0.6, z: 0.5 }, fuzz: 0.5 }))); + let monkey = Arc::new(Model::from_obj(include_str!("../res/monkey.obj"), Arc::new(Dielectric { index_of_refraction: 1.5, attenuation: Some(DielectricAttenuation { albedo: Color { x: 0.5, y: 0.5, z: 0.8 }, constant: 0.8 } ) }))); + // let monkey = Arc::new(Model::from_obj(include_str!("../res/monkey.obj"), Arc::new(Metal { albedo: Color { x: 0.7, y: 0.6, z: 0.5 }, fuzz: 0.5 }))); let monkey = Arc::new(RotateX::new(monkey, 45.0)); let monkey = Arc::new(RotateZ::new(monkey, 45.0)); objects.add(monkey); -- cgit v1.2.3