32 lines
652 B
GLSL
32 lines
652 B
GLSL
#version 140
|
|
|
|
uniform sampler2D tex;
|
|
uniform vec3 diffuse;
|
|
|
|
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() {
|
|
|
|
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 * vec4(diffuse, 1.0) * texture(tex, v_tex_coords);
|
|
|
|
if (color.a < 0.05) {
|
|
discard;
|
|
} else {
|
|
color.a = 1.0;
|
|
}
|
|
|
|
}
|
|
|