Creating Modular Curved Structures with Zero Floating Point Precision Loss

Discussion in 'Tutorials & Resources' started by iiboharz, Feb 24, 2016.

  1. iiboharz

    aa iiboharz Meme Queen

    Messages:
    728
    Positive Ratings:
    1,061
    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.

    [​IMG]
    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.

    [​IMG]
    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.

    [​IMG]

    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.

    [​IMG]

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

    [​IMG]

    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.

    [​IMG]

    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.

    [​IMG]

    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.

    [​IMG]

    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!

    [​IMG]

    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!
     
    • Thanks Thanks x 7
    • Useful Useful x 5
  2. henke37

    aa henke37

    Messages:
    1,947
    Positive Ratings:
    462
    So clipping prevents precision loss?
     
  3. phi

    aa phi Let Pain Be Your Guide

    Messages:
    805
    Positive Ratings:
    1,651
    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.
     
    • Agree Agree x 4
    • Thanks Thanks x 1
  4. sevin

    aa sevin

    Messages:
    959
    Positive Ratings:
    686
    I would have never figured this out because I have been trained to only touch carve if I am ready to die. Bookmarked!
     
    • Like Like x 1
  5. Izotope

    aa Izotope Never releases maps

    Messages:
    626
    Positive Ratings:
    599
    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:
     
  6. Hyperion

    aa Hyperion L16: Grid Member

    Messages:
    810
    Positive Ratings:
    618
    5th picture reminds me a lot about DNA
     
  7. Asd417

    aa Asd417 L1: Registered

    Messages:
    919
    Positive Ratings:
    628
    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: May 4, 2016
  8. Mikroscopic

    aa Mikroscopic

    Messages:
    615
    Positive Ratings:
    630
    What is the advantage of carving over using the clipping tool?
     
  9. Yrr

    aa Yrr An Actual Deer

    Messages:
    1,037
    Positive Ratings:
    2,039
    clipping tool is locked to the grid but carving with rotated brushes can let you do some stuff offgrid
     
  10. Mikroscopic

    aa Mikroscopic

    Messages:
    615
    Positive Ratings:
    630
    But don't you want to make sure stuff doesn't go offgrid?
     
  11. Yrr

    aa Yrr An Actual Deer

    Messages:
    1,037
    Positive Ratings:
    2,039
    not when youre trying to avoid floating point precision loss in a situation like this
     
  12. Mikroscopic

    aa Mikroscopic

    Messages:
    615
    Positive Ratings:
    630
    Okay now I'm more confused. Isn't precision loss caused by having vertices that aren't aligned with the 1hu grid? I fail to see how this method prevents that.
     
  13. sooshey

    aa sooshey :3c

    Messages:
    522
    Positive Ratings:
    418
    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.
     
    • Thanks Thanks x 1
  14. Mikroscopic

    aa Mikroscopic

    Messages:
    615
    Positive Ratings:
    630
    Oh! That's a much better explanation. So then, this isn't an issue with brushes that aren't intended to seal the map?
     
  15. sooshey

    aa sooshey :3c

    Messages:
    522
    Positive Ratings:
    418
    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.
     
    • Thanks Thanks x 1
  16. iiboharz

    aa iiboharz Meme Queen

    Messages:
    728
    Positive Ratings:
    1,061
    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.
     
  17. Asd417

    aa Asd417 L1: Registered

    Messages:
    919
    Positive Ratings:
    628
    nvm figured out how to make this work without instances.