Cleaning, fixed textures bug

This commit is contained in:
Thomas Forgione
2018-02-27 11:42:35 +01:00
parent b25dddaa9c
commit b9bdac0dae
5 changed files with 155 additions and 93 deletions
+15 -4
View File
@@ -1,11 +1,22 @@
#version 140
in vec2 v_tex_coords;
out vec4 color;
uniform sampler2D tex;
in vec3 v_normal;
in vec2 v_tex_coords;
out vec4 color;
vec3 ambientLight = vec3(0.3,0.3,0.3);
vec3 directionnalLight = normalize(vec3(10,5,7));
vec3 directionnalLightFactor = vec3(0.6,0.6,0.6);
void main() {
color = texture(tex, v_tex_coords);
vec3 lambertComponent = dot(directionnalLight, v_normal) * directionnalLightFactor;
lambertComponent = max(vec3(0.0, 0.0, 0.0), lambertComponent);
vec4 factor = vec4(ambientLight + lambertComponent, 1.0);
color = factor * texture(tex, v_tex_coords);
}
+7 -3
View File
@@ -1,14 +1,18 @@
#version 140
in vec3 vertex;
in vec2 tex_coords;
uniform mat4 perspective;
uniform mat4 view;
in vec3 vertex;
in vec2 tex_coords;
in vec3 normal;
out vec2 v_tex_coords;
out vec3 v_normal;
void main() {
v_normal = transpose(inverse(mat3(view))) * normal;
v_tex_coords = tex_coords;
gl_Position = perspective * view * vec4(vertex, 1.0);
}