diff --git a/src/integrators/simple_random_integrator.rs b/src/integrators/simple_random_integrator.rs index 5db972e..92308b3 100644 --- a/src/integrators/simple_random_integrator.rs +++ b/src/integrators/simple_random_integrator.rs @@ -55,11 +55,11 @@ impl Integrator for SimpleRandomIntegrator { } pub fn test_lighting_environment(w_o: &Vec3, wavelength: f64) -> f64 { - //let sun_direction = Vec3::new(1.0, 1.0, -1.0).normalize(); - //if w_o.dot(&sun_direction) >= 0.99 { - // 300.0 - //} else { - let sky_colour = ColourRgbF::new(w_o.y(), w_o.y(), 1.0); - Spectrum::reflection_from_linear_rgb(&sky_colour).intensity_at_wavelength(wavelength) - //} + let sun_direction = Vec3::new(1.0, 1.0, -1.0).normalize(); + if w_o.dot(&sun_direction) >= 0.99 { + 300.0 + } else { + let sky_colour = ColourRgbF::new(w_o.y(), w_o.y(), 1.0); + Spectrum::reflection_from_linear_rgb(&sky_colour).intensity_at_wavelength(wavelength) + } } diff --git a/src/main.rs b/src/main.rs index fc6ae5c..d4349e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use std::time::Duration; use vanrijn::accumulation_buffer::AccumulationBuffer; use vanrijn::colour::{ColourRgbF, NamedColour, Spectrum}; use vanrijn::image::{ClampingToneMapper, ImageRgbU8}; -use vanrijn::materials::LambertianMaterial; +use vanrijn::materials::{LambertianMaterial, SmoothTransparentDialectric}; use vanrijn::math::Vec3; use vanrijn::mesh::load_obj; use vanrijn::partial_render_scene; @@ -122,13 +122,16 @@ pub fn main() -> Result<(), Box> { println!("Loading object..."); let mut model_object = load_obj( &model_file_path, - Arc::new(LambertianMaterial { - colour: Spectrum::reflection_from_linear_rgb(&ColourRgbF::from_named( - NamedColour::Yellow, - )), - diffuse_strength: 0.05, - //reflection_strength: 0.9, - }), + //Arc::new(LambertianMaterial { + // colour: Spectrum::reflection_from_linear_rgb(&ColourRgbF::from_named( + // NamedColour::Yellow, + // )), + // diffuse_strength: 0.05, + // //reflection_strength: 0.9, + //}), + Arc::new(SmoothTransparentDialectric::new( + Spectrum::diamond_index_of_refraction(), + )), )?; println!("Building BVH..."); let model_bvh: Box = @@ -149,6 +152,26 @@ pub fn main() -> Result<(), Box> { diffuse_strength: 0.1, }), )) as Box, + Box::new(Plane::new( + Vec3::new(1.0, 0.0, 0.0), + -6.0, + Arc::new(LambertianMaterial { + colour: Spectrum::reflection_from_linear_rgb(&ColourRgbF::new( + 0.55, 0.27, 0.04, + )), + diffuse_strength: 0.1, + }), + )), + Box::new(Plane::new( + Vec3::new(0.0, 0.0, 1.0), + 12.0, + Arc::new(LambertianMaterial { + colour: Spectrum::reflection_from_linear_rgb(&ColourRgbF::new( + 0.55, 0.27, 0.04, + )), + diffuse_strength: 0.1, + }), + )), Box::new(Sphere::new( Vec3::new(-6.25, -0.5, 1.0), 1.0,