I had a chance to play with your code today to try to figure out the weird shadow problem that still exists with the code.
After a few hours I have narrowed the problem down to a few lines of code. But the problem area is perplexing.
I first looked over the shader code. It seemed OK. Then I moved onto the generation of the normals, because I came to believe that was in error. But that too, was OK. I generated the same exact normal map as you do.
So I added the following bit of code to your LoadContent class right after the creation of the new quadterrain and subsequent texture save to "C:\normalData\test.png"
| Texture2D test = Content.Load<Texture2D>("test"); |
| q.TerrainShader.Parameters["NormalTexture"].SetValue(test); |
Viola it worked! But the question is why? What is the Content loader doing different with the texture vs. what you did to generate it? I couldn't come up with an answer, but I need to get back to my code.