I have another question again concerning the calculation of normals. In my system I am calculating normals for various models using smoothing groups.
The idea is pretty basic and standard from what I have seen from people facing similar tasks.
- Iterate the triangles and calculate surface normals
- Count how many surfaces a vertex belongs to and sum all the surface normals each vertex belongs to
- Normalize the sum for each vertex.
This along with point light (calculated at vertex shader) seems to be rendering some test .3ds models beautifully.
A problem came up when I tried to render some glyphs. I have the vertices of each glyph(a letter) and the triangles that should be formed but no normals. So I went about to calculate them the same way I did for the other models.
The results can be seen in the screenshots below. Do you think I might have done something wrong or calculating normals this way is not a solution that fits every model?
You can easily spot my problem. Especially visible at G above. Some of the triangles that were created in order to triangulate the glyph’s outline are still visible and are standing our really uglily. This happens from most angles of view but from some angles as you can see the glyph is rendered nicely. Is this a problem with my normals calculation? Or could it be something totally different that I am missing.
I also tried a different normals calculation quite similar to the algorithm I mentioned above but with the added difference that I only added a surface’s normal to the vertex’s normal if it did not have any additions from that surface’s plane before. So that one vertex could get only 1 normal in its sum from each plane. But that did not work out either.
Thanks for your time. Any help is appreciated.
Edit: I would like to clarify something. The glyphs are comprised of 1 set of points duplicated in the z axis and then with additional triangles formed in order to connect the set of points of the glyph with its extrusion in the z axis.
The problem lies with the surface normals of these extra triangles getting added in the normals calculation. This is what produces the output from the screenshots above.
If I did not include these extra (let’s call them extrusion triangles) extrusion triangles in the normals calculation then the glyphs appear beautifully with the exception of when being viewed sideways where there is only blackness. I presume due to a normal of 0. You can see what I mean below.