summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--res/shaders/colors.fs10
-rw-r--r--src/main.odin2
2 files changed, 5 insertions, 7 deletions
diff --git a/res/shaders/colors.fs b/res/shaders/colors.fs
index 142d843..030fdac 100644
--- a/res/shaders/colors.fs
+++ b/res/shaders/colors.fs
@@ -10,6 +10,7 @@ struct Material {
 };
 
 struct Light {
+  vec3 position;
   vec3 direction;
   vec3 ambient;
   vec3 diffuse;
@@ -31,27 +32,24 @@ uniform Light light;
 void main() {
   // ambient
   vec3 ambient = light.ambient * texture(material.diffuse, TexCoords).rgb;
-
   // diffuse
   vec3 norm = normalize(Normal);
-  vec3 light_dir = normalize(-light.direction);
+  vec3 light_dir = normalize(light.position - FragPos);
   float diff = max(dot(norm, light_dir), 0.0);
   vec3 diffuse = light.diffuse * diff * texture(material.diffuse, TexCoords).rgb;
-
   // specular
   vec3 view_dir = normalize(view_position - FragPos);
   vec3 reflect_dir = reflect(-light_dir, norm);
   float spec = pow(max(dot(view_dir, reflect_dir), 0.0), material.shininess);
   vec3 specular = light.specular * spec * texture(material.specular, TexCoords).rgb;
 
-  float distance = length(light.positon - FragPos);
+  float distance = length(light.position - FragPos);
   float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
 
-  abient *= attenuation;
+  ambient *= attenuation;
   diffuse *= attenuation;
   specular *= attenuation;
 
   vec3 result = ambient + diffuse + specular;
   FragColor = vec4(result, 1.0);
 }
-
diff --git a/src/main.odin b/src/main.odin
index eee26e2..d3d5cac 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -203,7 +203,7 @@ main :: proc() {
 		shader_set_vec3(lighting_shader, cstring("light.diffuse"), &light_diffuse)
 		shader_set_vec3(lighting_shader, cstring("light.specular"), &light_specular)
 
-		shader_set_vec3(lighting_shader, cstring("light_position"), &light_pos)
+		shader_set_vec3(lighting_shader, cstring("light.position"), &light_pos)
 		shader_set_vec3(lighting_shader, cstring("view_position"), &camera.position)
 
     shader_set_f32(lighting_shader, "light.constant", 1.0)