How good is directx normal calculation

Hi;

I've created a small (5 vertex by 5 vertex) heightfield mesh with adjacency information.

The mesh is flat in the x-z plane, with a single overhead light.

I raise a single point in the cente of the mesh, thus creating a small four-sided pyramid. I then recalculate the normals using mesh.computenormals.But instead of getting a symettrically shaded pyramid, I get an asymmetrical mess. The pyramid is fine, but the shading is wrong.

As far as I can tell, this is actually the directx normal calculation going wrong -- perhaps because it doesn't use weighted vertices?

I've attached a picture of the result here. Does anyone know why it looks like this? Is the default normal calculation really that bad or did I mess something up?

Here is how I modify the mesh:

Vertices(12).Y += 1

Mesh.SetVertexBufferData(Vertices, LockFlags.None)

Mesh.GenerateAdjacency(0.01, Adjacency)

Mesh.ComputeNormals(Adjacency)

And here is the awful result:

http://img241.imageshack.us/my.php?image=imageqw4.jpg

Regards...

[1239 byte] By [ImagineNation] at [2007-12-23]
# 1
Since you're using flat shading only the first vertex of a triangle determines it's shade. This works when the all vertices of a triangle use the same normal, but ComputeNormals() generates a different normal for each vertex based on its adjacent triangles. If you want a rounded smooth pyramid with no visible edges you should use Gouraud shading, if you want your pyramid to have sharp edges you need to compute your own normals.
RossRidge at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2

Ah thank you!

Ironically the reason I was using flat shading was because I wanted to see how well the normals were working so I wanted colour differences to be "obvious"

When I switched back to gouraud shading it was perfect.

Thanks very much!

ImagineNation at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...