ReduceMesh Advice


(Clay Budin) #1

Hi,

I’m very experienced with graphics and software development, but a relative newbie on Rhino. I am using Rhino 6.7.18210.11281 to take in a CAD model and prepare it for use in the Unity game engine. For one step, I need to take the highly detailed model and greatly reduce the number of polygons in it. I’ve found the ReduceMesh tool to be both powerful and efficient; however, it seems to suffer from the problem of trashing a few of the meshes. I was wondering if any of the more experienced Rhino users could help me find a way of addressing this.

When I select the model, made up of many meshes, it seems like ReduceMesh runs on all the selected meshes with the same parameters. Among the meshes are these objects

which Rhino reduces to these visibly broken meshes.

Of course I could manually exclude meshes of this type, but I am looking for a way that is as automatic as possible. Also note that these objects are doubly-meshed on the inside and out, so if I push the “Add All Naked” button for the Locked Mesh Points, the rim points don’t get selected. Also, Rhino considers this a closed mesh, so I can’t not select it that way.

Any ideas on how I would programmatically identify meshes of this type? Or some way of varying the ReduceMesh parameters to take into account the amount of “damage” done to a mesh by reduction? Or even a metric that measures the amount of change in a mesh by the reduction process?

The ReduceMesh documentation page suggests that there is a Fast <-> Accurate trade-off parameter, but I don’t see it in my parameter dialog. Is there a way to run ReduceMesh on the command line that would allow me to access that parameter?

Any advice is appreciated.

Thanks,
Clay Budin
NYC


(Brian James) #3

Hi Clay,

Does the Planar only option do anything positive for you here? I mocked up a model of what you described where there’s both interior and exterior faces to the mesh cylinder making the rims not naked edges. It’s true you can select and use locking to prevent these verts from being impacted but it sounds like you want it to be automatic… I found the planar only option did the trick. Post a file of your own if you need more help please. You might need to use WeldVertices prior to reduction at a guess (UnweldVertex is the opposite) but this may impact your UVs depending on where you lay those out in your workflow.
reducemeshtest-planar.3dm (139.0 KB)


(Clay Budin) #4

Thanks for getting back to me.

I’ve been running the Planar Only option first, as a kind of pre-processing step. It seems to me that it’s basically an either/or situation: Either you reduce planar faces or you can reduce by a specific number or percentage.

For my object shown above, Planar Only didn’t really help - the faces are already down to 2 triangles per planar face, which is about as small as I can get them.

Let me clarify my original question, because now I see that I wasn’t completely clear about what I’d like to have happen:

I’m fine with ReduceMesh doing nothing to these cylindrical objects. I have a large model containing about 8,000 meshes and I want to automate the polygon reduction process as much as possible. That means that I select all 8,000 meshes and run ReduceMesh with a target of say 50% reduction. For other objects which can be reduced, then great, the reduction runs. For these cylindrical objects which are already reduced about as much as they can be, then nothing happens.

The key thing here is I would like to avoid having to manually find all of these objects for which further reduction will greatly affect the shape. I would like to automate this process (as much as possible).

I think there may be several ways of posing this problem:

  1. Reduce the number of polygons in any given mesh, subject to the constraint of not exceeding some measure of how much the mesh is changed by the reduction.

  2. Identify meshes which are already at or close to some notion of “maximally reduced” so that any further reduction will significantly alter the shape (based on some tolerance value or something).

  3. Some kind of “adaptive reduction” process where each mesh is reduced as much as it can be without changing the shape too much.

As I write this it seems clear that the key element here is some kind of metric that measures how much a given reduction changes the shape and topology of the original mesh.

Also, what happened to the “Fast <-> Accurate” parameter mentioned in the Rhino docs (eg at https://docs.mcneel.com/rhino/6/help/en-us/index.htm#commands/reducemesh.htm)? Would that help me? I’d be happy to run the mesh reduction as a command-line function if I could access that parameter (and it helped).

Thanks,
Clay Budin
NYC


(Brian James) #5

Run the dash version of the command to access that setting. Looks like it’s the max for accuracy by default.
-ReduceMesh > Accuracy option

I’ll file a doc change request that we explain where this is now or add it to the dialog, it may have been exposed at one point in the dialog UI and then removed.
https://mcneel.myjetbrains.com/youtrack/issue/RH-47746

Any way you can post a file with some of the meshes in it? I’ve got a word in to the developer to ask for any further advice but I know a sample file would help. Ideally before and after stages showing what you’d like to automate. Maybe only 20 or so meshes in the file representing the variety you’re working with.


(Clay Budin) #6

Thanks for the info. Yes, it looks like it is already set for max accuracy.

Unfortunately the model is proprietary IP, so I can’t make it available. I can speak to the powers that be here and see if a small subset of 20 or so objects would be OK to send.

Thanks,
Clay Budin
NYC


(Jussi Aaltonen) #7

Hi @clay.budin, at the moment ReduceMesh can’t do that but this functionality has been requested multiple times over the years. So one day it will be added. And surely it would be a big help to have real world sample meshes to test with.

Accuracy parameter is useful if you have a planar area on the mesh with regular face pattern and you wan’t to get little reduction randomly spread over that area. But like documentation says risk of getting deformations on non-planar areas increase.

Jussi


(Clay Budin) #8

Fair enough. In the meantime, could someone show me how I would write a script to select the “densest” meshes:

  1. Start with nothing selected
  2. Loop over all visible meshes in the scene
  3. For each mesh, compute its bounding-box volume (or perhaps some other parameter like surface area), and the number of triangles/faces/vertices it contains
  4. For the current mesh compute the “density” as the ratio of the number of tris/faces/verts to the volume/surface are.
  5. If that density ratio is above a certain given parameter, select the mesh, otherwise don’t select it.
  6. At the end, report the number of selected meshes.

So, this would operate a lot like the Select->Select Small Objects tool (which is great, by the way). It would be an extension/generalization of that sort of functionality that I could customize to my needs. Generally speaking, the meshes that benefit most from ReduceMesh tend to be the smallest and/or have the most tris/faces/verts to begin with.

I don’t know exactly how scripting works in Rhino, but I would prefer if this ran without the need for any add-on plugins (like grasshopper), which would have to be purchased separately. Python would be perfect.

Thanks,
Clay Budin
NYC


(Brian James) #9

Grasshopper is included in Rhino 6… just type Grasshopper. I’d go about setting this up there personally but other users prefer writing code. Python is also an option for you in Rhino 6… use EditPythonScript

I’m not sure off the top of my head how I’d handle steps 4 and 5 in GH. A sample file showing the meshes you want to sort would be needed but that as a separate GH challenge post would probably get you some attempts at it. Or post to the Scripting category here as well.