diff options
Diffstat (limited to '')
-rw-r--r-- | res/shaders/colors.fs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/res/shaders/colors.fs b/res/shaders/colors.fs index df02754..053e1c4 100644 --- a/res/shaders/colors.fs +++ b/res/shaders/colors.fs @@ -6,32 +6,39 @@ struct Material { float shininess; }; +struct Light { + vec3 position; + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + out vec4 FragColor; in vec3 Normal; in vec3 FragPos; -uniform vec3 light_color; uniform vec3 light_position; uniform vec3 view_position; uniform Material material; +uniform Light light; void main() { // ambient - vec3 ambient = light_color * material.ambient; + vec3 ambient = light.ambient * 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); + vec3 diffuse = light.diffuse * (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 specular = light.specular * (spec * material.specular); vec3 result = ambient + diffuse + specular; FragColor = vec4(result, 1.0); |