• Create Account

What normal to use when triangles are in smoothing groups?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

#1Thomas WIlliams  Members

102
Like
0Likes
Like

Posted 22 February 2012 - 07:55 AM

Hello,
I am currently in the process of building a 3D graphics engine in C#. My aim is to not use any 3D libraries that would provide support. For that reason I am using the standard GDI available through the .NET framework. Its come on a lot further than I imagined. I have done all triangle plotting by hand and it fully supports texturing and .OBJ wave front file import (bar the smoothing groups)

As you can see from the cylinder above there is some shading from a fixed point light source. I use the normal of each face with the vector of the light to the triangle to calculate the triangle intensity. I am using the Lambertian Reflectance model to calculate the correct light intensity of each face.

My draw triangle function works by specifying 3 things:
• 3 * 2D-screen coordinates
• 3 * texture UV coordinates
• 3 * intensity of a vertex of the triangle (in the above screenshot each vertex on any given triangle will have the same intensity)
My question is this: If a group of triangles are in a smoothing group how would I calculate the light intensity at each triangle vertex?
I think I may be missing something...

Thank you in advance for any help. Hope this is the correct place and what not

#2johnchapman  Members

597
Like
1Likes
Like

Posted 22 February 2012 - 08:04 AM

You need to duplicate any vertices that are shared between smoothing groups; they will have different normals. So, for example, if 2 smoothing groups meet at a single edge, the vertices on that edge will need to be duplicated.

#3Thomas WIlliams  Members

102
Like
0Likes
Like

Posted 22 February 2012 - 08:19 AM

I sort of see where you are coming from. I still don't understand how I could make the calculation. So if I had 2 triangles at right-angles joined along one edge (and part of the same smoothing group). what vector would I use for the intensity calculation at the joining vertex? Do I calculate some average of the 2 face normal vectors?

Thank you for the speedy reply

#4johnchapman  Members

597
Like
1Likes
Like

Posted 22 February 2012 - 12:22 PM

Sorry; I think I misread your question. Within a smoothing group triangles can share vertices; the normal at each vertex is some function of the normal(s) of the face(s) to which that vertex belongs - averaging the face normals will work perfectly for this.

#5Thomas WIlliams  Members

102
Like
0Likes
Like

Posted 22 February 2012 - 05:14 PM

I will have a go at implementing that and post my result back. This sounds like it could work. I will now have to cycle through each triangle in a given smoothing group to work out the averaged vertex normals. Thank you once again.

#6Zoner  Members

232
Like
0Likes
Like

Posted 25 February 2012 - 01:20 AM

For shared vertices, typically you calculate the triangle normals normal and weight them based on the angle of the wedge at the shared vertex, then normalize.

a 90 degree corner contributes twice as much of its triangle normal to the vertex than a 45 degree corner

This weighting breaks down if _edges_ can be used by more than two triangles (i.e. polygon fins sticking out of your mesh)

#7Thomas WIlliams  Members

102
Like
0Likes
Like

Posted 27 February 2012 - 09:14 AM