diff options
Diffstat (limited to 'engine/light.glsl')
-rw-r--r-- | engine/light.glsl | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/engine/light.glsl b/engine/light.glsl index 3f1c601..0ceac16 100644 --- a/engine/light.glsl +++ b/engine/light.glsl @@ -1,18 +1,33 @@ #version 330 core -uniform vec3 light_color; -uniform vec3 light_pos; - -uniform float ambient_light_strength; -uniform float specular_light_strength; - -uniform uint specular_shininess; +struct Material { + vec3 ambient; + vec3 diffuse; + vec3 specular; + float shininess; +}; + +struct Light { + vec3 position; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +uniform Material material; +uniform Light light; + +vec3 calc_ambient_light() +{ + return light.ambient * material.ambient; +} vec3 calc_diffuse_light(in vec3 light_dir, in vec3 norm) { float diff = max(dot(norm, light_dir), 0.0); - return diff * light_color; + return light.diffuse * (diff * material.diffuse); } vec3 calc_specular_light( @@ -27,8 +42,8 @@ vec3 calc_specular_light( vec3 reflect_direction = reflect(-light_dir, norm); float spec = - pow(max(dot(view_direction, reflect_direction), 0.0), specular_shininess); + pow(max(dot(view_direction, reflect_direction), 0.0), material.shininess); - return specular_light_strength * spec * light_color; + return light.specular * (spec * material.specular); } |