summary refs log tree commit diff
path: root/res/shaders
diff options
context:
space:
mode:
authoriurii <[email protected]>2024-09-07 12:51:36 +0200
committeriurii <[email protected]>2024-09-07 12:51:36 +0200
commit7019eba5e9fe2500e30b542e8a982a4edae40940 (patch)
tree23b8a9de581f30022e7c97b2fa0913bfc9ac30db /res/shaders
parentc78784795449732a4d7edb72af28506ab16d0117 (diff)
downloadfunhalla-7019eba5e9fe2500e30b542e8a982a4edae40940.tar.gz
refactored and wip texture loader
Diffstat (limited to '')
-rw-r--r--res/shaders/colors.fs8
-rw-r--r--res/shaders/colors.vs2
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));