Simple hollow shell script
Disclaimer: The code in this post is written on version 9.0.7700 of Simplygon. If you encounter this post at a later stage, some of the API calls might have changed. However, the core concepts should still remain valid.
Overview
In this post we will show you how to create a simple python script that generates a hollow shell.
What is a Hollow Shell?
With Simplygon 9 we released a new feature which is based on the aggregation processor. We call the result from this process, a Hollow Shell. In cases where you can't use the remesher, as it requires new materials, the hollow shell can be used as a good alternative. The resulting object will have all the internal geometry removed, as with the remesher. It isn't affecting the exterior nor require you to create new material. You can combine this processor with the reducer if you want to also reduce the poly count for the exterior. Optionally, you can choose to merge all materials onto one atlas. The advantage of the aggregation processor is that it can use the chart aggregator, which uses the original charts and can keep overlapping UV's intact. Here is a video showing the resulting what the result looks like.
Cases where the Hollow Shell is useful
In cases where you are combining pieces to create larger objects, i.e. kitbashing workflows, the hollow shell can help reduce the internal geometry that isn't visible from the outisde. As the process doesn't affect the exterior geometry the resulting object can be used close to the camera.
It can also be used to simplify an object that you need the exterior of. For example, a complete car with engine and all other details that you don't need for an exterior representation.
What will we do?
We will create a python script that transform the object below to an object where the internal geometry is removed and the bottom of the object is clipped by the box.
This will be the result of the process.
In this specific case the object is reduced from 136k polys to 90k, without affecting the exterior of the object.
The script
Starting point
First we need to set up the skeleton of the script. This is the code for that:
Now we need to define the processing function, which is responsible for loading the file, initializing the processing and save out the result.
Setting up and running the aggregation processor
The run_hollow_shell function called in the above script will do the handle all the settings and also run the processor.
In order to trigger the geometry culling we need to set EnableGeometryCulling to true. Using the precision setting gives us a lever between 0 and 1 that balances amount of culled geometry and processing speed, where 1 will maximize the amount culled.
Since we want to clip the bottom of the object with the ground geometry we also need to tell the pipeline which geometry is what. This we will do in setup_clipping_geometry. If you don't need that part, feel free to just remove that line and skip the next section.
Sorting clipping and processing geometry
The final step is to create the function that sorts out which geometry should be processed and which should be used to clip with. How to decide what belongs to what set is up to you. In this simple example we rely on naming. Any object starting with "clipgeom" is assumed to be used for clipping the result.
Here is the function that sets up pipeline with the selection sets that decides what is what.
Finally, here is the naive function we use in this example to decide which objects should be used as clipping geometry.
Summary
This a simple script that allows you to create a cheap representation of kitbashed collection of objects. it can be helpful in many scenarios where you have a lot of geometry that is just there, but never visible to the spectator.
Here is the script in its entirety.