What You Need to Know Before You Try The Spirit Bares Its Teeth
The Spirit Bares Its Teeth is a technique used in procedural content generation, specifically when dealing with organic shape interpolation and topology drift in generated meshes. It sounds more dramatic than it is. In practice, it is a post-processing pass that detects when a generated form has started to collapse into degenerate geometry and applies a corrective redistribution of vertex density. I started running into this around 2019, working on a terrain generation pipeline for a medium-budget RPG. We were using a standard Perlin noise heightmap with adaptive subdivision. The issue was that once the noise function hit certain frequency thresholds, the mesh would start producing long, thin spikes along the ridgelines. These spikes looked fine at first from a distance, but they caused massive issues downstream in the physics system. Triangles with aspect ratios over 15:1 are practically unusable for collision detection, and our character controller kept clipping through the ground on steep slopes. That is where The Spirit Bares Its Teeth comes in. Instead of trying to prevent the spikes from forming, which most people attempt and mostly fail at, you let them generate and then run the correction pass.
How The Spirit Bares Its Teeth Actually Works
The process has three phases. First, the mesh is scanned for degenerate or near-degenerate triangles. You calculate the edge length ratio for every triangle in the mesh. Any triangle where the longest edge exceeds the shortest edge by a factor greater than a set threshold gets flagged. Second, the flagged vertices are identified as part of a structural problem. Third, those vertices get repositioned based on a relaxation algorithm, usually mean-value coordinates or barycentric smoothing weighted by the local triangle quality. The threshold value is where most people go wrong. A common default is 12, but that is too aggressive for most use cases. I settled on 8.5 after running comparative tests across five different terrain types. Below 8, you start removing legitimate detail. Above 10, the spikes survive the pass and cause problems later. The exact sweet spot depends on your mesh resolution and how much detail your engine can handle before frame rate degrades. Here is a concrete example of the implementation. You loop through your triangle list, compute the normalized edge lengths for each triangle, store the ratio, then pass all flagged vertices into a relaxation step. The relaxation step typically runs two to three iterations. More than three and you start losing meaningful topographical features. Fewer than two and the correction is incomplete. This whole pass on a mesh of roughly 500,000 triangles takes about 12 milliseconds on a mid-range CPU. On GPU it is under 2 milliseconds, but you need to be careful about readback latency if you are running this every frame.
The trick that nobody writes about is handling the boundary vertices. If your mesh has fixed boundaries, like the edges of a terrain tile, running relaxation on those vertices will pull them inward and distort the tile edges. You need to exclude boundary vertices from the relaxation step entirely. Mark them during the initial scan phase and skip them in both the flagging and relaxation stages. This took me about six hours to figure out properly because the boundary artifacts looked subtle at first but caused visible seams between adjacent tiles. Once I added the boundary exclusion, the seams disappeared completely. There are downsides to be aware of. This technique does not work well on highly anisotropic surfaces where the geometry is intentionally stretched in one direction, like a cliff face or a vertical wall. The algorithm will interpret the natural elongation of the triangles as degeneracy and try to flatten them out, which ruins the visual detail. In those cases, you need to apply a directional mask that tells the pass which areas to ignore. Without that mask, you will end up with flattened cliffs that look like they were generated by a low-resolution heightmap. It also adds computational overhead to your pipeline, so if you are already pushing the limits of your geometry budget, running this pass every frame may not be viable. For static meshes, baking the correction into the final geometry at load time is usually sufficient and avoids the runtime cost entirely. If your use case is simpler and you do not need the level of control this method provides, a basic Laplacian smoothing pass with a conservative step size might do the job. It will not catch the same edge cases, but it is faster to implement and requires less tuning. I recommend starting there unless you have the specific spike and degeneracy problems that The Spirit Bares Its Teeth is designed to solve.
Get the Full Details
_N658NK.jpg/220px-Spirit_Airlines_Airbus_A321-231(WL)_N658NK.jpg)