Tutorial: Tetrahedron Terrain Last edited 1 year ago2022-09-01 12:29:38 UTC

Download attachment

For this tutorial, I'll be assuming you have:

Tetrahedron

"Tetrahedron" is a more elaborate name for three-sided pyramid, which is known as the most primitive three-dimensional shape possible. Unlike a wedge with six vertices and five faces, it only has four vertices and four faces.
A tetrahedronA tetrahedron

Tetrahedron Terrain

The most common complex terrain method used in GoldSource mapping, usually called "Triangle terrain", involves manipulating the vertices of wedges to produce more complex surfaces with minimal risk of creating invalid solids (don't say I haven't told you to read that tutorial on terrain.. ;> ). This method, even if visually superior to any other method(s), always ends up choking your level with huge wpoly/clipnode/leaf counts, making it nearly impossible to use in multiplayer maps where terrain plays a bigger role.

Tetrahedron terrain is pretty much the same above mentioned technique with a single twist: Tetrahedrons instead of wedges. Tetrahedrons are triangular shapes, therefore can be used to form the same squares of triangles you'd make from wedges and have the same flexibility when it comes to Vertex Manipulation. Most importantly, however, using them instead of wedges will usually cut down wpoly/clipnode/leaf counts by 20-30%.

The main reason behind this is that tetrahedrons in terrain have only three edges touching their surrounding objects, whereas wedges have six. This reduces unnecessary face-splitting done by the compile tools, thus decreasing the aforementioned figures.

Getting Started

Convinced in giving this a go? Start by opening Hammer and creating a wedge of any size (I'd suggest using standard dividable-by-16 dimensions, though) and texturing it all with the BEVEL texture (ZHLT.wad). In the example, I used 96x96x16. BEVEL is extremely important there, as it tells the compile tools to completely discard the faces it's applied to during the process. That does a great deal in reducing face-splitting.
Wedge.. Period.Wedge.. Period.
Select your newly created shape and go into Vertex Manipulation mode. Then select each bottom vertice one-by-one and move it to one point in the center of the shape. Merge vertices when prompted.
Merging vertices..Merging vertices..
Now you have a nice clean tetrahedron! Apply your texture of choice to its top face. Select and drag it in top view, while holding Shift to clone the shape. Finally, rotate the clone by 180° and fit it to the existing triangle to form a square of two tetrahedrons.
Your very own tetrahedron square!Your very own tetrahedron square!
Clone the square as many times as you want (like you usually would when making triangle terrain) and you'll have yourself a VM-ready triangle field, ready to be transformed into your most low-poly terrain yet.
Ready to rock.Ready to rock.
Do read the next section before rushing off to VMing, as it covers some..

Precautions to take

Sadly, as pretty much every technique for terrain in GldSrc, this one definitely has its downsides & problems..

First of all, a VMed field of tetrahedrons will probably be the dirtiest thing you'll ever see in Hammer's perspective views, making everything fairly indistinguishable there. In this case, VIS Groups are your best friend and should certainly be utilised in bigger maps.
A medium-sized tetrahedron terrain area in Hammer's side/front views. Call it modern art - I say it's a bloody mess!A medium-sized tetrahedron terrain area in Hammer's side/front views. Call it modern art - I say it's a bloody mess!
Second, when manipulating tetrahedrons, always keep track of the center vertex, sticking out to the void/outside area. Chances are, it may end up inverted, creating concave brushes, which produce "Entity/Brush outside world" errors in CSG. Always check for problems in Hammer (Alt+P) to at least partly avoid that (you'll still have to run CSG to find every concave brush, though).
Keep your eye on this vertex...Keep your eye on this vertex...
You may also encounter clipping problems in-game, ranging from simple invisible barriers to your player falling through the triangle seams into the void. The "-cliptype precise" command for CSG plus using the BEVEL texture as described earlier seem to usually fix both problems.

And finally, since each tetrahedron side is joined with the other by only one edge, LEAKs may occur in more complex terrain. I haven't run into that problem myself yet, though I believe shifting vertices in the X/Y axis (Top view) may cause that, so to avoid bigger problems, perform LEAK-only BSP checks regularly.

Conclusion

So, as you see, this technique, albeit providing better performance, may cause bugs even if handled properly and is generally much harder to work with.

To sum it all up, I'd say don't be bothered with tetrahedrons unless you really need to reduce wpoly/clipnode counts and any other optimisation methods you try fail. Stick to triangles when you can.

Check out the example maps for a better idea/example on how this works. Good luck! :>

6 Comments

Commented 15 years ago2008-06-01 18:34:02 UTC Comment #100861
Heh Excellent!

I like that you included common pitfalls as many times these are conveniently left out. ;)

You should add a nice screenie of some sexy finished terrain!

"The "-cliptype precise" command for CSG plus using the BEVEL texture as described earlier seem to usually fix both problems."

You can also make sticky areas func_illusionary, and place more simple terrain over/inside it with clip brush. (this also saves you on the preposterous clipnodes this type of terrain uses up = ) )

Nice tutorial with pictures and well-written = win = 5 stars.

)

Commented 15 years ago2008-06-03 00:08:42 UTC Comment #100862
I use the same technique for cliffs. It is very good if you are trying to make something very complex. I find it much more convenient to use tetrahedrons than simple triangles. Mostly because it's much easier to make valid shapes out of them.

Anyways good tutorial.

P.S I agree with Captain Terror, you could have added a sexy-compiled-terrain-image. :-)
Commented 15 years ago2008-06-03 00:30:14 UTC Comment #100863
Heh, so I'm not the only one who started using this. Weird it's never been documented before.. :o

As for screenies - I really don't have anything I can show off. Example maps show the effect right, though aren't that sexy.
Commented 15 years ago2008-06-04 09:56:52 UTC Comment #100864
Yeah, i have never seen a tutorial about this. I myself have been using this technique for quite a long time. "Discovered" it by accident. :-D
Commented 10 years ago2013-11-09 06:38:42 UTC Comment #100865
Hello, I'd like to comment on this:

quote start

Most importantly, however, using them instead of wedges will usually cut down wpoly/clipnode/leaf counts by 20-30%.

quote end

I checked out your test maps with RipEnt and in-game, and most of your claims appear to be false.

First of all, the clipnode and (world)leaf counts aren't lower at all when using tetrahedrons instead of triangular prisms -- they're higher.
http://i.imgur.com/NKYmppj.png

The wpoly count is slightly better when using tetrahedrons though, I'll give you that.
Summary of most important findings:
http://i.imgur.com/Jlchjb6.png

I would like to advise everybody to stick to good ol' triangular prisms ( http://i.imgur.com/Vv4CiCx.png ). The slightly higher wpoly count can easily be optimized by using VHLT's "SOLIDHINT" texture anyway.
Commented 3 years ago2020-11-25 23:13:53 UTC Comment #103091
If you make tetra terrain have fun solving the clipping issues where you fall through gaps in the floor. Also if you make them func_detail then the backside of the terrain wastes other resources too like clipnodes and worldleaves

You must log in to post a comment. You can login or register a new account.