fix: broken light

This commit is contained in:
Laureηt 2022-04-15 09:14:55 +02:00
parent 163c93666b
commit 984db29300
No known key found for this signature in database
GPG key ID: D88C6B294FD40994

View file

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