Fundamentals of Computational Engineering: Part 4 Implicits

By on October 13th, 2023 in Ideas, news

We will dive a bit into the technicalities of a Voxel-based kernel here, how do we interact with it?

Editorās note: Lin Kayser has written a series of stories introducing the new concept of Computational Engineering being developed by his new company, Leap71. This is a six-part series, with links below to all parts as they are published:

Fundamentals of Computational Engineering: Prologue
Fundamentals of Computational Engineering: Part 1 ā A Bit of History
Fundamentals of Computational Engineering: Part 2 ā The Technology
Fundamentals of Computational Engineering: Part 3 ā Voxels to the Rescue
Fundamentals of Computational Engineering: Part 4 Implicits
Fundamentals of Computational Engineering: Part 5 ā All You Need is a Few Functions

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!

The first 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.

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.

ChatGPT is a great source for these kinds of formulas, so instead of littering this article with them, you can just head over and ask:

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.

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.

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.

Editorās note: Lin Kayser has written a series of stories introducing the new concept of Computational Engineering being developed by his new company, Leap71. This is a six-part series, with links below to all parts as they are published:

Fundamentals of Computational Engineering: Prologue
Fundamentals of Computational Engineering: Part 1 ā A Bit of History
Fundamentals of Computational Engineering: Part 2 ā The Technology
Fundamentals of Computational Engineering: Part 3 ā Voxels to the Rescue
Fundamentals of Computational Engineering: Part 4 Implicits
Fundamentals of Computational Engineering: Part 5 ā All You Need is a Few Functions

Via Leap 71

By Lin Kayser

Lin Kayser is a serial entrepreneur who has built deep tech companies for the last 30 years. He has spent the last decade helping define the emerging field of Computational Engineering, where parts, structures and entire machines are created using sophisticated algorithms, ready for production with digital manufacturing technologies.