Warp's mesh smoothing utility contains a great explination of how to smooth triangles. A question was asked in the advanced users group if the normals of a smooth triangle should be weighted or not. The answer was, of couse, "however you want it."
| Part Zero Setting Up | |||
|---|---|---|---|
|
|
Setting up is pretty simple. We're going to describe a cirle with points on it, and connect them to another point not on the same plane, so it is tent like in shape:
The first two images show 4 and 12 triangles. We are not worried with the look around the ring, put the area around point q. The second image looks smoother because of the larger number of triangles. If there 30 or 40 triangles, at this resolution, it looks completely smooth. Creating more triangles isn't always an option. Smooth triangles are the solution we want here. We will look at using normalized normal vectors and standard normal vectors and we will offset q so it is closer to one side of the ring than the others. |
|
![]() 1. 4 triangles ![]() 1. 12 triangles |
| Part One Creating smooth triangles | |||
|
|
The easiest way to create three normal vectors per triangle is to use POV-Ray's vcross function. The other thing to keep in mind is that the normals need to be on the same face of the triangle. If one of them is "above" the triangle and the other two "below", then the triangle will crash, or give an error as being degenerate and not render. To play is safe, we want to make sure that our vectors are being treated as "clockwise." The code below is part of a loop that finds all of three normal vectors for each triangle (Image 3, the normal lengths are 25% of what they should be):
Image number 4 shows the same four triangles, smoothed out. It is hard to see the shape, even with the light-source moved up to give a bit more hightlight. |
|
![]() 3. The normal vectors of unsmoothed triangles ![]() 4. 4 smooth triangles |
| Part Two Uneven triangles | |||
|
|
Now we are going to move q to <0.8,0.35,0>, and using smooth triangles with normalized vectors we have image 5. Notice the two corners are in shadow, because the normals are pointing away from the light. This is similar to the hard shadow artifact that POV-Ray gives us. Image 6 is exactly the same, but the normalization of the normal vectors is omitted. The shadow effect is lessened. Here is the code to draw the smooth triangles.
|
|
![]() 5. Normalized normals ![]() 6. Unnormalized normals |
Thanks for watching.