make sure your normals are correct with respect to your geometry. The cross product of two vectors u & v will generate a normal with the 'right-hand rule'. If you point your index finger of your right hand in the direction of u and stick your middle finger at right angles to your palm and point it in the direction of v then sticking your thumb up into the air is the cross product of u and v. This trick works because you can only rotate your middle finger so far and so you're compelled to rotate your hand to get your fingers pointnig in u and v... and as you do so, your thumb will change direction accordingly.
Why is this important to know? Because if you haev two vectors, u and v, and computed the crossproduct(u, v) and crossproduct(v, u) (note the change in ordering), then you'll get _two vectors in opposite directions_.
So, the problem you have, I think, is that you're sometimes computing the wrong normal.
to fix this,
1) decide on a winding order for your veritices. I suggest counter-clockwise (the opengl default).
2) make sure all your triangles are in couter-clockwise order, and
3) make sure you compute the normals in the right order for your winding.
for example, if you choose counter clockwise, then the front side of your triangle would look like
(0, 1, 2 travel counterclockwise). You could compute the normal as crossProduct(1-0, 2-0) and get a normal pointing towards you (since you're looking down at this triangle).Code :0 |\ | \ 1--2
If you ensure that your winding order is ALWAYS clockwise then you can always comute your nromals that way and gauarantee they point outwards.
hope this helps