From 6add0f74e9c8a0a1b1252a8bab01a2d677555e63 Mon Sep 17 00:00:00 2001 From: iurii Date: Thu, 5 Sep 2024 23:46:40 +0300 Subject: update shader to struct --- res/shaders/colors.fs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'res/shaders') diff --git a/res/shaders/colors.fs b/res/shaders/colors.fs index 8d51645..df02754 100644 --- a/res/shaders/colors.fs +++ b/res/shaders/colors.fs @@ -2,7 +2,7 @@ struct Material { vec3 ambient; vec3 diffuse; - vec3 specula; + vec3 specular; float shininess; }; @@ -20,19 +20,20 @@ uniform Material material; void main() { // ambient vec3 ambient = light_color * material.ambient; - + // diffuse vec3 norm = normalize(Normal); vec3 light_dir = normalize(light_position - FragPos); float diff = max(dot(norm, light_dir), 0.0); vec3 diffuse = light_color * (diff * material.diffuse); - + // 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_color * (spec * material.specular); - + vec3 result = ambient + diffuse + specular; FragColor = vec4(result, 1.0); } + -- cgit 1.4.1-2-gfad0