# Signed Distance Fields

Didn’t see much mention of this anywhere so, I wanted to make a thread. I’ll also mention this thread is mostly for the future, probably during the 0.9.x releases.

One of the advantages we will be getting with the introduction of Convolution Surfaces is the ability to use Signed Distance Fields (SDF) to influence the shape of stuff made with it. I wanted to make a thread educating about these since I think they will clear up a lot of questions of what can be done/what is possible.

What is a SDF?

A SDF is the math that forms some geometric shape by basically saying where in space it is, and where it is not. It uses distance from the surface to indicate it’s values in different grid sections, -1 and below is inside, 1 and above is outside, and 0 the surface. Decimals from -1 to 1 are usually the sections where we actually render anything, like voxels or pixels. If you invert it, the opposite is the case, and you get a negative field that takes chunks out of others.

This important because, it’s exactly what a metaball even is (each one is just math for a sphere.) The reason metaballs fuse together is when you go to render them, you add the values of the fields so that, you get grid sections where both metaballs effect the number, and sections where only one metaball has an effect.

Why are they important for 3D?

The algorithm we have decided on for years now has been the Convolution Surfaces algorithm, specifically SCALIS (find out more in the Convolution Surfaces thread.) What Convolution Surfaces does is very sophisticated, specifically rather than summing fields it uses a mathematical operation called Convolution.

The TL;DR of how it all works is basically you take two geometric shapes called skeletal elements, whether that’s a sphere around a point (what we will do) or some other field, and you smoothly blend them across some distance, repeating this for every relation along lines or curves that form the overall shape you want (the membrane or creature’s body in our case)

This means that in the context of Convolution Surfaces, you can use stuff other than a sphere. You could for example use a triangular shape like a cone or prism, and have it blend across a distance into a sphere, making a sort of beak shape or something. You could use ellipses and make really cool shapes like muscles with less work.

SDFs have lots of other use cases you can find online as well. The engine we use, Godot, will for example use SDFs in it’s lighting system for version 4.x. Another interesting use is that you can render SDFs directly. Basically, you can skip Convolution Surfaces and go straight to making triangles which can give you very defined shapes like in CAD software. This is also really fast since you aren’t calculating the smoothing and will probably be a huge part of how the tech editors will have to work.

Relevance for microbe

For now, the system for drawing microbes will be pretty simple. I have some functions for cool effects I made over the years like using the Voronoi Diagram of the mesh to make shell/armor chunks or drawing along the mesh connections rather than along the actual membrane’s Convolution Surfaces skeleton to form an organic cage shape. In the future though we will have tons of flexibility, maybe to make more elaborate Cell Walls or something so, I wanted to get some creative ideas flowing on this front.

Hopefully this was educational, if there are any questions, I will answer.

2 Likes

Reading through this, my mind goes immediately to weird cell shapes like those of dinoflagellates:

Me and Buckly have had some thoughts on revamped cell membranes that could correspond with the effects described here.

A side note: I always wondered if, somehow and someway, we could ever be in a spot where spiral bacteria and the such could feasibly be implemented in Thrive:

They by no means are necessary in Thrive - I think they would basically just benefit the variety of art we see in a Thrive playthrough - but these guys kind of represented the one thing I never dared to believe could be seen in Thrive due to how insignificant yet weird they are. I guess the same goes for bacteria which live in immense colonies, such as cyanobacteria, but more so for gameplay reasons; we operate under a philosophy of allowing the player to do whatever the AI can do and v.v., so that could be a deviation from our design tenants.

Part of how I will cluster hexes will involve building relations between chunks of a cell’s membrane dependent on rigidity. So, if there were a chain of relations that form a wave, you could identify that to generate a spiral.

In the king’s English: if hexes zig-zag the algorithm would know. You can say zig-zags are spirals.

1 Like

Thank you for the plebeian translation. Pretty cool stuff; it’s exciting to see how versatile the system could be. Hopefully a solution to the UV dilemma works itself out with ease soon!

1 Like

Actually, I think I figured out the UV thing. The commits I’ve been making to membrane_overhaul are rewrites to set myself up to try something. The way I was doing things before (when I kept everything local to my PC) made it very difficult to try anything useful / advanced.

1 Like