I am trying to experiment with GLSL lighting and in particular with implementing the Phong lighting algorithm. I am not sure if the shader implementation I have is wrong or not but I have to verify that the normals that are sent to the shader are correct.
My code takes a mesh of vertices and indices and calculates the normal with the following way I figured out by checking various websites around the net:
1. Iterates the triangles and calculates surface normals 2. Counts how many surfaces a vertex belongs to and sums all the surface normals each vertex belongs to 3. Using the above calculation the average normal of each vertex is calculated 4. It is reduced to a unit vector.
The above does not seem to be working. It is quite possible it might be an error in the code, and if so I will post code also but I figured I should first ask if the logic is correct first.
The result of this is some kind of strange lighting which makes the objects look transparent. I tested it with a simple rectangle and below you can observe the results when you are looking at it from the front. The light source is located above the eye coordinates(on our head).
In both cases the problem is that they all look transparent from some particular angle views. Anyone has any idea as to what might be the problem here?