22 lines
638 B
GLSL
22 lines
638 B
GLSL
#version 330
|
|
|
|
in vec2 fragTexCoord; // texture coordinate
|
|
in vec3 fragNormal; // normal direction
|
|
|
|
uniform sampler2D texture0;
|
|
uniform vec4 colDiffuse;
|
|
|
|
out vec4 finalColor;
|
|
|
|
uniform vec3 lightDirection; // direction of light
|
|
uniform vec4 ambientLight;
|
|
|
|
void main() {
|
|
vec4 texelColor = texture(texture0, fragTexCoord);
|
|
float light_dot = clamp(dot(normalize(fragNormal), normalize(lightDirection)), 0.0, 1.0);
|
|
vec4 light_col = vec4(vec3(light_dot), 1.0);
|
|
finalColor = texelColor * colDiffuse * light_col;
|
|
finalColor += texelColor * colDiffuse * ambientLight;
|
|
finalColor = pow(finalColor, vec4(vec3(0.8), 1.0));
|
|
}
|