2021-01-29 01:07:43 +01:00
|
|
|
#version 430 core
|
|
|
|
|
|
|
|
layout (location = 0) out vec4 FragColor;
|
|
|
|
layout (location = 1) out vec4 BrightColor;
|
|
|
|
|
|
|
|
uniform vec3 objectColor;
|
|
|
|
uniform vec3 cameraPos;
|
2021-02-12 00:08:28 +01:00
|
|
|
uniform sampler2D diffuseTexture;
|
2021-01-29 01:07:43 +01:00
|
|
|
in vec3 interpNormal;
|
|
|
|
in vec3 fragPos;
|
|
|
|
in vec2 vTexCoord;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec3 normal = normalize(interpNormal);
|
|
|
|
vec3 V = normalize(cameraPos-fragPos);
|
|
|
|
float coef = pow(max(0,dot(normal,V)),2);
|
2021-02-12 00:08:28 +01:00
|
|
|
vec4 textureColor = texture2D(diffuseTexture, -vTexCoord);
|
2021-02-12 03:43:11 +01:00
|
|
|
vec3 texture = vec3(textureColor.x, textureColor.y, textureColor.z) * objectColor;
|
2021-01-29 01:07:43 +01:00
|
|
|
FragColor = vec4(texture + texture * coef, 1.0);
|
|
|
|
|
|
|
|
float brightness = dot(FragColor.rgb, vec3(0.2, 0.7, 0.07));
|
2021-01-29 02:13:38 +01:00
|
|
|
if(brightness > 0.2)
|
2021-01-29 01:07:43 +01:00
|
|
|
BrightColor = vec4(FragColor.rgb, 1.0);
|
|
|
|
else
|
|
|
|
BrightColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
|
|
}
|