Polygon reduction

Modern graphics cards can easily render millions of polygons at a high framerate. Usually other things will be a limiting factor such as draw calls, fillrate, complex shaders, etc. However, CAD models can produce excessive amounts of polygons and this needs to be reduced.

There are several techniques to reduce polygons from CAD models. I will go through each of them.

CAD models in general are vector based. So if you convert from CAD to non-CAD, you have to ask yourself how many polygons you want to create rather than how many polygons you want to remove.

A good program which can convert CAD vector files from Inventor (ipt and iam files) into polygons (fbx for example) is 3ds Max. At the import dialog you can choose how many polygons should be generated, called the “mesh resolution” slider.

mesh resolution

I found that a value between 0 and -2 is adequate for real time rendering. Large curved surfaces might need a higher setting though.

Another great way of reducing polygons is to remove all surface detail and replace it with a texture. To do this, first copy your entire CAD project folder and rename it to something like “LOW RES”. Don’t remove the surface detail form the main CAD source as it can be a lot of work to undo the changes.

To remove the surface detail, click on all surface features such as small chamfers, fillets, extrudes, etc. and delete them. Below is an example of a model how it looks originally. You can see that it has a lot of surface detail which will convert to a lot of polygons. Without modification, this model will generate 2814 polygons with a mesh resolution setting of -2.

high res cad

The screenshot below shows what the CAD model looks after removing all the surface details.

low res cad

This model generates only 170 polygons with a mesh resolution setting of -2. That is a 16x reduction, just be removing the surface detail! The details can be replaced by a texture, making it much faster to render.

Not all surface details can be removed by simply deleting features, for example in the case of this coil.

coil

Unless the coil shape is made by engraving a shape out of the edge of a cylinder, it can not be deleted. In this case we need to replace the coil by inserting a cylinder just below the coil feature. In order to do this, move the End Of Part icon to just below the coil feature. Then create a cylinder which matches the coil and move the End Of Part icon to the bottom again. Inventor should apply the bend to the cylinder automatically and you can delete the entire coil feature, leaving only the cylinder, as shown below.

cylinder

In this case the amount of polygons are reduced from 10.596 to 394 (mesh resolution -2), as shown below.

coil to cylinder

This is a 1 minute tweak which results in a 27x reduction of polygons!

You can also remove polygons which will never be visible. This might not be worth the effort though as it requires a lot of manual work. Even if you managed to remove 100.000 polygons by hand (which is a lot of work!) then there will be no noticeable increase in frame rate unless you run it on a mobile device.

As an example, the bottom of our CAD model will never be visible, so these polygons can be removed. Here is the bottom of the model before.

low res closed

Pictured below is the bottom of the model after manual polygon removal.

low res open

The amount of polygons is now reduced from 170 to 148. Again, this might not be worth the trouble. Either way, you most certainly don’t want to texture map invisible areas as that wastes texture space.

Now that we have our low res model, let’s make a high res model which will be used for baking textures. This is easy. Just import the original CAD file which includes all surface detail and set the mesh resolution to the highest available.

This is our CAD model imported with the highest mesh resolution.

high res fbx

Now the model has 51.698 polygons. This is not suitable for real time rendering (or at least not if the entire model has this resolution), but it is great for texture baking.

How to bake a texture from a high res model is different for each 3d modelling package so I won’t go into details. The basic idea is to project the high res model onto a texture to generate at the very least a normal map. Other maps such as occlusion and curvature maps can be used to further enhance the model. If this is done right, the low res model with a texture applied can look nearly identical to the high res model, under the right conditions.

Advertisements