aboutsummaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'shaders')
-rw-r--r--shaders/color.fsh12
-rw-r--r--shaders/color.vsh3
2 files changed, 9 insertions, 6 deletions
diff --git a/shaders/color.fsh b/shaders/color.fsh
index 4989d73..c2a8dc7 100644
--- a/shaders/color.fsh
+++ b/shaders/color.fsh
@@ -1,9 +1,8 @@
# version 330 core
struct Material {
- vec3 ambient;
- vec3 diffuse;
- vec3 specular;
+ sampler2D diffuse;
+ sampler2D specular;
float shininess;
};
@@ -16,6 +15,7 @@ struct Light {
in vec3 Normal;
in vec3 FragPos;
+in vec2 TexCoords;
out vec4 FragColor;
@@ -26,19 +26,19 @@ uniform Light light;
void main()
{
// ambient
- vec3 ambient = material.ambient * light.ambient;
+ vec3 ambient = light.ambient * texture(material.diffuse, TexCoords).rgb;
// diffuse
vec3 norm = normalize(Normal);
vec3 lightDir = normalize(light.position - FragPos);
float diff = max(dot(norm, lightDir), 0.0);
- vec3 diffuse = light.diffuse * diff * material.diffuse;
+ vec3 diffuse = light.diffuse * diff * texture(material.diffuse, TexCoords).rgb;
// specular
vec3 viewDir = normalize(viewPos - FragPos);
vec3 reflectDir = reflect(-lightDir, norm);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
- vec3 specular = light.specular * spec * material.specular;
+ vec3 specular = light.specular * spec * texture(material.specular, TexCoords).rgb;
FragColor = vec4((specular + ambient + diffuse), 1.0f);
}
diff --git a/shaders/color.vsh b/shaders/color.vsh
index ff878be..d3a2082 100644
--- a/shaders/color.vsh
+++ b/shaders/color.vsh
@@ -2,16 +2,19 @@
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
+layout (location = 2) in vec2 aTexCoords;
uniform mat4 model, view, proj;
uniform mat4 rotNormals;
out vec3 FragPos;
out vec3 Normal;
+out vec2 TexCoords;
void main()
{
gl_Position = proj * view * model * vec4(aPos, 1.0f);
FragPos = vec3(model * vec4(aPos, 1.0));
Normal = vec3(rotNormals * vec4(aNormal, 1.0));
+ TexCoords = aTexCoords;
}
Feel free to download, copy and edit any repo