Tuesday, October 1, 2013

Another Fine Mesh

So.  Mesh design, for 3d printing and for Poser, and how those differ.

This is going to be a rambling post, an exploration of concepts and ways to explain them that might, one day, make it into a tighter and better edited post.  With pictures.



There are two major philosophies to building a mesh, in my opinion.  Two ways of working.  One is to use shape and surface tools, working at an abstraction from the actual polygons.  And when it comes time to clean up for export, you rely on more automated tools.

The other is to work with the polys.  To get down in the dirt and wrestle with individual vertices.  I'm old-school.  This is how I work.  Perhaps some day I will change.

Working at the larger, abstracted layer, with subdivision surfaces, displacement painting, and so on and so forth, is faster.  And probably gives you a better feeling for the shape.  The kinds of modeling applications that have good tools for this sort of work -- stacks, hypernurbs, etc. -- also tend to have mesh clean-up tools like retopology and decimation.  Although you might have to turn to third-party aps with tools to check for n-gons and merged faces and so forth.

My feeling is that at least some of the time you gain at the top is lost at this stage.  And since you are still working at an abstracted layer, you end up spending a potentially long and frustrating time trying random settings on different tools, perhaps never even finding out which one finally made your mesh behave.

Also, for the modeler on a budget, each tool you add to the tool chain is more cost.

I'd like to use more of these tools.  In the application I use currently (Carrara, which I no longer recommend to anyone), I've had small success with some of the tools, specifically subdivision, as well as lofting, lathing, and path extrude.  But even the most basic "automated" operation in Carrara -- such as selecting an edge loop -- is fraught with exceptions.  Over and over, I have to work manually at selections and welds and so forth because Carrara's tools are simply too blunt, awkward, and glitchy.

The tl:dr for the above; I'm going to talk polys, not tools, because that is how I see the mesh -- and how (far too often) I have to work with the mesh.




In 3d printing, the most important thing is that the mesh be manifold.  Words are not the best way to demonstrate, and there is a good explanation with illustrations at the Shapeways site, but here goes anyhow: a manifold surface is a single completely enclosed volume.  You can't have divisions across the surface.  You can't have lines or faces sharing the same space.  A manifold shape is watertight, but that is only part of it.

However, at Shapeways at least you can have several different manifolds within a single printed object.  The intersection is calculated, and priced accordingly, but it is only printed once.  Just make sure the overlap is generous enough that you don't end up with two exactly adjacent faces that share the same space.  That will throw up non-manifold errors.



For Poser, it is only necessary to have faces.  You can stack and align polygons in any manner you chose.  The exception is organics -- anything that is going to have smooth bends or similar deformations.  Then you have to make sure you connect all the edges otherwise it will "tear" when posed or otherwise bent.

One thing Poser does get annoyed at is double-sided polygons.  If you have two faces sharing the same physical space, Poser will render them weird (often they go black).  So even simple things like a sign on a wall needs to be done in a slightly more complex manner; extrude the sign to give it a little thickness, then stick it on the wall so that the front face is slightly in front of the wall faces.

The really annoying part is that the backside of faces don't display in preview (and may render funny).  So something as simple as a coat sleeve needs to be modeled with thickness, otherwise it will vanish when you look from the inside.  And this, of course, plays utter hob with dynamic clothing...




In 3d printing, the facets are what gets printed.  If you want a smooth surface, you need to add the facets to the file.  Fortunately the print software limit is over a million polys, so you can freely tesselate the mesh until your curves are finer than the resolution of the print head (depending on the material and process, about 0.1 mm).

