As usual it is a matter of adding the right semantic and setting the correct renderstate in the shader.
So, the code.
Shader Model 1.1 - 2
In your Shader's vertex return structure, add the following
In your vertex shader set the fog you require:
Note: This is an example you can generate this how ever you need to.
Now all you have to do is set the render state for fog, so in the top of your pass add this
Where 3 is Linear fog and float4(.5,.5,.5,1) would be the color gray.
Shader Model 3
To get fog working on SM 3 and/or the XBox 360 is a little different
calulate this in the shader per vertex lerp between the
calculated color and the fog color based on the FOG
Thanks to Leaf at XNA UK User Group and Jon Watte for your help with this I am sure this will help many others in there XNA development. Jon's shader also has the ability to specify the height of the fog and so giving a much richer fog effect, nice...
If you have any interest in the discussions we had then take a look here or the comments on this post.
Leaf has also put up an example of Jon's shader in action and you can find that here.