Blender Optimisation Add-on
While optimising numerous Revit model geometries for a large-scale infrastructure project, I saw the opportunity to develop my own Python add-on as I was performing repetitive tasks in Blender. The below geometry came from the Epic marketplace and acts as a test scene for the plugin.
Intelligent Decimation
In Blender, the decimation modifier is used to reduce the triangle count of a mesh, whilst retaining it’s overall shape. I realised that the meshes with denser topologies needed more decimation than the ones with less dense topologies. I therefore used an equation that I created myself to predict the most suitable decimation ratio for each selected mesh.
The script works by dividing the number of vertices on a given mesh by it’s total surface area. This gives a factor for vertex density. Firstly I had to manually apply decimation to an array of different meshes in my scene so the triangle count was as low as possible, without introducing any abnormalities. I then plotted the vertex density against the decimation ratios that I had used in this small test array. Once I had found the equation of this trend line, I could then use it in my Python script, so I could predict new decimation ratios for any new mesh, based purely on it’s vertex density.
Core Functionality
This clip shows part of the add-ons functionality; many basic optimisation operations are applied to the entire scene i.e. welding verticies, merging similar objects to reduce draw calls and UV mapping.
There is also a batch tool feature where the add-on iterates through ‘n’ number of geometry files (e.g. .fbx) in a given folder. It imports each geometry file into a new Blender scene, then performs the basic optimisation operations and saves it. I then go into each Blender file to do any further optimisations as I see fit before exporting to Unreal via Datasmith.
Customisation
Should the artist feel like the predicted decimation ratio is too weak or strong, they have the ability to influence the equation by changing the ‘Ratio Offset’ parameter. This video clip shows how increasing the offset to 1.4 applies a weaker decimation to the selected meshes.
Batch Tool
When working on very large-scale projects such as stadiums, the plugin can iterate through a folder of geometry files applying a selection of desired procedures. This might include: welding vertices, UV mapping, applying placeholder materials, clearing smoothing groups, merging objects etc. Each file is then saved as a Blender file in a newly created sub-folder. A technician can then open each Blender file, applying any further optimisations and acting as a quality control.
This plugin aims to do most the heavy lifting, leaving the remainder for someone to make final adjustments before committing the geometry to a real-time engine. I don’t think Python could ever totally replace human intervention.