[Tutorial] Displacements

Discussion in 'Tutorials & Resources' started by Nutomic, Dec 31, 2009.

  1. Nutomic

    Nutomic L11: Posh Member

    Messages:
    888
    Positive Ratings:
    177
    This is my first tutorial, about displacements in hammer, how they work, and what can be done with them.
    This is a large topic, so prepare for a long read.

    1. Displacement Tools

    [​IMG]
    1 Select: standard tool to select faces, just as you normally do. To select multiple faces, hold strg while selecting.
    2 Create: Turns all selected faces into displacements. When pressing, hammer asks you for the "power". The higher the power, the higher the number of nodes. 3 is standard, but you should try too keep it as low as possible for performance reasons. Displacements with a power of 4 can also cause problems with sticky bombs, so better dont use that (thanks littleedge)
    3 Destroy: Turns all selected displacements back into world brushes.
    4 Subdivide: Divides each big face into smaller parts, making it smoother and rounder. Further information can be read here (thanks to Nerdboy)
    5 Noise: Raises and lowers each vertex of the displacement by a random value between the min and max values.
    6 Sew: Connects the selected displacements to prevent gaps. For this to work, the base brushes of both displacements must share an edge. The displacements must either have the same length of that edge, or one must be exactly half the lenghth of the other. Displacements can not only be sewn with each other, but also with world brushes and even brush entities.
    7 Paint Geometry:
    [​IMG]
    Effect: Raise/Lower: Move points up or down by the specified value with each click.
    Raise to: Rises the current point exactly to the specified height.
    Smooth: Removes hard edges of the displacement. you will probably have to set the raduis higher to see a result.
    Spatial: If selected, changes apply to all points within the radius, the stronger the nearer they are to the center.
    If it is disabled, changes only apply to the currnetly active point.
    Brush: to do: While testing, i didnt find any differences between soft-edge and hard-edge, probably doesnt do anything. If you know what it does, let me know.
    Distance: The distance a single click changes the height (raise/lower), or the height the displacement is set to (Raise to).
    In smooth mode, a lower value seems to mean more change with each click, while a high value lets the height only change by a few units.
    Radius: The radius changes should apply to.
    Suto sew: sews the selected displacements after each change, useful to avoid gaps.
    8 Paint Alpha:
    [​IMG]
    Effect: Same as in paint geometry.
    Type: Probably for textures with more than one alpha channel, though i could not test this.
    Brush: The site of the area to edit, 1 means only the actual vertex gets edited, 3 would change all vertexes within a range of 3.
    Value: Basically the same as in paint geometry.
    9 Invert Alpha: Turns the alpha channel around, 0 becomes 255 and 255 becomes 0, same for values in between, so 25 would become 230.


    2. Creating Displacement Ground

    Imagine we have this area, and want the nodrawed space filled with displacements (dont do it like i did, and place everything off the grid...):
    [​IMG]

    Here are a few examples of possible solutions:
    [​IMG]

    As you can see, theres a really high number of vertexes, because the displacements are small and the power is high. In almost all cases, you will
    not need so many vertexes, and this has a really bad effect on performance. You can also see parts of displacements sticking out of the map.
    [​IMG]

    If we have a look on the 2d overview, we can see how the displacements are in a nice raster (and that i forgot one). It might look good from here, but is the worst case you can have. More than half of all displacements are hidden under brushes, but still being rendered.
    [​IMG]

    Here, we have a lower displacement scale, and also bigger displacements, which should work perfectly, if your displacements are rather flat.
    [​IMG]

    As we cen see on the overview, theres still much of the displacements hidden under geometry, thus being rendered, without any benefit.
    [​IMG]

    You will immediately see one difference in this version: the displacements aren't straight on the grid any more, but the corners have been dragged around.
    [​IMG]

    Looking at the 2d image, we see that there is almost no displacement surface hidden under a brush, and thus, useless.
    The method used to create this is vertex editing. If you dont know what that is, here' a tut:
    http://developer.valvesoftware.com/wiki/Hammer_Vertex_Tool

    The idea is, that the corners of the displacements are at the same positions as the corners of your walls, so no part of a displacement is hidden underneath walls.

    We start with a single brush where we want our ground. Turn the top site into a displacement, power of 2 should be okay. Give it a ground texture, and go into vertex editing mode.
    It should now look somewhat like this:
    [​IMG]

    Now we try to move the corners of this displacement so, that they are at the same position as the corners of what is surrounding your displacements, for example buildings, or rock walls.
    [​IMG]

    The displacements dont always perfectly fit when only aligning them by the corners, thats where we can divide one edge up into 2:
    [​IMG]
    You only have to make sure, that the corners are exactly at the middle at the middle of the other displacements edge, or they wont sew.

    Sometimes, you cant do it that way without getting really small displacements:
    [​IMG]
    But you should try to keep the hidden part of the displacement as small as possible, to not give away anything, and to prevent possible shadow errors.

    Now we just put displacements over your whole area, starting from the outside, going towards the center. The easiest way to work with them is to group all displacements in an area, that should sew together, and just edit them with all being selected.

    3. Caves

    For caves, you want to place the displacements, just like you would place normal brushes: Make a displacement for every wall, floor and ceiling. Be sure that they always share an edge, so you can sew them properly. To avoid leaks, you have to place another set of brushes directly behind the displacements, all world brushes, and textured in tools/toolsnodraw.

    You can then just select just the walls and the ceiling (not the floor, picture is wrong here), subdivide it, and you already have round edges. Then drag them around until you have what you want, and dont forget to sew everything at the end.
    [​IMG]
    [​IMG]
    [​IMG]


    4. Other utilizations of displacements

    Displacements can not only be used to create rocks and ground. For example, you want a smooth round corner. With brushes, you need at least 8 of them to make it look good. Using displacements, you only need 2. Heres how:
    Take a brush, make two sides of it displacements, and select both. Now put a copy of both brushes above them, and one underneath (we need the copies, because hammer would not subdivide them regularly without them). Select all displacements, subdivide them, and delete the copies above and below the original brush.

    [​IMG]
    The steps, from left to right.

    Another way for making round corners is shown http://www.snarkpit.net/snarkpower/articles/game/cat/pn/tp/146/Texture_alignment_through_arches_using_displacement_maps, applying it vertically (thanks to grazr). This will give you a cleaner result, but will also take more time to be created. Its your decision, what you want to use.

    Another example would be wooden structures, making them look more interesting. Heres an example, how valve did it in 2fort:
    [​IMG]

    If you have brush fences in your map, displacements can be used to make them look more interesting, like here:
    [​IMG]

    You can also use displacements for roofs, making them less flat, and providing another advantage: You can put tools/toolsskybox brushes directly above your buildings, while the displacement roofs are still being rendered. Valve uses this in badlands, where it doesnt have much room to place brushes for vis-blocking.
    [​IMG]
    If that roof was a world brush, it would not be rendered where the skybox textured brush is, leaving an ugly gap where you could see the sky through.


    5. Useful shortcuts

    shift + a opens the face edit sheet.

    You can change the radius in the paint geometry tool by holding alt + mouse1, and moving your mouse forward or back.

    While holding shift + mouse1, you can move displacement points up or down according to how far you move your mouse back or forward.

    With alt + mouse2, you can change the angle to that of the currently active point.

    6. Additional Information

    http://forums.tf2maps.net/showthread.php?t=111
    http://forums.tf2maps.net/showthread.php?t=798
    http://developer.valvesoftware.com/wiki/Displacement
    http://developer.valvesoftware.com/wiki/Hammer_Face_Edit_Disps

    Download of the example map
     
    • Thanks Thanks x 31
    Last edited: Jan 1, 2010
  2. The Political Gamer

    aa The Political Gamer

    Messages:
    4,468
    Positive Ratings:
    1,682
    +1 Thanks

    This goes hand in hand with Youme's tutorial perfectly.
     
  3. littleedge

    aa littleedge L1111: Clipping Guru

    Messages:
    983
    Positive Ratings:
    573
    You missed telling us what Subdivide did at the beginning.

    Caves: Do not make four brushes in the form of a box and subdivide. That is a terrible way to make displacement caves. That makes unrealistic ones - caves aren't tubes.

    You should work on your grid. You show plenty of examples of placing brushes off the grid.

    You DO NOT have to make your displacement ground line up with your displacement walls. In your example, you should simply have your walls be 8 or so units under the displacements. There is no reason to go through the hassle of making your ground displacements sew with your walls. The only time you do this is for the TOP. Let's use Furnace as an example. You know the canyons outside of BLU spawn that you take to get to A and B? The ground and the walls are not sewn - they are a few units beneath, and the ground goes through the displacement walls. The ground ABOVE the walls is sewn because you have no way to hide the displacements.
     
  4. keithgarry

    keithgarry L2: Junior Member

    Messages:
    59
    Positive Ratings:
    8
    You don't have to bite his head off. He obviously put a lot of time and effort into this.

    Thanks Nutomic. I learned something from that last bit about the skybox and displacement.
     
  5. littleedge

    aa littleedge L1111: Clipping Guru

    Messages:
    983
    Positive Ratings:
    573
    I didn't mean to bite his head off.

    It is a nice tutorial. The bottom section was the best. Displacements don't have to be used for outside areas only, and not enough people use them to their advantage. Nutomic did well. I just wanted to give him feedback, and oftentimes my feedback is aggressive, which I apologize for.
     
  6. VelvetFistIronGlove

    aa VelvetFistIronGlove

    Messages:
    567
    Positive Ratings:
    437
    Displacements are actually pretty cheap to render, so having a lot of power 3 or 4 disps is probably not a problem if your map has well optimised vis. (of course, if in doubt, use showbudget to check).
     
  7. littleedge

    aa littleedge L1111: Clipping Guru

    Messages:
    983
    Positive Ratings:
    573
    Power 4 displacements can cause problems when used in conjunction with sticky bombs, though. So it's best to stay at 3 or 2.
     
    • Thanks Thanks x 1
  8. Nutomic

    Nutomic L11: Posh Member

    Messages:
    888
    Positive Ratings:
    177
    Thanks, i will see how i can change that :)

    Sure, but you should only use a high power if you really need it, if not, you should stay as low as possible.
     
  9. Acumen

    aa Acumen Annoyer

    Messages:
    704
    Positive Ratings:
    594
    since you showed examples where displacements are used for walls and wooden structures - why not show how you can make that as well :)
    i think that would be very interesting, too. if you mention these nifty tricks, i'd be glad to know how to realize them. a lot of the time, the best stuff in tutorials is kept short telling the readers "you'll find out about that on your own" which makes me a sad panda :(
     
  10. Nutomic

    Nutomic L11: Posh Member

    Messages:
    888
    Positive Ratings:
    177
    I think there just is not much to explain, basically, you make a beam, a roof or whatever you need, just like you normally would, and turn the visible sides into displacements. Then you edit them via the dispalcement tool, until you get what you want.

    Nothing i could really explain here.
     
  11. martijntje

    martijntje L8: Fancy Shmancy Member

    Messages:
    539
    Positive Ratings:
    168
    Great tutorial, I knew most of the things you said, but I think it will be useful to people newer to mapping for tf2.

    anyways, is there any particular reason stickies and power 4 displacements dont like each other?
     
  12. Psy

    aa Psy The Imp Queen

    Messages:
    1,705
    Positive Ratings:
    1,465
    I'm pretty sure the only reason those beams are displacements is to get around either a) indices or b) the brush limit.
     
  13. Acumen

    aa Acumen Annoyer

    Messages:
    704
    Positive Ratings:
    594
    well the wodden stuff, oke, but the walls, i'd like to know, cause i read it often, but a nice insight on how to get the curved look without the rest messing up, would enlighten me :)
    but that's just me, no need to work for just one lonely number :D
     
  14. Nutomic

    Nutomic L11: Posh Member

    Messages:
    888
    Positive Ratings:
    177
    You mean this?
    [​IMG]

    Its right there in the tutorial ;)
     
    • Thanks Thanks x 1
  15. Lancey

    aa Lancey Currently On: ?????

    Messages:
    3,076
    Positive Ratings:
    1,314
    In case you want to know, subdivision is the process of taking any geometric shape and dividing it into further polygons which are then positioned and angled to make the object smoother. This process is repeated until each vertex in your displacement has been positioned at a different angle, making the object appear smooth.
    [​IMG]

    Power of 4 displacements build very complex collision meshes that in other source games work fine. However, in Team Fortress 2, the physics system has been very dumbed down. The collision mesh isn't built properly, and thus, any physics object that collides with it will crash. Supposedly it doesn't work in Episode 2 either, but I haven't been able to break it by dropping stuff on it.
     
    • Thanks Thanks x 2
    Last edited: Jan 1, 2010
  16. Acumen

    aa Acumen Annoyer

    Messages:
    704
    Positive Ratings:
    594
    hm, then i say you wrote it in a confusing manner :D
    tested it, worked like a charm

    my thanks yous are reserved !
     
  17. grazr

    aa grazr Old Man Mutant Ninja Turtle

    Messages:
    5,436
    Positive Ratings:
    3,557
    [​IMG]

    I would not have said that was the most efficient or appropriate use for a displacement. The centre of the wall still curves in slightly and the wall appears warped where it eases into the curve of the corner. I would have said just cut a corner on a basic brush/use the arch tool.

    A more accurate, although tedious approach to this kind of corner can be seen here.

    Applying this vertically rather than horizontally gives you a much cleaner finish.
     
    • Thanks Thanks x 1
  18. Nutomic

    Nutomic L11: Posh Member

    Messages:
    888
    Positive Ratings:
    177
    Seems to be a lot more work, but with a better result. I'll put it in as an alternative way to do it.
     
  19. XFunc_CaRteR

    XFunc_CaRteR L5: Dapper Member

    Messages:
    248
    Positive Ratings:
    17
    The Guardian tunnels in Half Life 2 Ep 2 (I think that's the episode) were done like this, and they look perfect.

    A tunnel can look like a tube. It depends on the tunnel now doesn't it? For example, a well...
     
  20. grazr

    aa grazr Old Man Mutant Ninja Turtle

    Messages:
    5,436
    Positive Ratings:
    3,557
    The gaurdian tunnels had more than a simple subdivide used in their creation. But that said, those tunnels were supposed to be more rounded than normal, due to how they were made. TF2 tunnels should be jaggedy to not only fit with the theme but how they were created (pick axes and dynamite).
     
    • Thanks Thanks x 1