I did one for terrains and it's pretty fast. The shading is generated by calculating the normals direction in relation to the sun. The shadows are generated by checking to see if the point is occluded. As I say I use terrains (Bitmaps) to provide the height information, there is no reason why you could not use a mesh terrain and use vertex positions - you may need some interpolation if your terrain is not in a grid format. And for the normals use the VertexNX() etc... commands.
Here is the link : http://www.blitzbasic.com/codearcs/codearcs.php?code=1004
Here is the link : http://www.blitzbasic.com/codearcs/codearcs.php?code=1004