Viking room first tries
This commit is contained in:
		
							parent
							
								
									64f46fb251
								
							
						
					
					
						commit
						3f225bde7f
					
				
					 3 changed files with 40 additions and 23 deletions
				
			
		|  | @ -1,7 +1,4 @@ | |||
| # Blender v2.82 (sub 7) OBJ File: '' | ||||
| # www.blender.org | ||||
| mtllib viking_room.mtl | ||||
| o mesh_all1_Texture1_0 | ||||
| 
 | ||||
| v -0.573651 0.001530 0.713748 | ||||
| v -0.573651 0.151382 -0.000154 | ||||
| v -0.573651 0.164474 0.619081 | ||||
|  |  | |||
							
								
								
									
										54
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								src/main.rs
									
									
									
									
									
								
							|  | @ -67,17 +67,17 @@ fn main() { | |||
| 
 | ||||
|     // Image
 | ||||
|     let aspect_ratio = 10.0 / 7.5; //16.0 / 9.0;
 | ||||
|     let image_width = 400; | ||||
|     let image_width = 600; | ||||
|     let image_height = (image_width as f64 / aspect_ratio) as u32; | ||||
|     let samples_per_pixel = 100_u32; | ||||
|     let max_depth = 50; | ||||
|     let samples_per_pixel = 1_u32; | ||||
|     let max_depth = 30; | ||||
|     let antialiasing_threshold = 0.2; // at what diff between two colors will a pixel be antialiased
 | ||||
| 
 | ||||
|     let vfov = 40.0; | ||||
|     let lookfrom = Point3::new(2.0, 0.8, 3.0); | ||||
|     let lookat = Point3::new(0.0, 0.0, 0.0); | ||||
|     let vfov = 43.0; | ||||
|     let lookfrom = Point3::new(2.0, 1.0, 1.0); | ||||
|     let lookat = Point3::new(0.0, 0.2, 0.0); | ||||
|     let vup = Vec3::new(0.0, 1.0, 0.0); | ||||
|     let dist_to_focus = 3.0; | ||||
|     let dist_to_focus = 1.0; | ||||
|     let aperture = 0.0; // disable depth of field
 | ||||
| 
 | ||||
|     // limit rayon multithreading thread count
 | ||||
|  | @ -88,7 +88,7 @@ fn main() { | |||
| 
 | ||||
|     // World
 | ||||
|     eprintln!("[1/4] Loading meshes from file..."); | ||||
|     let world = from_obj("obj/suzanne.obj"); | ||||
|     let world = from_obj("obj/viking_room.obj"); | ||||
|     // let world = random_world();
 | ||||
| 
 | ||||
|     // Camera
 | ||||
|  | @ -137,6 +137,26 @@ fn main() { | |||
|         .collect(); | ||||
|     bar.finish_and_clear(); | ||||
| 
 | ||||
|     // no antialiasing
 | ||||
|     if samples_per_pixel == 1_u32 { | ||||
|         eprintln!("[4/4] Exporting image to disk...");  
 | ||||
|         (0..image_height).into_iter().rev().for_each(|j| { | ||||
|             (0..image_width).into_iter().for_each(|i| { | ||||
|                 color::put_color( | ||||
|                     &mut image, | ||||
|                     &color_lines[(image_height - j - 1) as usize][i as usize], | ||||
|                     i, | ||||
|                     image_height - j - 1, | ||||
|                     1, | ||||
|                 ); | ||||
|             }) | ||||
|         }); | ||||
| 
 | ||||
|         image.save(default_file).unwrap(); | ||||
| 
 | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     eprintln!("[3/4] Antialiasing image..."); | ||||
|     let mut antialiasing: Vec<Vec<bool>> = Vec::new(); | ||||
|     let mut antialiasing_counter = 0; | ||||
|  | @ -262,13 +282,13 @@ fn from_obj(path: &str) -> HittableList { | |||
|     ))); | ||||
|     */ | ||||
| 
 | ||||
|     let material = Arc::new(Lambertian::new(&Color::new( | ||||
|         77.0 / 255.0, | ||||
|         77.0 / 255.0, | ||||
|         118.0 / 255.0, | ||||
|     ))); | ||||
|     //let material = Arc::new(Lambertian::new(&Color::new(
 | ||||
|     //    77.0 / 255.0,
 | ||||
|     //    77.0 / 255.0,
 | ||||
|     //    118.0 / 255.0,
 | ||||
|     //)));
 | ||||
|     //let material = Arc::new(Dielectric::new(2.0));
 | ||||
|     //let material = Arc::new(Metal::new(&Color::new(0.9, 0.9, 0.7), 1.0));
 | ||||
|     let material = Arc::new(Metal::new(&Color::new(0.7, 0.7, 0.8), 0.0)); | ||||
|     //let material = Arc::new(Rainbow::new());
 | ||||
| 
 | ||||
|     let cornell_box = tobj::load_obj(path, &tobj::OFFLINE_RENDERING_LOAD_OPTIONS); | ||||
|  | @ -337,18 +357,18 @@ fn from_obj(path: &str) -> HittableList { | |||
|             world.add(Box::<Triangle>::new(Triangle::new( | ||||
|                 Point3::new( | ||||
|                     mesh.positions[3 * index_a] as f64, | ||||
|                     mesh.positions[3 * index_a + 1] as f64, | ||||
|                     mesh.positions[3 * index_a + 2] as f64, | ||||
|                     mesh.positions[3 * index_a + 1] as f64, | ||||
|                 ), | ||||
|                 Point3::new( | ||||
|                     mesh.positions[3 * index_b] as f64, | ||||
|                     mesh.positions[3 * index_b + 1] as f64, | ||||
|                     mesh.positions[3 * index_b + 2] as f64, | ||||
|                     mesh.positions[3 * index_b + 1] as f64, | ||||
|                 ), | ||||
|                 Point3::new( | ||||
|                     mesh.positions[3 * index_c] as f64, | ||||
|                     mesh.positions[3 * index_c + 1] as f64, | ||||
|                     mesh.positions[3 * index_c + 2] as f64, | ||||
|                     mesh.positions[3 * index_c + 1] as f64, | ||||
|                 ), | ||||
|                 normal_avg, | ||||
|                 material.clone(), | ||||
|  |  | |||
|  | @ -77,7 +77,7 @@ impl Material for Metal { | |||
|         *scattered = Ray::new(rec.p, reflected + self.fuzz * Vec3::random_in_unit_sphere()); | ||||
|         *attenuation = self.albedo.clone(); | ||||
| 
 | ||||
|         return Vec3::dot(scattered.direction(), rec.normal) > 0.0; | ||||
|         return true;//Vec3::dot(scattered.direction(), rec.normal) > 0.0;
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -97,7 +97,7 @@ impl Material for Mirror { | |||
|     ) -> bool { | ||||
|         if utility::random_f64() > 0.8 { | ||||
|             // Reflektiert
 | ||||
|             let reflected = Vec3::reflect(&Vec3::unit_vector(r_in.direction()), &rec.normal); | ||||
|             let reflected = Vec3::reflect(&r_in.direction(), &rec.normal); | ||||
|             *scattered = Ray::new(rec.p, reflected); | ||||
|             *attenuation = self.albedo.clone(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue