From af515879c9b48a34ca4e953c9eb4bdff9e95fbd2 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 28 Oct 2021 10:54:35 +0300 Subject: feat: increase ambient lighting level --- src/camera.rs | 8 ++++---- 1 file 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) -- cgit v1.2.3