Creating Modular Curved Structures with Zero Floating Point Precision Loss

iiboharz

eternally tired
aa
Nov 5, 2014
857
1,291
NOTE: This tutorial assumes you have knowledge of instances, if you don't know what instances are, please read this article first.

Before I begin, I'd like to give a shout-out to Andrew Weldon who not only created this method, but also KOTH Roundhouse, a rather interesting KOTH map whose mid is completely comprised of curved sections made using this method.

HgXdkIY.jpg

Anyway, I suppose I should get on with the tutorial now..

Creating Modular Curved Structures with Zero Floating Point Precision Loss

So first of all, if you're not familiar with it, you may be asking, "what is floating point precision loss?" - to answer your question, the way brushes work is that all of their vertices refer to a point on the grid.

When these vertices start going off grid and then get transformed (moved, resized, rotated etc) in some way, they tend to start losing precision.

YvqsrYw.png

how floating point precision loss can look on the 3D and 2D view​

The two biggest reasons this is bad are that this may cause issues with VSBP during your compile, and brushes with floating point loss probably won't be able to seal your map.

If you'd like to know more, ask around the community.

Anyway, now that we've covered what floating point loss actually is, let's move onto the method we're going to use.

First, select the texture tools/toolsskip and draw two 2048x512 brushes opposite each other around the origin, like so, and then select them.

SZgPP9W.png

While your brushes are selected, press CTRL+M to open the transform dialogue, rotate them -7.5 degrees on the Z axis. Copy your rotated brushes, and then go to Edit > Paste Special and use these settings.

J7hlduo.png

With your rotated brushes duplicated, select the duplicated brushes and press CTRL+L, this will flip them horizontally.

vZm9TSW.png

Now select the two brushes on the right, delete them, and then clip off the excess of the other two along the origin. If you've followed all of these instructions, you should end up with something like this.

YAfFpmQ.png

Congratulations, you've successfully created brushes to clip your geometry with.

Now, within the space between these two brushes, create your geometry, do whatever you like. As an example I'm going to try and create a structure in a similar style to the ones on KOTH Roundhouse.

WOvjVCH.png

Once your structure is created, make sure it's lined up between the skip brushes to your liking. Once you're happy with the results, select one of the skip brushes and Carve (CTRL+SHIFT+C). Do this step again with the other skip brush.

(Note: This is one of the few instances that carving is okay!)

The sides of your creation will be chopped off and you should be left with a wedge like this.

4fpTLJM.png

Now save this wherever you keep your instances relative to your main map and close it.

Open your main map and with the entity tool, create a func_instance. Set the VMF filename to whatever you just created and it should appear. Rotate it 15 degrees around the origin of the func_instance and you should see your pieces line up perfectly!

gUfK9y7.png

That's all for this tutorial, however there's a few things to note:
  • All the numbers in this tutorial are interchangeable, for example, rotating the skip brushes 7.5 degrees, we do this because our intent is to rotate our pieces by 15 degrees. If you want to rotate your pieces by 10 degrees, you would rotate your skip brushes 5 degrees instead.
  • You should keep a copy of your unclipped instance geometry in-case you wish to make any changes.
  • Don't change any of your geometry after clipping as this could lead to floating point precision loss.
  • If you have any questions, feel free to ask.
I look forward to seeing what you create with this method!
 

henke37

aa
Sep 23, 2011
2,075
515
So clipping prevents precision loss?
 

phi

aa
Nov 6, 2011
832
1,815
So clipping prevents precision loss?

No.

Clipping won't create precision loss, you could easily lose precision after you clip. The mere act of clipping does not prevent this.

The reason there is no precision loss here is that there is no resizing or reshaping of the brushes after the carve. There's no actions which could cause hammer to truncate decimally valued vertices. That's why the line "You should keep a copy of your unclipped instance geometry in-case you wish to make any changes." is there, if you want to edit this geometry (the edges of it, at least) you must go back to the geometry before you carved.

I'm not talking hard mathematics here or anything, but as long as you don't give Hammer any reason to truncate decimals (resizing), it won't.
 

Izotope

Sourcerer
aa
May 13, 2013
698
764
No.

Clipping won't create precision loss, you could easily lose precision after you clip. The mere act of clipping does not prevent this.

The reason there is no precision loss here is that there is no resizing or reshaping of the brushes after the carve. There's no actions which could cause hammer to truncate decimally valued vertices. That's why the line "You should keep a copy of your unclipped instance geometry in-case you wish to make any changes." is there, if you want to edit this geometry (the edges of it, at least) you must go back to the geometry before you carved.

I'm not talking hard mathematics here or anything, but as long as you don't give Hammer any reason to truncate decimals (resizing), it won't.

I just learned something very useful, thanks!
I can now have off-grid geometry without hammer messing it up,
although I still prefer on-grid geometry over everything else any day.
Just the idea of more control against hammer makes me feel good. :psyduck:
 

Asd417

Sample Text
aa
Mar 20, 2016
1,451
1,031
I don't understand this. Every time I try this myself, the skip brush goes completely off-grid making it impossible to cut a structure with precision. Not a single point on gird meets the sides of the skip brushes. Instancing doesn't work. It simply shows the red box not the instance. For Portal 2, I simply had to put it in sdk_contents folder but it desn't exist in TF2? Also, flipping object doesn't work even though I focus on that object on 2d view. Can you help me?
 
Last edited:

Yrr

An Actual Deer
aa
Sep 20, 2015
1,308
2,743
What is the advantage of carving over using the clipping tool?
clipping tool is locked to the grid but carving with rotated brushes can let you do some stuff offgrid
 

Yrr

An Actual Deer
aa
Sep 20, 2015
1,308
2,743
not when youre trying to avoid floating point precision loss in a situation like this
 

sooshey

:3c
aa
Jan 7, 2015
514
410
The main issue here is the vertices aren't aligned with each other. Who cares if they're on the grid or not, if they're not aligned with each other then there will be gaps and therefore possible leaks.
 

sooshey

:3c
aa
Jan 7, 2015
514
410
Well, even if their job isn't to seal the map, they'll still cause issues with vbsp like iibo mentioned in the OP. Tiny cracks will still cause tiny visleaves to form and that's bad news for optimization.
 

iiboharz

eternally tired
aa
Nov 5, 2014
857
1,291
You're only really gonna get floating point loss if you're messing with the verts after they're been taken off grid. That's why you want to save an un-cut version of your thingy so that you can edit it later and re-cut to make changes.