From 6239be219a2cdeaa2e056681669f5469cfebf0f7 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 18 Aug 2024 17:09:13 +0100 Subject: [PATCH] Ensure light is normalised --- src/shader/shaders.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shader/shaders.c b/src/shader/shaders.c index 14a1102..bcda30d 100644 --- a/src/shader/shaders.c +++ b/src/shader/shaders.c @@ -179,7 +179,10 @@ internal M4x4f get_projection_matrix(ProjectionType projection_type) { } internal f32 get_intensity(const V3f *normal) { - f32 intensity = dot_v3((*normal), g_light_dir); + V3f light = g_light_dir; + normalise_v3(light); + + f32 intensity = dot_v3((*normal), light); if (intensity < 0.0f) { intensity = 0.001f; }