From c2eb421fd8ac99729194f401ec72f4452447a1c5 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 10 Jul 2016 17:56:42 -0700 Subject: [PATCH] Actually use seed in renders. This is important for animations, where you don't want the same noise pattern every frame. --- src/parse/psy.rs | 1 + src/renderer.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/parse/psy.rs b/src/parse/psy.rs index 69b3705..1b3b529 100644 --- a/src/parse/psy.rs +++ b/src/parse/psy.rs @@ -87,6 +87,7 @@ pub fn parse_scene(tree: &DataTree) -> Result { output_file: output_info.clone(), resolution: ((render_settings.0).0 as usize, (render_settings.0).1 as usize), spp: render_settings.1 as usize, + seed: render_settings.2, scene: scene, }; diff --git a/src/renderer.rs b/src/renderer.rs index f303f9e..3bf99a8 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -23,6 +23,7 @@ pub struct Renderer { pub output_file: String, pub resolution: (usize, usize), pub spp: usize, + pub seed: u32, pub scene: Scene, } @@ -82,10 +83,10 @@ impl Renderer { } } - // Generate rays + // Generate light paths and initial rays for y in bucket.y..(bucket.y + bucket.h) { for x in bucket.x..(bucket.x + bucket.w) { - let offset = hash_u32(((x as u32) << 16) ^ (y as u32), 0); + let offset = hash_u32(((x as u32) << 16) ^ (y as u32), self.seed); for si in 0..self.spp { // Calculate image plane x and y coordinates let (img_x, img_y) = {