From 9235e74dfbc41895a5f8807e1ab93508268a39ea Mon Sep 17 00:00:00 2001 From: Julian T Date: Wed, 3 Feb 2021 17:54:03 +0100 Subject: Base render of surface normal, and abstract shading and tracing to the trace module --- src/render.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/render.rs') 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, 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) { -- cgit v1.2.3