Add diffuse strength term to LambertianMaterial
This commit is contained in:
parent
430053c134
commit
e7bcc9cc62
|
|
@ -87,8 +87,8 @@ pub fn partial_render_scene<T: RealField>(
|
||||||
scene.camera_location,
|
scene.camera_location,
|
||||||
);
|
);
|
||||||
let ambient_intensity: T = convert(0.0);
|
let ambient_intensity: T = convert(0.0);
|
||||||
let directional_intensity1: T = convert(0.7);
|
let directional_intensity1: T = convert(7.0);
|
||||||
let directional_intensity2: T = convert(0.3);
|
let directional_intensity2: T = convert(3.0);
|
||||||
let integrator = WhittedIntegrator::<T> {
|
let integrator = WhittedIntegrator::<T> {
|
||||||
ambient_light: ColourRgbF::from_named(NamedColour::White) * ambient_intensity,
|
ambient_light: ColourRgbF::from_named(NamedColour::White) * ambient_intensity,
|
||||||
lights: vec![
|
lights: vec![
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
-2.0,
|
-2.0,
|
||||||
Rc::new(LambertianMaterial {
|
Rc::new(LambertianMaterial {
|
||||||
colour: ColourRgbF::new(0.55, 0.27, 0.04),
|
colour: ColourRgbF::new(0.55, 0.27, 0.04),
|
||||||
|
diffuse_strength: 0.1,
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
Box::new(Sphere::new(
|
Box::new(Sphere::new(
|
||||||
|
|
@ -73,6 +74,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
1.0,
|
1.0,
|
||||||
Rc::new(LambertianMaterial {
|
Rc::new(LambertianMaterial {
|
||||||
colour: ColourRgbF::from_named(NamedColour::Green),
|
colour: ColourRgbF::from_named(NamedColour::Green),
|
||||||
|
diffuse_strength: 0.1,
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
Box::new(Sphere::new(
|
Box::new(Sphere::new(
|
||||||
|
|
@ -80,6 +82,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
1.0,
|
1.0,
|
||||||
Rc::new(LambertianMaterial {
|
Rc::new(LambertianMaterial {
|
||||||
colour: ColourRgbF::from_named(NamedColour::Blue),
|
colour: ColourRgbF::from_named(NamedColour::Blue),
|
||||||
|
diffuse_strength: 0.1,
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
Box::new(Sphere::new(
|
Box::new(Sphere::new(
|
||||||
|
|
@ -87,6 +90,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
1.0,
|
1.0,
|
||||||
Rc::new(LambertianMaterial {
|
Rc::new(LambertianMaterial {
|
||||||
colour: ColourRgbF::from_named(NamedColour::Red),
|
colour: ColourRgbF::from_named(NamedColour::Red),
|
||||||
|
diffuse_strength: 0.1,
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,14 @@ pub trait Material<T: RealField>: Debug {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct LambertianMaterial<T: RealField> {
|
pub struct LambertianMaterial<T: RealField> {
|
||||||
pub colour: ColourRgbF<T>,
|
pub colour: ColourRgbF<T>,
|
||||||
|
pub diffuse_strength: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: RealField> LambertianMaterial<T> {
|
impl<T: RealField> LambertianMaterial<T> {
|
||||||
pub fn new_dummy() -> LambertianMaterial<T> {
|
pub fn new_dummy() -> LambertianMaterial<T> {
|
||||||
LambertianMaterial {
|
LambertianMaterial {
|
||||||
colour: ColourRgbF::new(T::one(), T::one(), T::one()),
|
colour: ColourRgbF::new(T::one(), T::one(), T::one()),
|
||||||
|
diffuse_strength: T::one(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +31,7 @@ impl<T: RealField> Material<T> for LambertianMaterial<T> {
|
||||||
) -> Box<dyn Fn(Vector3<T>, Vector3<T>, ColourRgbF<T>) -> ColourRgbF<T> + 'a> {
|
) -> Box<dyn Fn(Vector3<T>, Vector3<T>, ColourRgbF<T>) -> ColourRgbF<T> + 'a> {
|
||||||
Box::new(
|
Box::new(
|
||||||
move |_w_o: Vector3<T>, _w_i: Vector3<T>, colour_in: ColourRgbF<T>| {
|
move |_w_o: Vector3<T>, _w_i: Vector3<T>, colour_in: ColourRgbF<T>| {
|
||||||
self.colour * colour_in
|
self.colour * colour_in * self.diffuse_strength
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue