What is wrong here?
The code:
Fragment Shader
#version 330
layout (std140) uniform Material {
vec4 diffuse;
vec4 ambient;
vec4 specular;
vec4 emissive;
float shininess;
int texCount;
};
uniform vec4 Lightambient;
uniform vec4 Lightdiffuse;
uniform vec4 Lightspecular;
in vec4 ShadowCoord;
in vec3 lightVec;
in vec3 eyeVec;
in vec2 TexCoord;
uniform float invRadius;
uniform sampler2D Textures;
uniform sampler2D normalMap;
uniform sampler2DShadow ShadowMap;
out vec4 output;
void main()
{
float distSqr = dot(lightVec, lightVec);
float att = clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0);
vec3 lVec = lightVec * inversesqrt(distSqr);
vec3 vVec = normalize(eyeVec);
vec4 base = texture2D(Textures, TexCoord);
vec3 bump = normalize( texture2D(normalMap, TexCoord).xyz * 2.0 - 1.0);
vec4 vAmbient = Lightambient * ambient;
float diffuseVec = max( dot(lVec, bump), 0.0 );
vec4 vDiffuse = Lightdiffuse * diffuseVec * diffuse;
float specularVec = pow(clamp(dot(reflect(-lVec, bump), vVec), 0.0, 1.0),
shininess );
vec4 vSpecular = Lightspecular * specular * specularVec;
float shadow = 0.0;
if (ShadowCoord.w > 1.0)
{
shadow = textureProj(ShadowMap, ShadowCoord);
}
output = ( vAmbient*base + vDiffuse*base + vSpecular) * att * (shadow+0.2);
}
Any suggestions?
Thank you, best regards.