Compare commits
2 Commits
c90b185b8d
...
30b972ce5c
Author | SHA1 | Date | |
---|---|---|---|
30b972ce5c | |||
560b921b3a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
|||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
.vscode/
|
.vscode/
|
||||||
|
*.png
|
||||||
|
@ -117,6 +117,7 @@ fn cornell_box() -> Scene {
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
// Boxes
|
// Boxes
|
||||||
|
|
||||||
let rotated1 = RotateY::new(
|
let rotated1 = RotateY::new(
|
||||||
Cuboid::new(
|
Cuboid::new(
|
||||||
Point3::new(0.0, 0.0, 0.0),
|
Point3::new(0.0, 0.0, 0.0),
|
||||||
@ -144,7 +145,6 @@ fn cornell_box() -> Scene {
|
|||||||
);
|
);
|
||||||
world.push(Arc::new(box2));
|
world.push(Arc::new(box2));
|
||||||
|
|
||||||
|
|
||||||
let look_from = Point3::new(278.0, 278.0, -800.0);
|
let look_from = Point3::new(278.0, 278.0, -800.0);
|
||||||
let look_at = Point3::new(278.0, 278.0, 0.0);
|
let look_at = Point3::new(278.0, 278.0, 0.0);
|
||||||
let focus_dist = 2.0;
|
let focus_dist = 2.0;
|
||||||
@ -493,6 +493,7 @@ fn main() {
|
|||||||
let image_height: usize = (IMAGE_WIDTH as f64 / scene_setup.cam.aspect_ratio()) as usize;
|
let image_height: usize = (IMAGE_WIDTH as f64 / scene_setup.cam.aspect_ratio()) as usize;
|
||||||
let mut pixels = vec![0; IMAGE_WIDTH * image_height * 3];
|
let mut pixels = vec![0; IMAGE_WIDTH * image_height * 3];
|
||||||
let bands: Vec<(usize, &mut [u8])> = pixels.chunks_mut(3).enumerate().collect();
|
let bands: Vec<(usize, &mut [u8])> = pixels.chunks_mut(3).enumerate().collect();
|
||||||
|
//rayon::ThreadPoolBuilder::new().num_threads(3).build_global().unwrap(); // Enable, to reduce load
|
||||||
let count = Mutex::new(0);
|
let count = Mutex::new(0);
|
||||||
bands.into_par_iter().for_each(|(i, pixel)| {
|
bands.into_par_iter().for_each(|(i, pixel)| {
|
||||||
let row = image_height - (i / IMAGE_WIDTH) - 1;
|
let row = image_height - (i / IMAGE_WIDTH) - 1;
|
||||||
|
@ -21,7 +21,7 @@ impl<H: Hittable> Hittable for Translate<H> {
|
|||||||
match &self.hittable.hit(&moved_ray, t_min, t_max) {
|
match &self.hittable.hit(&moved_ray, t_min, t_max) {
|
||||||
Some(hit_record) => {
|
Some(hit_record) => {
|
||||||
let mut hr = HitRecord {
|
let mut hr = HitRecord {
|
||||||
point: hit_record.point,
|
point: hit_record.point + self.offset,
|
||||||
material: hit_record.material,
|
material: hit_record.material,
|
||||||
front_face: hit_record.front_face, // Maybe need to calc normal and front_face again?
|
front_face: hit_record.front_face, // Maybe need to calc normal and front_face again?
|
||||||
normal: hit_record.normal,
|
normal: hit_record.normal,
|
||||||
|
Loading…
Reference in New Issue
Block a user