Hello,
i probably need some help with a strange beaviour of a lightning-function in a fragment-shader.
This is the relevant shader-code (a bit simplified):
in Data {
vec4 Vertex;
vec3 Normal;
vec4 Position;
vec4 TexCoord;
} In;
out vec4 color;
vec3 normal = In.Normal;
vec3 LightVec = normalize( gl_LightSource[0].position.xyz - vec3(In.Vertex));
[...]
void main() {
[...]
// --- Create Bumpmap ----------------------------------
if (uniBumpFact > 0) normal = normal + bump(Texture0, uniBumpFact) ;
// --- Shadow ------------------------------------------
float intens = max(dot (-normal, vec3 (LightVec)), 0.0);
color = color * intens;
[...]
}
The problem is that the light on the back side of the vertices is somehow inverted, so the shadow on an object which is drawn fron right to left, appears on the wrong side.
Does anyone have an idea what the problem might be?
Thanks,
Frank