diff options
Diffstat (limited to '')
-rw-r--r-- | res/shaders/colors.fs | 8 | ||||
-rw-r--r-- | res/shaders/colors.vs | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/res/shaders/colors.fs b/res/shaders/colors.fs index 053e1c4..79e243f 100644 --- a/res/shaders/colors.fs +++ b/res/shaders/colors.fs @@ -1,7 +1,6 @@ #version 330 core struct Material { - vec3 ambient; - vec3 diffuse; + Sampler2D diffuse; vec3 specular; float shininess; }; @@ -17,6 +16,7 @@ out vec4 FragColor; in vec3 Normal; in vec3 FragPos; +in vec3 TexCoords; uniform vec3 light_position; uniform vec3 view_position; @@ -26,13 +26,13 @@ uniform Light light; void main() { // ambient - vec3 ambient = light.ambient * material.ambient; + vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); // diffuse vec3 norm = normalize(Normal); vec3 light_dir = normalize(light_position - FragPos); float diff = max(dot(norm, light_dir), 0.0); - vec3 diffuse = light.diffuse * (diff * material.diffuse); + vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords)); // specular vec3 view_dir = normalize(view_position - FragPos); diff --git a/res/shaders/colors.vs b/res/shaders/colors.vs index 15cc265..9128abc 100644 --- a/res/shaders/colors.vs +++ b/res/shaders/colors.vs @@ -2,6 +2,7 @@ layout (location = 0) in vec3 a_pos; layout (location = 1) in vec3 a_normal; +layout (location = 2) in vec2 a_tex_coords; uniform mat4 model; uniform mat4 view; @@ -9,6 +10,7 @@ uniform mat4 projection; out vec3 Normal; out vec3 FragPos; +out vec2 TexCoords; void main() { FragPos = vec3(model * vec4(a_pos, 1.0)); |