I'm generating terrain using perlin noise and then computing normals using:
D3DXVECTOR3 v0 = aoVertices[auiIndices[i]].Position;
D3DXVECTOR3 v1 = aoVertices[auiIndices[i + 1]].Position;
D3DXVECTOR3 v2 = aoVertices[auiIndices[i + 2]].Position;
D3DXVECTOR3 v3 = aoVertices[auiIndices[i + 3]].Position;
D3DXVECTOR3 v4 = aoVertices[auiIndices[i + 4]].Position;
D3DXVECTOR3 v5 = aoVertices[auiIndices[i + 5]].Position;
D3DXVECTOR3 vNormal;
D3DXVECTOR3 vCross;
D3DXVec3Cross(&vCross, &D3DXVECTOR3(v2 - v0), &D3DXVECTOR3(v1 - v0));
D3DXVec3Normalize(&vNormal, &vCross);
aoVertices[auiIndices[i]].Normal = D3DXVECTOR3(vNormal);
aoVertices[auiIndices[i + 1]].Normal = D3DXVECTOR3(vNormal);
aoVertices[auiIndices[i + 2]].Normal = D3DXVECTOR3(vNormal);
D3DXVec3Cross(&vCross, &D3DXVECTOR3(v5 - v3), &D3DXVECTOR3(v4 - v3));
D3DXVec3Normalize(&vNormal, &vCross);
aoVertices[auiIndices[i + 3]].Normal = D3DXVECTOR3(vNormal);
aoVertices[auiIndices[i + 4]].Normal = D3DXVECTOR3(vNormal);
aoVertices[auiIndices[i + 5]].Normal = D3DXVECTOR3(vNormal);
However this is causing grid lines to appear between grid squares. Any ideas what the problem is?
Example:
I don't know much about DX10 but I recently did this in OpenGL, it looks like you're doing your normals on a per triangle basis which will give you flat shading, so what you see is probably correct.
If you wish to calculate your normals per vertex use something like:
((x+1) - (X-1)) X ((Y+1) - (Y-1))
where X is the vertex in the X direction on the grid and Y in the Y direction.