model-converter/assets/shaders/shader.frag

30 lines
607 B
GLSL
Raw Normal View History

2018-02-26 11:45:53 +01:00
#version 140
2018-02-23 17:35:39 +01:00
2018-02-27 11:42:35 +01:00
uniform sampler2D tex;
in vec3 v_normal;
2018-02-26 14:59:32 +01:00
in vec2 v_tex_coords;
2018-02-27 11:42:35 +01:00
2018-02-26 11:45:53 +01:00
out vec4 color;
2018-02-23 17:35:39 +01:00
2018-02-27 11:42:35 +01:00
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);
2018-02-26 14:59:32 +01:00
2018-02-23 17:35:39 +01:00
void main() {
2018-02-27 11:42:35 +01:00
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);
2018-04-12 17:23:40 +02:00
if (color.a < 0.5) {
discard;
2018-04-17 10:45:44 +02:00
} else {
color.a = 1.0;
2018-04-12 17:23:40 +02:00
}
2018-02-23 17:35:39 +01:00
}