From 4066bf4b85c35b96c704136658e6ac36aaf150d2 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sat, 17 Sep 2022 16:45:29 -0700 Subject: [PATCH] rtiow: add blox with gloxy edges. Fixed bug in kdtree that this uncovered. Marked Hit and it's dependencies as needing to implement the Debug trait. --- rtiow/renderer/src/bvh.rs | 2 + rtiow/renderer/src/constant_medium.rs | 1 + rtiow/renderer/src/cuboid.rs | 4 + rtiow/renderer/src/flip_normals.rs | 1 + rtiow/renderer/src/glowybox.rs | 142 +++++++++++++++++++++++ rtiow/renderer/src/hitable.rs | 14 ++- rtiow/renderer/src/hitable_list.rs | 2 +- rtiow/renderer/src/kdtree.rs | 10 ++ rtiow/renderer/src/lib.rs | 1 + rtiow/renderer/src/material.rs | 11 +- rtiow/renderer/src/moving_sphere.rs | 1 + rtiow/renderer/src/noise/lode.rs | 1 + rtiow/renderer/src/noise/mod.rs | 4 +- rtiow/renderer/src/noise/perlin.rs | 1 + rtiow/renderer/src/rect.rs | 3 + rtiow/renderer/src/renderer.rs | 4 + rtiow/renderer/src/rotate.rs | 1 + rtiow/renderer/src/scenes/mod.rs | 1 + rtiow/renderer/src/scenes/tron.rs | 135 +++++++++++++++++++++ rtiow/renderer/src/sphere.rs | 1 + rtiow/renderer/src/texture/checker.rs | 1 + rtiow/renderer/src/texture/mandelbrot.rs | 1 + rtiow/renderer/src/texture/mod.rs | 4 +- rtiow/renderer/src/texture/noise.rs | 1 + rtiow/renderer/src/translate.rs | 1 + 25 files changed, 338 insertions(+), 10 deletions(-) create mode 100644 rtiow/renderer/src/glowybox.rs create mode 100644 rtiow/renderer/src/scenes/tron.rs diff --git a/rtiow/renderer/src/bvh.rs b/rtiow/renderer/src/bvh.rs index 00ea741..248a4c7 100644 --- a/rtiow/renderer/src/bvh.rs +++ b/rtiow/renderer/src/bvh.rs @@ -9,6 +9,7 @@ use crate::{ ray::Ray, }; +#[derive(Debug)] enum BVHNode { Leaf(Box), Branch { @@ -178,6 +179,7 @@ impl Hit for BVHNode { } } +#[derive(Debug)] pub struct BVH { root: BVHNode, } diff --git a/rtiow/renderer/src/constant_medium.rs b/rtiow/renderer/src/constant_medium.rs index ae7156b..85da04a 100644 --- a/rtiow/renderer/src/constant_medium.rs +++ b/rtiow/renderer/src/constant_medium.rs @@ -11,6 +11,7 @@ use crate::{ vec3::Vec3, }; +#[derive(Debug)] pub struct ConstantMedium where H: Hit, diff --git a/rtiow/renderer/src/cuboid.rs b/rtiow/renderer/src/cuboid.rs index 890c5fc..75b6dd5 100644 --- a/rtiow/renderer/src/cuboid.rs +++ b/rtiow/renderer/src/cuboid.rs @@ -11,6 +11,7 @@ use crate::{ vec3::Vec3, }; +#[derive(Debug)] pub struct Cuboid { p_min: Vec3, p_max: Vec3, @@ -21,6 +22,9 @@ impl Cuboid { // This clippy doesn't work right with Arc. #[allow(clippy::needless_pass_by_value)] pub fn new(p_min: Vec3, p_max: Vec3, material: Arc) -> Cuboid { + assert!(p_min.x <= p_max.x); + assert!(p_min.y <= p_max.y); + assert!(p_min.z <= p_max.z); Cuboid { p_min, p_max, diff --git a/rtiow/renderer/src/flip_normals.rs b/rtiow/renderer/src/flip_normals.rs index e3a8be4..283dd56 100644 --- a/rtiow/renderer/src/flip_normals.rs +++ b/rtiow/renderer/src/flip_normals.rs @@ -4,6 +4,7 @@ use crate::{ ray::Ray, }; +#[derive(Debug)] pub struct FlipNormals where H: Hit, diff --git a/rtiow/renderer/src/glowybox.rs b/rtiow/renderer/src/glowybox.rs new file mode 100644 index 0000000..015b09e --- /dev/null +++ b/rtiow/renderer/src/glowybox.rs @@ -0,0 +1,142 @@ +use std::sync::Arc; + +use crate::{ + aabb::AABB, + cuboid::Cuboid, + flip_normals::FlipNormals, + hitable::{Hit, HitRecord}, + hitable_list::HitableList, + material::Material, + ray::Ray, + rect::{XYRect, XZRect, YZRect}, + vec3::Vec3, +}; + +#[derive(Debug)] +pub struct Glowybox { + p_min: Vec3, + p_max: Vec3, + main: Cuboid, + edges: [Cuboid; 12], +} + +impl Glowybox { + // This clippy doesn't work right with Arc. + #[allow(clippy::needless_pass_by_value)] + pub fn new( + p_min: Vec3, + p_max: Vec3, + edge_thickness: f32, + main_material: Arc, + edge_material: Arc, + ) -> Glowybox { + assert!(p_min.x < p_max.x); + assert!(p_min.y < p_max.y); + assert!(p_min.z < p_max.z); + let main = Cuboid::new(p_min, p_max, main_material); + // Top edges + let ht = edge_thickness / 2.; + let edges = [ + // Top edges + Cuboid::new( + [p_min.x - ht, p_max.y - ht, p_min.z - ht].into(), + [p_min.x + ht, p_max.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_min.x - ht, p_max.y - ht, p_min.z - ht].into(), + [p_max.x + ht, p_max.y + ht, p_min.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_max.x - ht, p_max.y - ht, p_min.z - ht].into(), + [p_max.x + ht, p_max.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_min.x - ht, p_max.y - ht, p_max.z - ht].into(), + [p_max.x + ht, p_max.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + // Bottom edges + Cuboid::new( + [p_min.x - ht, p_min.y - ht, p_min.z - ht].into(), + [p_min.x + ht, p_min.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_min.x - ht, p_min.y - ht, p_min.z - ht].into(), + [p_max.x + ht, p_min.y + ht, p_min.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_max.x - ht, p_min.y - ht, p_min.z - ht].into(), + [p_max.x + ht, p_min.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_min.x - ht, p_min.y - ht, p_max.z - ht].into(), + [p_max.x + ht, p_min.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + // Middle edges + Cuboid::new( + [p_min.x - ht, p_min.y - ht, p_min.z - ht].into(), + [p_min.x + ht, p_max.y + ht, p_min.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_min.x - ht, p_min.y - ht, p_max.z - ht].into(), + [p_min.x + ht, p_max.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_max.x - ht, p_min.y - ht, p_min.z - ht].into(), + [p_max.x + ht, p_max.y + ht, p_min.z + ht].into(), + Arc::clone(&edge_material), + ), + Cuboid::new( + [p_max.x - ht, p_min.y - ht, p_max.z - ht].into(), + [p_max.x + ht, p_max.y + ht, p_max.z + ht].into(), + Arc::clone(&edge_material), + ), + ]; + let p_min = [p_min.x - ht, p_min.y - ht, p_min.z - ht].into(); + let p_max = [p_max.x + ht, p_max.y + ht, p_max.z + ht].into(); + Glowybox { + p_min, + p_max, + main, + edges, + } + } +} + +impl Hit for Glowybox { + fn hit(&self, r: Ray, t_min: f32, t_max: f32) -> Option { + let mut edge_hit = None; + for edge in &self.edges { + if let Some(hit) = edge.hit(r, t_min, t_max) { + edge_hit = Some(hit); + break; + } + } + let main_hit = self.main.hit(r, t_min, t_max); + match (edge_hit, main_hit) { + (Some(ehit), Some(mhit)) => { + if mhit.t < ehit.t { + Some(mhit) + } else { + Some(ehit) + } + } + (Some(ehit), None) => Some(ehit), + (None, Some(mhit)) => Some(mhit), + _ => None, + } + } + + fn bounding_box(&self, t_min: f32, t_max: f32) -> Option { + Some(AABB::new(self.p_min, self.p_max)) + } +} diff --git a/rtiow/renderer/src/hitable.rs b/rtiow/renderer/src/hitable.rs index 6a34c64..2b0e671 100644 --- a/rtiow/renderer/src/hitable.rs +++ b/rtiow/renderer/src/hitable.rs @@ -1,7 +1,8 @@ -use std::sync::Arc; +use std::{fmt::Debug, sync::Arc}; use crate::{aabb::AABB, material::Material, ray::Ray, vec3::Vec3}; +#[derive(Debug)] pub struct HitRecord<'m> { pub t: f32, pub uv: (f32, f32), @@ -10,7 +11,7 @@ pub struct HitRecord<'m> { pub material: &'m dyn Material, } -pub trait Hit: Send + Sync { +pub trait Hit: Send + Sync + Debug { fn hit(&self, r: Ray, t_min: f32, t_max: f32) -> Option; fn bounding_box(&self, t_min: f32, t_max: f32) -> Option; } @@ -23,3 +24,12 @@ impl Hit for Arc { (**self).bounding_box(t_min, t_max) } } + +impl Hit for Box { + fn hit(&self, r: Ray, t_min: f32, t_max: f32) -> Option { + (**self).hit(r, t_min, t_max) + } + fn bounding_box(&self, t_min: f32, t_max: f32) -> Option { + (**self).bounding_box(t_min, t_max) + } +} diff --git a/rtiow/renderer/src/hitable_list.rs b/rtiow/renderer/src/hitable_list.rs index 937a0df..f94d385 100644 --- a/rtiow/renderer/src/hitable_list.rs +++ b/rtiow/renderer/src/hitable_list.rs @@ -7,7 +7,7 @@ use crate::{ vec3::Vec3, }; -#[derive(Default)] +#[derive(Debug, Default)] pub struct HitableList { list: Vec>, } diff --git a/rtiow/renderer/src/kdtree.rs b/rtiow/renderer/src/kdtree.rs index 30cb15f..b3c581b 100644 --- a/rtiow/renderer/src/kdtree.rs +++ b/rtiow/renderer/src/kdtree.rs @@ -5,9 +5,11 @@ use log::info; use crate::{ aabb::{surrounding_box, AABB}, hitable::{Hit, HitRecord}, + hitable_list::HitableList, ray::Ray, }; +#[derive(Debug)] pub enum KDTree { Leaf(Box), Branch { @@ -102,6 +104,14 @@ impl KDTree { }), _ => panic!("Unreachable"), }; + info!("left_half {:?}", left_half); + info!("right_half {:?}", right_half); + if left_half.is_empty() { + return KDTree::Leaf(Box::new(HitableList::new(right_half))); + }; + if right_half.is_empty() { + return KDTree::Leaf(Box::new(HitableList::new(left_half))); + }; KDTree::Branch { left: Box::new(KDTree::new(left_half, t_min, t_max)), right: Box::new(KDTree::new(right_half, t_min, t_max)), diff --git a/rtiow/renderer/src/lib.rs b/rtiow/renderer/src/lib.rs index e348ade..b6513f0 100644 --- a/rtiow/renderer/src/lib.rs +++ b/rtiow/renderer/src/lib.rs @@ -4,6 +4,7 @@ pub mod camera; pub mod constant_medium; pub mod cuboid; pub mod flip_normals; +pub mod glowybox; pub mod hitable; pub mod hitable_list; pub mod human; diff --git a/rtiow/renderer/src/material.rs b/rtiow/renderer/src/material.rs index 2e06cb8..97c6c7b 100644 --- a/rtiow/renderer/src/material.rs +++ b/rtiow/renderer/src/material.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{fmt::Debug, sync::Arc}; use rand::{self, Rng}; @@ -20,14 +20,14 @@ fn random_in_unit_sphere() -> Vec3 { } } -#[derive(Default)] +#[derive(Default, Debug)] pub struct ScatterResponse { pub scattered: Ray, pub attenutation: Vec3, pub reflected: bool, } -pub trait Material: Send + Sync { +pub trait Material: Send + Sync + Debug { fn scatter(&self, r_in: &Ray, rec: &HitRecord) -> ScatterResponse; fn emitted(&self, _u: f32, _v: f32, _p: Vec3) -> Vec3 { Vec3::new(0., 0., 0.) @@ -52,6 +52,7 @@ impl Material for Box { } } +#[derive(Debug)] pub struct Isotropic where T: Texture, @@ -82,6 +83,7 @@ where } } +#[derive(Debug)] pub struct Lambertian where T: Texture, @@ -113,6 +115,7 @@ where } } +#[derive(Debug)] pub struct Metal { albedo: Vec3, fuzzy: f32, @@ -167,6 +170,7 @@ fn schlick(cosine: f32, ref_idx: f32) -> f32 { r0 + (1. - r0) * (1. - cosine).powf(5.) } +#[derive(Debug)] pub struct Dielectric { ref_idx: f32, } @@ -213,6 +217,7 @@ impl Material for Dielectric { } } +#[derive(Debug)] pub struct DiffuseLight where T: Texture, diff --git a/rtiow/renderer/src/moving_sphere.rs b/rtiow/renderer/src/moving_sphere.rs index 18b022c..ed81e47 100644 --- a/rtiow/renderer/src/moving_sphere.rs +++ b/rtiow/renderer/src/moving_sphere.rs @@ -7,6 +7,7 @@ use crate::{ vec3::{dot, Vec3}, }; +#[derive(Debug)] pub struct MovingSphere where M: Material, diff --git a/rtiow/renderer/src/noise/lode.rs b/rtiow/renderer/src/noise/lode.rs index bbc6d08..4778d57 100644 --- a/rtiow/renderer/src/noise/lode.rs +++ b/rtiow/renderer/src/noise/lode.rs @@ -5,6 +5,7 @@ use rand; use crate::{noise::NoiseSource, vec3::Vec3}; const NOISE_SIZE: usize = 128; +#[derive(Debug)] pub struct Lode { // Using fixed array causes stack overflow. noise: Vec>>, //[[[f32; NOISE_SIZE]; NOISE_SIZE]; NOISE_SIZE], diff --git a/rtiow/renderer/src/noise/mod.rs b/rtiow/renderer/src/noise/mod.rs index de73c0d..82a2fe5 100644 --- a/rtiow/renderer/src/noise/mod.rs +++ b/rtiow/renderer/src/noise/mod.rs @@ -1,13 +1,13 @@ pub mod lode; pub mod perlin; -use std::f32::consts::PI; +use std::{f32::consts::PI, fmt::Debug}; use serde_derive::Deserialize; use crate::vec3::Vec3; -pub trait NoiseSource: Send + Sync { +pub trait NoiseSource: Send + Sync + Debug { /// value returns noise on the interval [0., 1.). fn value(&self, p: Vec3) -> f32; diff --git a/rtiow/renderer/src/noise/perlin.rs b/rtiow/renderer/src/noise/perlin.rs index fe87909..45d8fe4 100644 --- a/rtiow/renderer/src/noise/perlin.rs +++ b/rtiow/renderer/src/noise/perlin.rs @@ -8,6 +8,7 @@ use crate::{ vec3::{dot, Vec3}, }; +#[derive(Debug)] pub struct Perlin { ran_vec: Vec, perm_x: Vec, diff --git a/rtiow/renderer/src/rect.rs b/rtiow/renderer/src/rect.rs index ccc6c28..0fab9d3 100644 --- a/rtiow/renderer/src/rect.rs +++ b/rtiow/renderer/src/rect.rs @@ -8,6 +8,7 @@ use crate::{ vec3::Vec3, }; +#[derive(Debug)] pub struct XYRect where M: Material, @@ -69,6 +70,7 @@ where } } +#[derive(Debug)] pub struct XZRect where M: Material, @@ -130,6 +132,7 @@ where } } +#[derive(Debug)] pub struct YZRect where M: Material, diff --git a/rtiow/renderer/src/renderer.rs b/rtiow/renderer/src/renderer.rs index 890661f..1a11b93 100644 --- a/rtiow/renderer/src/renderer.rs +++ b/rtiow/renderer/src/renderer.rs @@ -42,6 +42,7 @@ pub enum Model { PerlinDebug, Spheramid, Test, + Tron, Tutorial, } @@ -58,6 +59,7 @@ impl Model { Model::PerlinDebug => scenes::perlin_debug::new(opt), Model::Spheramid => scenes::spheramid::new(opt), Model::Test => scenes::test::new(opt), + Model::Tron => scenes::tron::new(opt), Model::Tutorial => scenes::tutorial::new(opt), } } @@ -86,6 +88,7 @@ impl str::FromStr for Model { "perlin_debug" => Ok(Model::PerlinDebug), "spheramid" => Ok(Model::Spheramid), "test" => Ok(Model::Test), + "tron" => Ok(Model::Tron), "tutorial" => Ok(Model::Tutorial), _ => Err(ModelParseError(s.to_owned())), } @@ -105,6 +108,7 @@ impl std::string::ToString for Model { Model::PerlinDebug => "perlin_debug".to_string(), Model::Spheramid => "spheramid".to_string(), Model::Test => "test".to_string(), + Model::Tron => "tron".to_string(), Model::Tutorial => "tutorial".to_string(), } } diff --git a/rtiow/renderer/src/rotate.rs b/rtiow/renderer/src/rotate.rs index 5ef067a..e18a91e 100644 --- a/rtiow/renderer/src/rotate.rs +++ b/rtiow/renderer/src/rotate.rs @@ -7,6 +7,7 @@ use crate::{ vec3::Vec3, }; +#[derive(Debug)] pub struct RotateY where H: Hit, diff --git a/rtiow/renderer/src/scenes/mod.rs b/rtiow/renderer/src/scenes/mod.rs index deab28d..4bf9ced 100644 --- a/rtiow/renderer/src/scenes/mod.rs +++ b/rtiow/renderer/src/scenes/mod.rs @@ -8,4 +8,5 @@ pub mod mandelbrot; pub mod perlin_debug; pub mod spheramid; pub mod test; +pub mod tron; pub mod tutorial; diff --git a/rtiow/renderer/src/scenes/tron.rs b/rtiow/renderer/src/scenes/tron.rs new file mode 100644 index 0000000..31f582a --- /dev/null +++ b/rtiow/renderer/src/scenes/tron.rs @@ -0,0 +1,135 @@ +use std::sync::Arc; + +use image; +use log::info; +use rand; + +use crate::{ + camera::Camera, + cuboid::Cuboid, + glowybox::Glowybox, + hitable::Hit, + hitable_list::HitableList, + kdtree::KDTree, + material::{DiffuseLight, Lambertian}, + noise::{perlin::Perlin, NoiseType}, + rect::{XYRect, XZRect, YZRect}, + renderer::{Opt, Scene}, + sphere::Sphere, + texture::{ConstantTexture, ImageTexture, NoiseTexture}, + vec3::Vec3, +}; + +pub fn new(opt: &Opt) -> Scene { + let lookfrom = Vec3::new(20., 20., 20.); + let lookat = Vec3::new(0., 1., 0.); + let dist_to_focus = 10.0; + let aperture = 0.0; + let time_min = 0.; + let time_max = 1.; + let camera = Camera::new( + lookfrom, + lookat, + Vec3::new(0., 1., 0.), + 20., + opt.width as f32 / opt.height as f32, + aperture, + dist_to_focus, + time_min, + time_max, + ); + let rng = &mut rand::thread_rng(); + let ground_color = if opt.use_accel { + ConstantTexture::new(Vec3::new(1.0, 0.4, 0.4)) + } else { + ConstantTexture::new(Vec3::new(0.4, 1.0, 0.4)) + }; + + let world_image_bytes = include_bytes!("../../images/world.jpg"); + let it = ImageTexture::new(image::load_from_memory(world_image_bytes).unwrap().to_rgb()); + let noise_source = Perlin::new(rng); + let noise_type = NoiseType::Scale(10.); + + let lights: Vec> = vec![ + Box::new(XZRect::new( + -100., + 100., + -100., + 1000., + 60., + DiffuseLight::new(ConstantTexture::new(Vec3::new(1., 1., 1.))), + )), + Box::new(YZRect::new( + 1., + 3., + -1., + 1., + 4., + DiffuseLight::new(ConstantTexture::new(Vec3::new(4., 0., 4.))), + )), + Box::new(YZRect::new( + 1., + 3., + -1., + 1., + -4., + DiffuseLight::new(ConstantTexture::new(Vec3::new(0., 4., 0.))), + )), + Box::new(XZRect::new( + -1., + 1., + -1., + 1., + 6., + DiffuseLight::new(ConstantTexture::new(Vec3::new(4., 4., 0.))), + )), + Box::new(XYRect::new( + -1., + 1., + 1., + 3., + -4., + DiffuseLight::new(ConstantTexture::new(Vec3::new(0., 0., 4.))), + )), + Box::new(XYRect::new( + -1., + 1., + 1., + 3., + 4., + DiffuseLight::new(ConstantTexture::new(Vec3::new(0., 4., 4.))), + )), + ]; + let mut objects: Vec> = vec![ + // Earth sized sphere + Box::new(Sphere::new( + Vec3::new(0., -1010., 0.), + 1000., + Lambertian::new(ground_color), + // Lambertian::new(NoiseTexture::new(noise_source, noise_type)), + )), + Box::new(Glowybox::new( + [-4., -4., -4.].into(), + [4., 4., 4.].into(), + 0.01, + Arc::new(Lambertian::new(ConstantTexture::new([0., 0., 0.]))), + Arc::new(DiffuseLight::new(ConstantTexture::new([100., 0., 0.]))), + )), + ]; + objects.extend(lights); + info!("objects {:?}", objects); + let world: Box = if opt.use_accel { + Box::new(KDTree::new(objects, time_min, time_max)) + } else { + Box::new(HitableList::new(objects)) + }; + Scene { + camera, + world, + subsamples: opt.subsamples, + num_threads: opt.num_threads, + width: opt.width, + height: opt.height, + ..Default::default() + } +} diff --git a/rtiow/renderer/src/sphere.rs b/rtiow/renderer/src/sphere.rs index 067200d..afea9a9 100644 --- a/rtiow/renderer/src/sphere.rs +++ b/rtiow/renderer/src/sphere.rs @@ -8,6 +8,7 @@ use crate::{ vec3::{dot, Vec3}, }; +#[derive(Debug)] pub struct Sphere where M: Material, diff --git a/rtiow/renderer/src/texture/checker.rs b/rtiow/renderer/src/texture/checker.rs index d041320..541672d 100644 --- a/rtiow/renderer/src/texture/checker.rs +++ b/rtiow/renderer/src/texture/checker.rs @@ -1,5 +1,6 @@ use crate::{texture::Texture, vec3::Vec3}; +#[derive(Debug)] pub struct CheckerTexture where T: Texture, diff --git a/rtiow/renderer/src/texture/mandelbrot.rs b/rtiow/renderer/src/texture/mandelbrot.rs index eb1b2e1..12f7886 100644 --- a/rtiow/renderer/src/texture/mandelbrot.rs +++ b/rtiow/renderer/src/texture/mandelbrot.rs @@ -3,6 +3,7 @@ use rand::{self, Rng}; use crate::{texture::Texture, vec3::Vec3}; +#[derive(Debug)] pub struct Mandelbrot { palette: Vec, } diff --git a/rtiow/renderer/src/texture/mod.rs b/rtiow/renderer/src/texture/mod.rs index e48ea5e..c188520 100644 --- a/rtiow/renderer/src/texture/mod.rs +++ b/rtiow/renderer/src/texture/mod.rs @@ -9,11 +9,11 @@ pub use crate::texture::{ mandelbrot::Mandelbrot, noise::NoiseTexture, }; -use std::sync::Arc; +use std::{fmt::Debug, sync::Arc}; use crate::vec3::Vec3; -pub trait Texture: Send + Sync { +pub trait Texture: Send + Sync + Debug { fn value(&self, u: f32, v: f32, p: Vec3) -> Vec3; } diff --git a/rtiow/renderer/src/texture/noise.rs b/rtiow/renderer/src/texture/noise.rs index 16b850f..7730e04 100644 --- a/rtiow/renderer/src/texture/noise.rs +++ b/rtiow/renderer/src/texture/noise.rs @@ -4,6 +4,7 @@ use crate::{ vec3::Vec3, }; +#[derive(Debug)] pub struct NoiseTexture where N: NoiseSource, diff --git a/rtiow/renderer/src/translate.rs b/rtiow/renderer/src/translate.rs index ea080dc..1bb4fd5 100644 --- a/rtiow/renderer/src/translate.rs +++ b/rtiow/renderer/src/translate.rs @@ -5,6 +5,7 @@ use crate::{ vec3::Vec3, }; +#[derive(Debug)] pub struct Translate where H: Hit,