prior normal check for lights
This commit is contained in:
parent
f3098d8061
commit
e3829a73e4
4 changed files with 80 additions and 8 deletions
src/scene
|
@ -14,6 +14,7 @@ pub enum LightType {
|
|||
pub trait Light {
|
||||
fn get_light_type(&self) -> LightType;
|
||||
fn weighted_distance(&self, pos: Vector3<f32>, size: Vector3<f32>) -> f32;
|
||||
fn get_direction(&self, pos: Vector3<f32>) -> Vector3<f32>;
|
||||
}
|
||||
|
||||
pub trait LightSource: Light + Memorizable {}
|
||||
|
@ -109,6 +110,10 @@ impl Light for PointLight {
|
|||
|
||||
light_intensity / distance.powf(2.0)
|
||||
}
|
||||
|
||||
fn get_direction(&self, pos: Vector3<f32>) -> Vector3<f32> {
|
||||
(pos - self.pos).normalize()
|
||||
}
|
||||
}
|
||||
|
||||
impl LightSource for PointLight {}
|
||||
|
@ -157,6 +162,10 @@ impl Light for DirectionalLight {
|
|||
|
||||
light_intensity
|
||||
}
|
||||
|
||||
fn get_direction(&self, pos: Vector3<f32>) -> Vector3<f32> {
|
||||
self.direction.clone().normalize()
|
||||
}
|
||||
}
|
||||
|
||||
impl LightSource for DirectionalLight {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue