GRK-Projekt/grafika_projekt/shaders/shader_tex.frag

18 lines
545 B
GLSL
Raw Normal View History

2021-12-27 15:25:54 +01:00
#version 410 core
uniform sampler2D textureSampler;
uniform vec3 lightDir;
in vec3 interpNormal;
in vec2 interpTexCoord;
void main()
{
vec2 modifiedTexCoord = vec2(interpTexCoord.x, 1.0 - interpTexCoord.y); // Poprawka dla tekstur Ziemi, ktore bez tego wyswietlaja sie 'do gory nogami'
vec3 color = texture2D(textureSampler, modifiedTexCoord).rgb;
vec3 normal = normalize(interpNormal);
2021-12-30 14:42:41 +01:00
float ambient = 0.2;
2021-12-30 14:50:39 +01:00
float diffuse = max(dot(normal, -lightDir), 0.1);
2021-12-30 14:58:41 +01:00
gl_FragColor = vec4(color * (ambient + (1-ambient) * diffuse * 0.6 ), 1.0);
2021-12-27 15:25:54 +01:00
}