Since hundreds of polys can be a pain to crawl through looking for the one bad weld, the smart thing is to build the basic shape and get it watertight and manifold...and then tesselate (but only in ways that don't break the mesh -- thank you again, Carrara!)




In Poser, smoothing is applied.  More-or-less in two different ways; the basic render algo smooths across adjacent polygons.  But the Firefly render engine applies some sort of  micro-poly smoothing to all surfaces before render.  At least that's what I think I heard.

In any case, the issue in Poser can be to stop it from smoothing.  Depending on the version of Poser you are targeting, you can turn off smoothing for some parts of your mesh or even set the smoothing angle individually. 

But it is smarter to design your mesh to avoid the "marshmallow" effect in the first place.  The simplest way is to split faces.  Take a cube.  If you rendered it with the defaults, you'd get a marshmallow.  If you split each face into a unique polygon, it will have hard edges again.  However, if you try to animate it like this, it will break along one or more of the 12 seams.

Also, hard edges look fake.  So a better move is to add a tiny bevel.  This bevel will catch the light and look realistic, and it will hold the smoothing to actually make a tight corner.  However!  Firefly works so hard to smooth the mesh (Poser was written to make pretty girls look pretty.  It doesn't do so wall with cars, guns, and buildings) that it will warp the flat faces of the cube.  To keep THAT from happening, add an arbitrary constraining edge loop just outside of the micro-bevel.

This does mean that one edge turned into four.  Which is why if you are worrying about your poly count, better to just split faces.  Plus it makes for a cleaner mesh; the intersections of three micro-bevels and their retaining edges in a single corner is not a pretty thing.

Another habit of the Firefly smoothing algo is the "bagpipe" effect.  If you have a long cylinder, it will bloat in the middle.  Add (you guessed it!) another edge loop or two as a constraint.

Of course, smoothing is not a panacea.  The surface is defined by the lines, and when you try to stretch polys too far you get splotchy surfaces in your render.  Also, although the lighting may be smoothed, the edges are not; if you build a globe with twenty facets, it may render as a sphere, but the edges will look like a D20.

And as of Poser 9, the smoothing algorithm has been changed.  Now micro-bevels look horrible when smoothed.  In fact, no combination of bevels and restraining loops will allow a cube to be smoothed.  Poser is now completely broken in this regard.  With smoothing left at the default setting, only at the lowest quality render setting does any difference appear between a mesh with split edges and one without anything.  With smoothing turned off, there is also no apparent difference.  

However, even unsmoothed, a cube with beveled edges renders badly.  A cube with constraint loops fares a little better.  Basically, Poser has made it impossible to get consistent and clean results on mechanical objects.


In the Print world, topology is practically a non-issue.  You can print pretty much any kind of wacky polygon.  I suppose in practice some of them will fail, but I've had n-gons and non-planar polys and all sorts of ugliness and it hasn't made my meshes unprintable.



In the Poser world, topology matters.  Even for static props.  Poser doesn't always bork on n-gons, but it has been known to (especially earlier versions of the program).  Poser will also produce render issues with star points.  If you have more than six lines coming into a single vertice, you may get a black spot or some funny long triangles in a slightly different color when you render.  Break up the star points.

For a figure or other object that bends, well, you obviously want good mesh flow.  I'm not going to go into all that right now, but I will say that my personal experience is that quads seem to drape a little better than tris for dynamic fabric.

Edge loops make for smooth surfaces, but if they touch, then bad crunchies result, and really horrible renders.  So you have to really control how many edges there are inside of joints.




Shapeways offers a full-color "Sandstone" material but for the most part the UV map isn't an issue.  The printer will react badly to reversed surface normals, but as far as I can tell the UV map is nothing to the printer.




Color in Poser can be assigned by materials, but even flat single colors doesn't remove the obligation to UVmap.  Because if the UVs are scrunched and confused, Poser renders the surface badly.  Even if there is no texture map involved!

Of course most things are getting texture maps anyhow so...UVmaps.  I have a long lecture about them one day, but for the nonce, only thing I'll say is that if you can map FIRST, detail SECOND, then do it that way!  Map ONE wheel then clone it.  Map the low-poly mesh THEN tesselate.

My experience is that UVmapping can take as long as making the mesh in the first place.  Which is horrible, but that's the way it is.  I'll skimp on the maps for smaller detail items that are just going to be flood-filled, but that's it.  Oh; and map to scale.  If (barring detail maps) all of your maps are the same scale relationship as the actual surfaces, then you can flood-fill a bunch with the same texture.

No comments:

Post a Comment