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) {