Quote Originally Posted by Dan View Post
assuming the center of the sphere is in (0, 0, 0) - the normal of each vertex is the normalized position of that vertex. so all you need to do is Vertex[n].Normal := normalize(Vertex[n].Position)
I think the issue with sphere is about making the faces. Normals should be generated with the function that is used with terrain as the idea was to check if it generates them right.

I made quickly a similar terrain with my 3D tool and it actually may light it up like in the pictures you've shown if light source is directly above.

I don't have a simple function to generate it atm but you can also try moving the lights around, or shaping the terrain bigger.

As for how normal is calculated for face:
- Crossproduct from 2 vectors going from vertex A->B and A->C
- Normalize (scale length to 1)

Normal for vertex:
- Make a temporary vector T and initialize it 0
- Also start a integer variable Counter = 0
- Start a for loop that goes through faces (F), Next for loop going through each vertex in that face (V), Pick each face that connects to the vertex V and belongs to the same smoothing group as face F:
- - Add face normal vector to T
- - Increase counter by 1
- Divide T by Counter
- Normalize T

This won't work well for object that's shaped like a cone, because the top vertex is connected to all faces and it makes the normal look bad. But if you have a cube and each face in its own smoothing group then it will properly make them flat.