Add missing file that should have been in earlier commit
This commit is contained in:
parent
d2fb84191e
commit
98373a1935
|
|
@ -0,0 +1,26 @@
|
||||||
|
use nalgebra::{RealField, Vector3};
|
||||||
|
|
||||||
|
use super::raycasting::IntersectionInfo;
|
||||||
|
|
||||||
|
pub trait Integrator<T: RealField> {
|
||||||
|
fn integrate(&self, info: &IntersectionInfo<T>) -> T;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DirectionalLight<T: RealField> {
|
||||||
|
pub direction: Vector3<T>,
|
||||||
|
pub intensity: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct PhongIntegrator<T: RealField> {
|
||||||
|
pub ambient_light: T,
|
||||||
|
pub lights: Vec<DirectionalLight<T>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: RealField> Integrator<T> for PhongIntegrator<T> {
|
||||||
|
fn integrate(&self, info: &IntersectionInfo<T>) -> T {
|
||||||
|
self.lights
|
||||||
|
.iter()
|
||||||
|
.map(|light| light.intensity * light.direction.dot(&info.normal))
|
||||||
|
.fold(self.ambient_light, |a, b| a + b)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue