diff --git a/src/consts.rs b/src/consts.rs index 15cd97a..082641a 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -19,19 +19,22 @@ pub const ANGLE_POWER: f64 = 2.; //pub const IMG_WIDTH: usize = 480; //pub const IMG_WIDTH: usize = 1280; -pub const IMG_WIDTH: usize = 1080; +//pub const IMG_WIDTH: usize = 1080; +//pub const IMG_WIDTH: usize = 1920; +pub const IMG_WIDTH: usize = 4961; //pub const IMG_HEIGHT: usize = 480; //pub const IMG_HEIGHT: usize = 720; -pub const IMG_HEIGHT: usize = 1080; +//pub const IMG_HEIGHT: usize = 1080; +pub const IMG_HEIGHT: usize = 3508; pub const IMG_DIM: usize = if IMG_HEIGHT > IMG_WIDTH { IMG_HEIGHT } else { IMG_WIDTH }; pub const IMG_SIZE: usize = IMG_WIDTH * IMG_HEIGHT; pub const IMG_BYTE_SIZE: usize = IMG_SIZE * 3; -//pub const SUPERSAMPLING: usize = 1; -pub const SUPERSAMPLING: usize = 2; -//pub const RAYS_PER_PIXEL: usize = 1; +pub const SUPERSAMPLING: usize = 1; +//pub const SUPERSAMPLING: usize = 2; +pub const RAYS_PER_PIXEL: usize = 1; //pub const RAYS_PER_PIXEL: usize = 50; -pub const RAYS_PER_PIXEL: usize = 500; +//pub const RAYS_PER_PIXEL: usize = 500; //pub const MAX_BOUNCES: u32 = 1; //pub const MAX_BOUNCES: u32 = 4; //pub const MAX_BOUNCES: u32 = 8; @@ -39,7 +42,7 @@ pub const MAX_BOUNCES: u32 = 10; //pub const THREAD_COUNT: usize = 1; pub const THREAD_COUNT: usize = 12; -pub const SLICES_PER_THREAD: usize = 16; +pub const SLICES_PER_THREAD: usize = 32; pub const REPORT_STATUS: bool = true; pub const UP: Vec3 = Y; diff --git a/src/main.rs b/src/main.rs index 333ef35..c271ce3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,7 +85,7 @@ fn default_scene3() -> Scene { fn main() { // get scene and camera - let scene = scene_from_file("scenes/insidemirror.lua".to_owned()).unwrap(); + let scene = scene_from_file("scenes/randomspheres.lua".to_owned()).unwrap(); //let scene = default_scene3(); let cam = default_cam(); diff --git a/src/structs/cam.rs b/src/structs/cam.rs index ff68df2..2c3c23f 100644 --- a/src/structs/cam.rs +++ b/src/structs/cam.rs @@ -56,7 +56,7 @@ struct Slice { type CastData = [Option; MAX_BOUNCES as usize]; const NONE_CAST_DATA: CastData = [None; MAX_BOUNCES as usize]; -pub type Image = [u8; IMG_BYTE_SIZE]; +pub type Image = Vec; fn l2s(l: f64) -> u8 { (f64::powf(f64::clamp(l, 0., 1.), 1./2.2) * 255. + 0.5) as u8 @@ -128,7 +128,8 @@ impl Cam { } let lights = scene.get_lights(); - let mut pixels = [0; IMG_BYTE_SIZE]; + let mut pixels = Vec::with_capacity(IMG_BYTE_SIZE); + pixels.resize(IMG_BYTE_SIZE, 0u8); for y in 0..IMG_HEIGHT { for x in 0..IMG_WIDTH { let field_pos = (x + y*IMG_WIDTH) * 3; @@ -136,7 +137,7 @@ impl Cam { } if REPORT_STATUS { - stderr.write_all(format!("\x1b[1K\x1b[GRendering... {}/{} rows ({:.2}%)", y+1, IMG_HEIGHT, (y+1) as f64/IMG_HEIGHT as f64).as_bytes()).unwrap(); + stderr.write_all(format!("\x1b[1K\x1b[GRendering... {}/{} rows ({:.2}%)", y+1, IMG_HEIGHT, (y+1) as f64*100./IMG_HEIGHT as f64).as_bytes()).unwrap(); stderr.flush().unwrap(); } } @@ -150,7 +151,8 @@ impl Cam { } pub fn render_multithreaded(&self, scene: &T) -> Image { - let mut pixels = [0; IMG_BYTE_SIZE]; + let mut pixels = Vec::with_capacity(IMG_BYTE_SIZE); + pixels.resize(IMG_BYTE_SIZE, 0u8); crossbeam::scope(|scope| { // initialize everything for render