Compare commits

..

1 Commits

Author SHA1 Message Date
Matthew Gordon 59be110a55 Glass bunny scene 2025-03-29 16:04:54 -03:00
3 changed files with 39 additions and 16 deletions

View File

@ -5,7 +5,7 @@ authors = ["Matthew Gordon <matthew.scott.gordon@gmail.com>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
itertools = "0.14" itertools = "0.9"
obj = "0.9" obj = "0.9"
quickcheck = "0.9" quickcheck = "0.9"
quickcheck_macros = "0.9" quickcheck_macros = "0.9"

View File

@ -55,11 +55,11 @@ impl Integrator for SimpleRandomIntegrator {
} }
pub fn test_lighting_environment(w_o: &Vec3<f64>, wavelength: f64) -> f64 { pub fn test_lighting_environment(w_o: &Vec3<f64>, wavelength: f64) -> f64 {
//let sun_direction = Vec3::new(1.0, 1.0, -1.0).normalize(); let sun_direction = Vec3::new(1.0, 1.0, -1.0).normalize();
//if w_o.dot(&sun_direction) >= 0.99 { if w_o.dot(&sun_direction) >= 0.99 {
// 300.0 300.0
//} else { } else {
let sky_colour = ColourRgbF::new(w_o.y(), w_o.y(), 1.0); let sky_colour = ColourRgbF::new(w_o.y(), w_o.y(), 1.0);
Spectrum::reflection_from_linear_rgb(&sky_colour).intensity_at_wavelength(wavelength) Spectrum::reflection_from_linear_rgb(&sky_colour).intensity_at_wavelength(wavelength)
//} }
} }

View File

@ -16,7 +16,7 @@ use std::time::Duration;
use vanrijn::accumulation_buffer::AccumulationBuffer; use vanrijn::accumulation_buffer::AccumulationBuffer;
use vanrijn::colour::{ColourRgbF, NamedColour, Spectrum}; use vanrijn::colour::{ColourRgbF, NamedColour, Spectrum};
use vanrijn::image::{ClampingToneMapper, ImageRgbU8}; use vanrijn::image::{ClampingToneMapper, ImageRgbU8};
use vanrijn::materials::LambertianMaterial; use vanrijn::materials::{LambertianMaterial, SmoothTransparentDialectric};
use vanrijn::math::Vec3; use vanrijn::math::Vec3;
use vanrijn::mesh::load_obj; use vanrijn::mesh::load_obj;
use vanrijn::partial_render_scene; use vanrijn::partial_render_scene;
@ -122,13 +122,16 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Loading object..."); println!("Loading object...");
let mut model_object = load_obj( let mut model_object = load_obj(
&model_file_path, &model_file_path,
Arc::new(LambertianMaterial { //Arc::new(LambertianMaterial {
colour: Spectrum::reflection_from_linear_rgb(&ColourRgbF::from_named( // colour: Spectrum::reflection_from_linear_rgb(&ColourRgbF::from_named(
NamedColour::Yellow, // NamedColour::Yellow,
// )),
// diffuse_strength: 0.05,
// //reflection_strength: 0.9,
//}),
Arc::new(SmoothTransparentDialectric::new(
Spectrum::diamond_index_of_refraction(),
)), )),
diffuse_strength: 0.05,
//reflection_strength: 0.9,
}),
)?; )?;
println!("Building BVH..."); println!("Building BVH...");
let model_bvh: Box<dyn Primitive> = let model_bvh: Box<dyn Primitive> =
@ -149,6 +152,26 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
diffuse_strength: 0.1, diffuse_strength: 0.1,
}), }),
)) as Box<dyn Primitive>, )) as Box<dyn Primitive>,
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( Box::new(Sphere::new(
Vec3::new(-6.25, -0.5, 1.0), Vec3::new(-6.25, -0.5, 1.0),
1.0, 1.0,