Fundamentals of Computational Engineering: Part 4 — Implicits
By Lin Kayser
Published October 13, 2023

This is a series of articles originally published at Fabbaloo

We will dive a bit into the technicalities of a Voxel-based kernel here, how do we interact with it? What functions do we require in order to support Tier 2, the abstract shape kernel, which is where most of the more complex geometric work is being done. None of the technical or mathematical details here are absolutely essential for your work as a Computational Engineer, but to understand the foundation, it’s a good idea to grab your favorite hot drink and sit down in a quiet place. Let’s dive in!

Want to build objects like these? Read on! Photo courtesy of Fraunhofer IGCV/LEAP 71

The first kinds function that you would assume we add, is a way of setting a voxel in the voxel field. After all, this is what we want to do, something like SetVoxel(xyz), would add matter to the voxel field at the coordinate xyz. But, even at the lowest tier, this is not how we are going to interact with the voxel field. The reason is, that our voxels are not quite as simple, as I described in the previous article.

Our voxel field actually describes its content using what is called a narrow-band signed distance field (SDF). Instead of storing just a simple on/off value, we actually store the distance to the boundary of the voxels that contain matter, the surface of the voxel field (called the “isosurface“). The reasons take a bit of time to explain, so we will skip it for this article. The long story short is, if we added a SetVoxel function, that turns a voxel on or off, it would either have to be a bit on the complex side, and therefore slow, or it would mess up our nice narrow-band signed distance field. If you want to dive deep into this topic, here is a research paper from 2006, that describes the fundamentals quite well.

Slice through a voxel geometry, stored as signed distance field. Gray is outside, white is the surface, green is inside. Note the distance which is encoded as shades within a narrow band around the surface. So our voxels are not just on or off, but actually a bit more expressive.

Fortunately. it turns out, we actually don’t need to set individual volumetric elements, because we will interact with the voxel field in a different way, on a higher level.

One way to create matter in a voxel field is to render a so-called implicit function.

What are implict functions? They are formulas, which mathematically describe the distance to the surface of an object. As such, they are a beautiful fit for our “narrow-band signed distance field”, which make up our voxels.

It turns out you can create a lot of geometric figures, infill patterns and other useful things very elegantly using implicit functions. Some of the easiest things they can describe are spheres and cylinders. So, implicts are great for lattices, as well as formula-based infills, and that’s where they are used a lot. But you could do much more, if you are mathematically inclined. There is an absolutely mind-blowing website created by computer graphics wizard Inigo Quilez, which has a live showcase of implict formulas (https://www.shadertoy.com/user/iq). Everything you see on that site is created mathematically using these building blocks.

The beauty of implicits is that you can just evaluate them for a point in space (xyz), and they will always return a result. So they are infinitely precise, extremely robust, and even simple formulas can create very complex and interesting results.

One formula that is used constantly, is of course the famous gyroid function, which creates a triply periodic minimal surface, that has almost become synonymous with 3D printed parts. One of the people who realized early how powerful implicits are for representing geometry was Bradley Rothenberg, who founded the company nTopology (now nTop) around the concept. He called it field-driven design, and the approach has significantly influenced the 3D printing industry in the past couple of years. It is one very powerful approach to computational geometry.

A cube filled with an implicit gyroid (this will be the last gyroid you will see in these articles, they are cool, but over-used)

So it is quite essential for a geometry kernel to be able to render implicits, because lattices and formula-driven geometry, such as infills, are critical to many applications.

Fortunately it’s not hard, because all you have to do is set the voxel to the value of an implicit formula evaluated at the voxel’s coordinate. The function gives us a negative value, if we inside the surface, a value of zero, if we are on the surface, and a positive value, if we are outside.

Thank you Pythagoras. In other words, we calculate the distance to the center of a sphere, and then subtract the radius, which will give us negative values, as long as we are inside the sphere, positive values, whenever we are beyond the radius, and zero, for a voxel that is exactly on the surface.

A sphere, rendered into voxels from the above function.

While you are at it, you might even ask ChatGPT for the code to create a signed distance field in your programming language of choice, and you can start writing your own kernel! The mathematical and logical concepts have been known for a really long time, and it’s easy to create boilerplate code using the ChatGPT Large Language Model (LLM), which was trained on millions of publicly available Github repositories.

However, while implicits are great for generating mathematical shapes, it is not so trivial to create more advanced geometries directly with signed distance formulas. Imagine coming up with the math to accurately describe the three-dimensional distance to a relatively straightforward object, say, as a cogwheel. Even if you are mathematically talented (and a cogwheel is quite mathematical), you would require a lot of thinking to design the object in one formula. So unless you are the next Einstein, we will use implicits for what they are good for: formulas that are very simple and straightforward (and ChatGPT-able).

If you have a voxel field, you can always go back to cylinders and spheres and use them as a paint brush to draw other shapes. That’s the beauty of rendering them into voxels. You don’t have to create everything at once in a hyper formula. You can pick your battles and work as an engineer and not as a mathematician.

The famous Hyperganic Aerospike rocket engine that Josefine Lissner created in 2022 was designed using this paradigm. Of course it takes a powerful algorithm that wields the paintbrush, drawing voxels into space. Foto courtesy of AMCM. Printed in 800mm in copper using AMCM 4K.

So, by just being able to evaluate signed distance functions, we have created the foundation for generating some of the most complex geometries you have seen in 3D printing. In fact, you could draw every object known to man, by placing tiny little implicit spheres at the right points. This is the equivalent of the SetVoxel function we talked about earlier.

But there are easier ways, which I am going to talk about the next article.

Feel free to head over to X to discuss.

Next article: Part 5 — All you need is a few functions