Hi,

after getting diffuse lighting to work I just added specular to my deferred renderer. But somehow I have the feeling that there is something wrong. I tried it with Phong and Blinn-Phong but both seem to produce specular highlights even when the light source is behind the sphere I render:

Here is my shader code:

```
uniform sampler2D Tex0, Tex1, Tex2;
void main(void)
{
vec4 Color = texture2DProj(Tex0, gl_TexCoord[0]);
vec3 Position = texture2DProj(Tex1, gl_TexCoord[0]).xyz;
vec3 Normal = texture2DProj(Tex2, gl_TexCoord[0]).xyz;
vec3 LightDirection = gl_LightSource[0].position.xyz-Position;
vec3 L = normalize(LightDirection);
float NdotL = max(dot(Normal, L), 0.0);
vec4 FinalColor = vec4(0.0,0.0,0.0,0.0);
if (NdotL>0.0)
{
float Distance = length(LightDirection);
float Attenuation = 1.0-gl_LightSource[0].quadraticAttenuation * Distance * Distance;
// blinn-phong specular
// screenshot 1
vec3 H = normalize(L-normalize(Position));
vec4 Ispec = vec4(1.0,1.0,1.0,1.0) * pow(max(dot(Normal,H),0.00001),32.0);
// phong specular
// screenshot 2
//vec3 E = normalize(-Position);
//vec3 R = normalize(-reflect(L,Normal));
//vec4 Ispec = vec4(1.0,1.0,1.0,1.0)
// * pow(max(dot(R,E),0.00001),32.0);
vec4 Idiffuse = Color * gl_LightSource[0].diffuse;
FinalColor = Attenuation * ((NdotL * Idiffuse) + Ispec);
}
gl_FragColor = FinalColor;
}
```

I thought the if statement would take care of not drawing the specular if there is no diffuse, but it looks like NdotL is greater than zero in this case.

I hope the screenshots show the problem good enough. Using a moving lightsource the problem is far more distracting than in this shots.

Any help is highly appreciated.