From 984db29300f440815c49a0e91a56b9f2512985fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Fri, 15 Apr 2022 09:14:55 +0200 Subject: [PATCH] fix: broken light --- Lighting.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lighting.java b/Lighting.java index 3bc3b9c..5c3c644 100644 --- a/Lighting.java +++ b/Lighting.java @@ -82,10 +82,10 @@ public class Lighting { double Id = light.params[3]; /* diffuse contribution */ - double I_diff = Id * kd * Math.cos(normal.dot(l)); + double I_diff = Id * kd * normal.dot(l) / normal.norm() / l.norm(); /* specular contribution */ - double I_spec = Id * ks * Math.pow(Math.cos(h.dot(normal)), s); + double I_spec = Id * ks * Math.pow(h.dot(normal) / h.norm() / normal.norm(), s); I += I_diff + I_spec; } catch (InstantiationException ex) {