Smooth an Arbitrary Mesh?

Hello,

I’m using the code from the procedural extrusion example:

http://unity3d.com/support/resources/example-projects/procedural-examples.html

I’m using graphics primitives to draw arbitrary shapes such as the one pictured below.

I’m wondering if anyone knows how to go about smoothing the resulting mesh. In any case, the extrusion seems to produce unsightly edges for some reason.

I’m not sure how the source mesh is constructed or what extrusion method is being used in your example, but in general, the effect shown in your image is the result of each triangle in the mesh being separate (that is, no vertices are shared), and each vertex having the same normal as the triangle with which it’s associated.

To ‘smooth’ a flat-shaded mesh, the normal for each vertex should be set to the normalized average (in one form or another) of the normals of the triangles that it touches. Computing these normals procedurally generally involves (possibly) welding vertices, and generating connectivity information.

I don’t believe Unity has any built-in functionality for this; if that’s the case, you’ll most likely need to modify the source mesh and/or the extrusion algorithm used in order to get the results you want.

(Or at least that’s the way it seems to me at the moment. I could be overlooking something though.)