diff options
author | eug-vs <eugene@eug-vs.xyz> | 2021-10-28 10:54:35 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2021-10-28 10:54:35 +0300 |
commit | af515879c9b48a34ca4e953c9eb4bdff9e95fbd2 (patch) | |
tree | 0f44b4c7a8dfd8edfc45da0d7df6de186dcc7c1a | |
parent | 8ed56f554f94dca0ca5ef707eaf8b1cdde3c91e7 (diff) | |
download | pistol-af515879c9b48a34ca4e953c9eb4bdff9e95fbd2.tar.gz |
feat: increase ambient lighting level
-rw-r--r-- | src/camera.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/camera.rs b/src/camera.rs index 054e3b5..2e11d62 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -167,11 +167,11 @@ impl Camera { } pub fn light_point(&self, point: Vector) -> f32 { - let base_light = 0.01; - return base_light + (1.0 - base_light) * (self.apply_shadow(point) * 0.7 + self.apply_ambient(point) * 0.3) + let ambient = 0.1; + return ambient + (1.0 - ambient) * (self.diffuse_lighting(point) * 0.7 + self.specular_lighting(point) * 0.3) } - pub fn apply_shadow(&self, point: Vector) -> f32 { + pub fn diffuse_lighting(&self, point: Vector) -> f32 { let mut res: f32 = 1.0; let mut ph = 1e20; let mut t = 0.1; @@ -192,7 +192,7 @@ impl Camera { return res } - pub fn apply_ambient(&self, point: Vector) -> f32 { + pub fn specular_lighting(&self, point: Vector) -> f32 { let normal = self.normal(point); let dot = -(normal.dot(self.light)); return dot.min(1.0).max(0.0) |