From 65dd9b5095fefe3c72e8b98241f7b6c2c83641a0 Mon Sep 17 00:00:00 2001 From: Matthew Gordon Date: Sat, 12 Sep 2020 09:47:17 -0400 Subject: [PATCH] Add integrators::test_liggting_environment() Should have been included in an earlier commit. --- src/integrators.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/integrators.rs b/src/integrators.rs index c37da97..415f8ec 100644 --- a/src/integrators.rs +++ b/src/integrators.rs @@ -1,6 +1,6 @@ use crate::math::Vec3; -use super::colour::{Photon, Spectrum}; +use super::colour::{ColourRgbF, Photon, Spectrum}; use super::raycasting::{IntersectionInfo, Ray}; use super::sampler::Sampler; use super::util::algebra_utils::try_change_of_basis_matrix; @@ -136,3 +136,13 @@ 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) * 0.1; + Spectrum::reflection_from_linear_rgb(&sky_colour).intensity_at_wavelength(wavelength) + } +}