From c5bf2b9de1504e60c007d3a166beb45c1eab64e9 Mon Sep 17 00:00:00 2001 From: iurii Date: Sat, 7 Sep 2024 15:00:44 +0300 Subject: fixed shaders --- res/shaders/colors.fs | 13 +++++++------ res/shaders/colors.vs | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'res/shaders') diff --git a/res/shaders/colors.fs b/res/shaders/colors.fs index 79e243f..a486a92 100644 --- a/res/shaders/colors.fs +++ b/res/shaders/colors.fs @@ -1,6 +1,9 @@ #version 330 core + +out vec4 FragColor; + struct Material { - Sampler2D diffuse; + sampler2D diffuse; vec3 specular; float shininess; }; @@ -12,11 +15,9 @@ struct Light { vec3 specular; }; -out vec4 FragColor; - in vec3 Normal; in vec3 FragPos; -in vec3 TexCoords; +in vec2 TexCoords; uniform vec3 light_position; uniform vec3 view_position; @@ -26,13 +27,13 @@ uniform Light light; void main() { // ambient - vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); + vec3 ambient = light.ambient * texture(material.diffuse, TexCoords).rgb; // 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 * vec3(texture(material.diffuse, TexCoords)); + vec3 diffuse = light.diffuse * diff * texture(material.diffuse, TexCoords).rgb; // specular vec3 view_dir = normalize(view_position - FragPos); diff --git a/res/shaders/colors.vs b/res/shaders/colors.vs index 9128abc..44f7c34 100644 --- a/res/shaders/colors.vs +++ b/res/shaders/colors.vs @@ -16,5 +16,6 @@ void main() { FragPos = vec3(model * vec4(a_pos, 1.0)); Normal = mat3(transpose(inverse(model))) * a_normal; + TexCoords = a_tex_coords; gl_Position = projection * view * vec4(FragPos, 1.0); } -- cgit 1.4.1-2-gfad0