20 lines
517 B
GLSL
20 lines
517 B
GLSL
#version 400 core
|
|
|
|
in vec2 pass_textureCoords;
|
|
in vec3 surfaceNormal;
|
|
in vec3 toLightVector;
|
|
|
|
out vec4 outColor;
|
|
|
|
uniform sampler2D textureSampler;
|
|
uniform vec3 lightColor;
|
|
|
|
void main(void) {
|
|
vec3 unitNormal = normalize(surfaceNormal);
|
|
vec3 unitToLightDir = normalize(toLightVector);
|
|
|
|
float cosTheta = dot(unitNormal, unitToLightDir);
|
|
float brightness = max(cosTheta, 0.0);
|
|
vec3 diffuse = brightness * lightColor;
|
|
outColor = vec4(diffuse, 1.0f) * texture(textureSampler, pass_textureCoords);
|
|
} |