Software packages that perform 3d print job preparation usually import parts in the industry standard .stl format (triangles with coordinates in XYZ forming a triangle mesh) and output a file or a set of files that a 3d printer can understand. Most machines require a file that has a "per layer" instruction of what to print. The process of going from a 3d triangle mesh to a collection of 2D layer instructions (slices) is called 'slicing'. The output from a slicer algorithm is usually one of two flavours:
Figure 1: Pixel versus vector based slices
This article will explain two different slicing techniques that are used in slicing software nowadays. What usage applications they are best for and how this all impacts slicing speed and quality. It is based on our experience with Formware 3D and after 3 years of improvements in slicing algorithms.
The first method is used by a lot of slicing software in the market and slices your triangle meshes on the CPU (Your computer's processor). That is, all the calculations happen mostly on the CPU. The algorithm to generate 1 slice is roughly as follows:
At least steps 1-4 are performed all on your CPU. Optionally step 5 as well. We've summarized the steps in the figure below:
Figure 2: Slicing geometry on the CPU
The alternative slicing technique is to let the GPU (your graphics card) do a lot of the heavy lifting. The limitation of slicing on the GPU is that it creates a pixel based output only. A detailed explanation goes to far for this article but the algorithm for generating the slices is roughly the following:
Figure 3: Slicing geometry on the GPU
Now we know what the two main methods are in slicing technology we can look at where the challenges are and how these methods cope with them. The challenges can be roughly categorized as follows:
We will now compare how both slicing techniques handle these specific challenges and why they might be good or bad.
There can be many different errors in your mesh. For this article it's best to categorize them into 'holes' and 'small artifacts'. Where holes are larger unclosed triangle surfaces in your mesh and small artifacts all other small errors in your mesh (double triangles, degenerate triangles, non-manifold edges, etc.). The CPU slicing method has to loop through each of the triangles and sort out all calculated line segments into closed polygon's. One can imagine that coping with all sorts of small artifacts in your triangles is a very difficult task to do right. However, closing a single hole might be easier to fix by just adding a missing line segment.
When we look at the GPU technique we know that it doesn't care whether there are small artifacts at all. It draws all the triangles mostly simultaneously on the pixel buffer. The only problem in the GPU technique is if there are any horizontal holes in the mesh. Horizontal holes will invalidate the counting of the upward and downward facing triangles. Hence area's might show in your slices where the slicer still thinks it is inside a part where it is actually not.
Next we look at the slicing many triangles. This can either be multiple meshes or one very big mesh. For the GPU that doesn't really matter. By hardware design a GPU is build to do all calculations in parallel. Millions of triangles are processed with ease at an almost constant speed. As a matter of fact it costs often just as much time to transfer the pixel data back to the computer memory (RAM) as it costs to draw all triangles onto the pixel buffer. This is also the reason that when you are slicing a small part (few triangles only) you still experience some processing time with GPU based slicing. The entire pixel buffer has to be transferred from GPU to RAM. This transfer time is independent of whether there are cross sections drawn or not.
A CPU is build to do most of its calculations in serie. One after the other, as fast as possible. When we think of slicing millions of triangles on the CPU it is not hard to imagine that processing all triangles one after the other it might easily be much much slower than in parallel. Even when using multiple cores and multiple threads in your slicing software.
The third challenge a modern day slicer has is to handle large pixel based outputs. Some printers in the marketplace print on resolutions up to 8000 x 8000 pixels. This has consequences for all algorithms creating these slices. Luckily a modern GPU is usually equipped by enough memory to handle these large slices before the pixel data is being transferred over to the computer memory for storage. Creating these large slices with a CPU slicing algorithm will have impacts on your 2D drawing and filling operations of your contours. In our experience not all available drawing libraries are suitable and stable enough to do this.
Last but not least when using a pixel based output for your printer you preferably want to have smooth edges of your cross sections. When slicing on the GPU you can use the highly optimized anti aliasing algorithms developed and perfected for the gaming industry. With a CPU based method the pixel data is potentially generated on the CPU as well. This may limit the anti aliasing result. Mostly however there are fast algorithms available for anti aliasing on the CPU as well. Needless to say, they won’t work in a parallel manner like on the GPU.
We've talked in this article about two different methods of slicing 3D geometry into 2D layers. There are pro's and con's to each method that we can summarize in a table below.
CPU | GPU | |
---|---|---|
Ability to fix errors | Can handle holes easily. Lots of artifacts are problematic. | Can handle lots of artifacts easily. Horizontal holes are problematic. |
Handling large amounts of triangles | Processes serial. Very slow with lots of triangles/parts. Very fast with small parts. | Processes parallel. Much faster to process lots of triangles/parts. Has a small startup cost when processing small parts. |
Creating large slices in pixels | Has consequences for the 2D Drawing/filling algorithms | Most GPU's can easily draw 8000x8000 pixels |
Smooth edges | Dependent on how well 2D Drawing algorithm smooth edges | Perfect anti aliasing build in already |
Now we know the differences it is easier to see why slicing on the GPU can have significant advantages in an industrial environment where a pixel based output is required. It is faster when there are lots of parts to be printed. If one knows that the parts contain no errors it is most certainly the best method to slice. Additionally it allows for advanced anti aliasing algorithms and can be easily scaled to high pixel outputs.
Formware 3D is a software package primarily build for pixel based 3d printers. These are mostly resin and inkjet based machines. As such it has a very robust GPU based slicing algorithm tested on different GPU’s. Over time we developed CPU based slicing algorithms as well and it can currently also slice on the CPU and export .SLC and .GCode formats to work with vector based machines.