summaryrefslogtreecommitdiff
path: root/engine/light.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'engine/light.glsl')
-rw-r--r--engine/light.glsl19
1 files changed, 10 insertions, 9 deletions
diff --git a/engine/light.glsl b/engine/light.glsl
index 90539a1..3ba5ba0 100644
--- a/engine/light.glsl
+++ b/engine/light.glsl
@@ -4,9 +4,9 @@
#define LIGHT_GLSL
struct Material {
- vec3 ambient;
- vec3 diffuse;
- vec3 specular;
+ sampler2D ambient;
+ sampler2D diffuse;
+ sampler2D specular;
float shininess;
};
@@ -21,23 +21,24 @@ struct Light {
uniform Material material;
uniform Light light;
-vec3 calc_ambient_light()
+vec3 calc_ambient_light(in vec2 texture_coords)
{
- return light.ambient * material.ambient;
+ return light.ambient * vec3(texture(material.ambient, texture_coords));
}
-vec3 calc_diffuse_light(in vec3 light_dir, in vec3 norm)
+vec3 calc_diffuse_light(in vec3 light_dir, in vec3 norm, in vec2 texture_coords)
{
float diff = max(dot(norm, light_dir), 0.0);
- return light.diffuse * (diff * material.diffuse);
+ return light.diffuse * (diff * vec3(texture(material.diffuse, texture_coords)));
}
vec3 calc_specular_light(
in vec3 light_dir,
in vec3 norm,
in vec3 view_pos,
- in vec3 frag_pos
+ in vec3 frag_pos,
+ in vec2 texture_coords
)
{
vec3 view_direction = normalize(view_pos - frag_pos);
@@ -47,7 +48,7 @@ vec3 calc_specular_light(
float spec =
pow(max(dot(view_direction, reflect_direction), 0.0), material.shininess);
- return light.specular * (spec * material.specular);
+ return light.specular * (spec * vec3(texture(material.specular, texture_coords)));
}
#endif