Lefteris

11-20-2011, 12:38 PM

Hello,

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.

1. Iterate the triangles and calculate surface normals

2. Count how many surfaces a vertex belongs to and sum all the surface normals each vertex belongs to

3. 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?

1 view of 'G'

http://img824.imageshack.us/img824/9886/strangenormals1.png (http://imageshack.us/photo/my-images/824/strangenormals1.png/)

2 view of 'G'

http://img221.imageshack.us/img221/1825/strangenormals2vx.png (http://imageshack.us/photo/my-images/221/strangenormals2vx.png/)

1 view of 'F'

http://img190.imageshack.us/img190/6006/strangenormals4.png (http://imageshack.us/photo/my-images/190/strangenormals4.png/)

2 view of 'F'

http://img265.imageshack.us/img265/974/strangenormals3.png (http://imageshack.us/photo/my-images/265/strangenormals3.png/)

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.

'G' rendered nicely since the extrusion triangles are not taken into account

http://img254.imageshack.us/img254/1287/noextrude1.png (http://imageshack.us/photo/my-images/254/noextrude1.png/)

'G' again with the same calculation but this time looking at the extrusion triangles and seeing only blackness.

http://img521.imageshack.us/img521/7743/noextrude2.png (http://imageshack.us/photo/my-images/521/noextrude2.png/)

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.

1. Iterate the triangles and calculate surface normals

2. Count how many surfaces a vertex belongs to and sum all the surface normals each vertex belongs to

3. 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?

1 view of 'G'

http://img824.imageshack.us/img824/9886/strangenormals1.png (http://imageshack.us/photo/my-images/824/strangenormals1.png/)

2 view of 'G'

http://img221.imageshack.us/img221/1825/strangenormals2vx.png (http://imageshack.us/photo/my-images/221/strangenormals2vx.png/)

1 view of 'F'

http://img190.imageshack.us/img190/6006/strangenormals4.png (http://imageshack.us/photo/my-images/190/strangenormals4.png/)

2 view of 'F'

http://img265.imageshack.us/img265/974/strangenormals3.png (http://imageshack.us/photo/my-images/265/strangenormals3.png/)

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.

'G' rendered nicely since the extrusion triangles are not taken into account

http://img254.imageshack.us/img254/1287/noextrude1.png (http://imageshack.us/photo/my-images/254/noextrude1.png/)

'G' again with the same calculation but this time looking at the extrusion triangles and seeing only blackness.

http://img521.imageshack.us/img521/7743/noextrude2.png (http://imageshack.us/photo/my-images/521/noextrude2.png/)