projekt_grafika/cw 2/shaders/shader_tex.frag
2022-02-13 01:51:44 +01:00

30 lines
616 B
GLSL

#version 410 core
uniform sampler2D textureSampler;
uniform vec3 lightDir;
in vec3 interpNormal;
in vec2 interpTexCoord;
in vec3 fragPos;
in float visibility;
//vec4(0.0175,0.4716,0.5109,1.0)
void main()
{
vec2 modifiedTexCoord = vec2(interpTexCoord.x, 1.0 - interpTexCoord.y);
vec3 color = texture2D(textureSampler, modifiedTexCoord).rgb;
vec3 normal = normalize(interpNormal);
float ambient = 0.2;
float diffuse = max(dot(normal, -lightDir), 0.0);
gl_FragColor = vec4(color * (ambient + (1-ambient) * diffuse), 1.0);
gl_FragColor = mix(vec4(0.0175,0.4716,0.5109,1), gl_FragColor, visibility);
}