diff options
author | Julian T <julian@jtle.dk> | 2021-02-03 17:54:03 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-02-03 17:54:03 +0100 |
commit | 9235e74dfbc41895a5f8807e1ab93508268a39ea (patch) | |
tree | b8e85390b9e131736016dd2589d5e6ea14013552 /src/render.rs | |
parent | 977b0e4152433b2a68e2b97fe5fe2c0ff6fb20d8 (diff) |
Base render of surface normal, and abstract shading and tracing to the
trace module
Diffstat (limited to 'src/render.rs')
-rw-r--r-- | src/render.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/render.rs b/src/render.rs index dcda672..7d05aba 100644 --- a/src/render.rs +++ b/src/render.rs @@ -4,12 +4,11 @@ use crate::camera::film::FilmTile; use crate::camera::Camera; use crate::scene::Scene; +use crate::trace::Tracer; -use crate::core::{Vector2f, Spectrum}; +use crate::core::{Vector2f, Vector3f, Spectrum}; use crate::Float; -const HALF_PIXEL: Vector2f = Vector2f {x: 0.5, y: 0.5 }; - pub struct RenderTask { pub tile: Box<FilmTile>, samples: u32, @@ -18,6 +17,7 @@ pub struct RenderTask { pub struct RenderContext<'a> { pub scn: &'a Scene, pub cam: &'a Camera, + pub trc: &'a Tracer, } impl RenderTask { @@ -29,13 +29,7 @@ impl RenderTask { // Create a ray let (r, _) = ctx.cam.generate_ray(&Vector2f::new_xy(x as Float, y as Float)); - // Trace ray - if let Some(_) = ctx.scn.intersect(r) { - return Spectrum::new_rgb(0.5, 0.5, 0.0); - } - - Spectrum::new_rgb(0.0, 0.0, 0.0) - + ctx.trc.trace(ctx.scn, &r) } pub fn render(&mut self, ctx: &RenderContext) { |