I don't think it's the aspect of the shader not liking the fog but simply the aspect of the camera which doesn't like the fog in combo with a particular shader ^^
I had this problem too with postprocessing (PP) effects (pixel based) and I resolved it by increasing the fog start parameter of the view that is used.
First try these simple lines in your function main without the function for controlling the fog:
camera.fog_start = 200;
camera.fog_end = 4000;
If that doesn't work, I would add a fog parameter into the shader code. Since fog is processed at a per vertex way, you need to do the following:
// add this parameter and function before the vertex shader(VS)
float4 vecFog;
float doFog(float3 WPos)
{
return(1 - (distance(WPos, vecViewPos) - vecFog.x) * (vecFog.z));
}
Then you need to add the following things to the VS:
// put this in the output struct from the vertex shader
float fog: FOG;
// put this in the vertex shader
Out.fog = doFog(mul(In.position, matWorld));
Since a specular effect has got a VS, I assume this should work if step 1 doens't help
Btw, I didn't use step 2 to overcome my problem as a PP effect is pixel based.
Thanks in progress
Frazzle