Normals for height map data
I want to find normals for height map data. I am using gl_triangles in my code for indices. How would I find normals for this? Given a triangle (vert1, vert2, vert3) its normal is ((vert2 - vert1).cross(vert3 - vert1)).normalize() . For smooth, per-vertex normals: Foreach vertex, sum together the face normals for each triangle that vertex is a part of, then normalize the sum. EDIT : Example: #include <GL/glut.h> #include <vector> #include <cmath> #include <Eigen/Core> #include <Eigen/Geometry> using namespace std; using namespace Eigen; typedef Matrix< Vector3f, Dynamic, Dynamic > VecMat; //