more stuff
This commit is contained in:
parent
43b85ae5d8
commit
abe4aa6115
6 changed files with 14 additions and 9 deletions
2
assignment-1b/.gitignore
vendored
2
assignment-1b/.gitignore
vendored
|
@ -5,3 +5,5 @@
|
||||||
*.ppm
|
*.ppm
|
||||||
*.zip
|
*.zip
|
||||||
*.pdf
|
*.pdf
|
||||||
|
perf.data*
|
||||||
|
flamegraph.svg
|
||||||
|
|
|
@ -4,6 +4,10 @@ authors = ["Michael Zhang <zhan4854@umn.edu>"]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
# For profiling with flamegraphs
|
||||||
|
[profile.release]
|
||||||
|
debug = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "raytracer1b"
|
name = "raytracer1b"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -6,6 +6,7 @@ use assignment_1b::image::Image;
|
||||||
use assignment_1b::ray::Ray;
|
use assignment_1b::ray::Ray;
|
||||||
use assignment_1b::scene::Scene;
|
use assignment_1b::scene::Scene;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
|
||||||
|
|
||||||
/// Simple raycaster.
|
/// Simple raycaster.
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
|
@ -69,12 +70,8 @@ fn main() -> Result<()> {
|
||||||
// Generate a parallel iterator for pixels
|
// Generate a parallel iterator for pixels
|
||||||
// The iterator preserves order and uses row-major order
|
// The iterator preserves order and uses row-major order
|
||||||
let pixels_iter = (0..scene.image_height)
|
let pixels_iter = (0..scene.image_height)
|
||||||
// .into_par_iter()
|
.into_par_iter()
|
||||||
.flat_map(|y| {
|
.flat_map(|y| (0..scene.image_width).into_par_iter().map(move |x| (x, y)));
|
||||||
(0..scene.image_width)
|
|
||||||
// .into_par_iter()
|
|
||||||
.map(move |x| (x, y))
|
|
||||||
});
|
|
||||||
|
|
||||||
// Loop through every single pixel of the output file
|
// Loop through every single pixel of the output file
|
||||||
let pixels = pixels_iter
|
let pixels = pixels_iter
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl Scene {
|
||||||
1 => LightKind::Point {
|
1 => LightKind::Point {
|
||||||
location: read_vec3(0)?,
|
location: read_vec3(0)?,
|
||||||
},
|
},
|
||||||
_ => bail!("Invalid w"),
|
_ => bail!("Invalid w; must be either 0 or 1"),
|
||||||
};
|
};
|
||||||
let light = Light {
|
let light = Light {
|
||||||
kind,
|
kind,
|
||||||
|
|
|
@ -33,9 +33,10 @@ pub fn compute_rotation_matrix(
|
||||||
a: Vector3<f64>,
|
a: Vector3<f64>,
|
||||||
b: Vector3<f64>,
|
b: Vector3<f64>,
|
||||||
) -> Result<Matrix3<f64>> {
|
) -> Result<Matrix3<f64>> {
|
||||||
// Special case: if a and b are in the same direction, just return the identity matrix
|
// Special case: if a and b are in the same direction, just return the
|
||||||
|
// identity matrix.
|
||||||
if a.normalize() == b.normalize() {
|
if a.normalize() == b.normalize() {
|
||||||
return Ok(Matrix3::identity())
|
return Ok(Matrix3::identity());
|
||||||
}
|
}
|
||||||
|
|
||||||
let cos_t = a.dot(&b);
|
let cos_t = a.dot(&b);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
cargo-flamegraph
|
cargo-flamegraph
|
||||||
cargo-watch
|
cargo-watch
|
||||||
imagemagick
|
imagemagick
|
||||||
|
linuxPackages_latest.perf
|
||||||
pandoc
|
pandoc
|
||||||
texlive.combined.scheme-full
|
texlive.combined.scheme-full
|
||||||
unzip
|
unzip
|
||||||
|
|
Loading…
Reference in a new issue