diff options
author | Julian T <julian@jtle.dk> | 2021-08-05 15:44:40 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-08-05 15:44:40 +0200 |
commit | 3ef8f4d918406eec6bdc29e0ebd883fabfac9b2e (patch) | |
tree | aa4b1aac1e165821c16f222ebfb9212a9740e98b /src/render/task.rs | |
parent | 45119506c0293fdde6cef35f6e6f82d4055b46b6 (diff) |
Add picture for c5505ab84820248c6dba35fc06aef9e0ced183derendered
Diffstat (limited to 'src/render/task.rs')
-rw-r--r-- | src/render/task.rs | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/render/task.rs b/src/render/task.rs deleted file mode 100644 index 017fe24..0000000 --- a/src/render/task.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! Implements the main render loop -//! -//! This is not a final design -use crate::camera::film::FilmTile; -use crate::camera::Camera; -use crate::trace::{DefaultTracer, Tracer}; -use crate::sample::Sampler; - -use crate::core::{Vector2f}; -use crate::Float; - -pub struct RenderTask { - pub tile: Box<FilmTile>, - samples: u32, - pub tile_index: i32, -} - -pub struct RenderContext<'a> { - pub cam: &'a Camera, - pub trc: &'a DefaultTracer<'a>, -} - -impl RenderTask { - pub fn new(tile: Box<FilmTile>, samples: u32, tile_index: i32) -> Self { - Self { tile, samples, tile_index } - } - - fn render_at(&mut self, ctx: &RenderContext, x: i32, y: i32, sampler: &mut dyn Sampler) { - let corner = Vector2f::new_xy(x as Float, y as Float); - - for _ in 0..self.samples { - let p = corner + sampler.get_sample_2d(); - - // Create a ray - let (r, _) = ctx.cam.generate_ray(&p, sampler); - - self.tile.add_sample(&p, ctx.trc.trace(sampler, &r)); - } - } - - pub fn render(&mut self, ctx: &RenderContext, sampler: &mut dyn Sampler) { - let b = self.tile.bounds.clone(); - for y in b.min.y .. b.max.y { - for x in b.min.x .. b.max.x { - self.render_at(ctx, x, y, sampler); - } - } - } -} |