PDA

View Full Version : [Tutorial] Displacements


Nutomic
12-31-2009, 10:34 AM
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

http://img269.imageshack.us/img269/2750/faceeditsheet.jpg
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 (http://forums.tf2maps.net/showpost.php?p=133559&postcount=15) (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:
http://img269.imageshack.us/img269/4791/paintgeometry.jpg
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:
http://img192.imageshack.us/img192/7011/paintalpha.jpg
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...):
http://img689.imageshack.us/img689/126/displacementgroundbase.jpg

Here are a few examples of possible solutions:
http://img192.imageshack.us/img192/7107/displacementgroundworst.jpg

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.
http://img694.imageshack.us/img694/7107/displacementgroundworst.jpg

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.
http://img689.imageshack.us/img689/2002/displacementgroundmid.jpg

Here, we have a lower displacement scale, and also bigger displacements, which should work perfectly, if your displacements are rather flat.
http://img192.imageshack.us/img192/830/displacementgroundmid2d.jpg

As we cen see on the overview, theres still much of the displacements hidden under geometry, thus being rendered, without any benefit.
http://img694.imageshack.us/img694/5076/displacementgroundbest.jpg

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.
http://img109.imageshack.us/img109/4987/displacementgroundbest2.jpg

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:
http://img192.imageshack.us/img192/3383/vertextut1.jpg

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.
http://img694.imageshack.us/img694/8242/vertextut2.jpg

The displacements dont always perfectly fit when only aligning them by the corners, thats where we can divide one edge up into 2:
http://img42.imageshack.us/img42/8264/vertextut3.jpg
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:
http://img192.imageshack.us/img192/2517/vertextut4.jpg
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.
http://img192.imageshack.us/img192/9076/cave1.jpg
http://img694.imageshack.us/img694/9549/cave2.jpg
http://img192.imageshack.us/img192/2644/cave3.jpg


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.

http://img42.imageshack.us/img42/1743/roundcorner.jpg
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_displacemen t_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:
http://img694.imageshack.us/img694/9191/2fortdisplacementsbeams.jpg

If you have brush fences in your map, displacements can be used to make them look more interesting, like here:
http://img526.imageshack.us/img526/7677/2fortdisplacementsfence.jpg

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.
http://img526.imageshack.us/img526/2875/badlandsroof.jpg
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 (http://forums.tf2maps.net/attachment.php?attachmentid=1825&stc=1&d=1262277220)

The Political Gamer
12-31-2009, 10:50 AM
+1 Thanks

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

littleedge
12-31-2009, 03:07 PM
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.

keithgarry
12-31-2009, 04:27 PM
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.

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.

littleedge
12-31-2009, 05:12 PM
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.

VelvetFistIronGlove
12-31-2009, 06:10 PM
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).

littleedge
12-31-2009, 07:06 PM
Power 4 displacements can cause problems when used in conjunction with sticky bombs, though. So it's best to stay at 3 or 2.

Nutomic
01-01-2010, 07:45 AM
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.

Thanks, i will see how i can change that :)

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).

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

Acumen
01-01-2010, 08:07 AM
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 :(

Nutomic
01-01-2010, 08:37 AM
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 :(

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.

martijntje
01-01-2010, 09:52 AM
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?

Psy
01-01-2010, 09:53 AM
I'm pretty sure the only reason those beams are displacements is to get around either a) indices or b) the brush limit.

Acumen
01-01-2010, 10:26 AM
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

Nutomic
01-01-2010, 10:30 AM
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

You mean this?
http://img42.imageshack.us/img42/1743/roundcorner.jpg

Its right there in the tutorial ;)

Lancey
01-01-2010, 10:34 AM
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.
http://upload.wikimedia.org/wikipedia/commons/thumb/3/33/Catmull-Clark_subdivision_of_a_cube.svg/414px-Catmull-Clark_subdivision_of_a_cube.svg.png

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?

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.

Acumen
01-01-2010, 10:37 AM
hm, then i say you wrote it in a confusing manner :D
tested it, worked like a charm

my thanks yous are reserved !

grazr
01-01-2010, 12:09 PM
http://img42.imageshack.us/img42/1743/roundcorner.jpg

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 (http://www.snarkpit.net/snarkpower/articles/game/cat/pn/tp/146/Texture_alignment_through_arches_using_displacemen t_maps).

Applying this vertically rather than horizontally gives you a much cleaner finish.

Nutomic
01-01-2010, 12:23 PM
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 (http://www.snarkpit.net/snarkpower/articles/game/cat/pn/tp/146/Texture_alignment_through_arches_using_displacemen t_maps).

Applying this vertically rather than horizontally gives you a much cleaner finish.

Seems to be a lot more work, but with a better result. I'll put it in as an alternative way to do it.

XFunc_CaRteR
01-01-2010, 11:44 PM
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.

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...

grazr
01-02-2010, 08:01 AM
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...

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).

Sel
01-02-2010, 09:58 AM
http://img42.imageshack.us/img42/1743/roundcorner.jpg


I'd also like to add that despite using less brushes, it's using about quadruple the triangles of if you did it with brushes.

Nutomic
01-02-2010, 10:14 AM
Thats right, but the displacements still take much less performance, because they can be rendered in batches or something.

XFunc_CaRteR
01-02-2010, 04:35 PM
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).

Nah. You are wrong. Rules are meant to be broken. Anybody who says, "Tunnels MUST be made this way" is begging to be proven wrong.

The truth is, the way you make it depends on what its needs are. The needs have to be assessed on a case by case basis. You might make a sewer, for example, that is ringed with brick. It would be totally appropriate to do such a tunnel as a tube.

grazr
01-02-2010, 07:46 PM
Nah. You are wrong. Rules are meant to be broken. Anybody who says, "Tunnels MUST be made this way" is begging to be proven wrong.

The truth is, the way you make it depends on what its needs are. The needs have to be assessed on a case by case basis. You might make a sewer, for example, that is ringed with brick. It would be totally appropriate to do such a tunnel as a tube.

The thing is though, you don't need displacements to make a tube. The sewers in 2fort, the secret water entrance in well. These are all brush work tubes.

I'm not saying, and never stated, that "tunnels have to be made this way". Simply that doing them (the type of tunnels you discuss) with displacements is not the most efficient way to do them. The fact that Valve have not either, is a hint unto itself. You would think that they understand their own game engine.

Taking tunnel creation on a case by case basis wont change the nature of how to construct them in Hammer and how they perform in game; these issues are dictated by the editor and engine capabilities. Not by any individual questioning the status quo of design principles (such as you or I). Cause and effect: There's no reason for taking the effert of creating a tunnel (in the form you hypothesise) with displacements, when brushwork is quicker and performs better ingame. You are right that the Gaurdian tunnels look sweet, but Guardian tunnels will never be an issue in TF2. A tunnel will either warrant brushwork for its uniformity, or displacements for its non-uniformity. The TF2 universe gives us pretty strict rules to apply to our visual design process as well.

Creating a cave may warrant subdivision to get the bulk of the work/achieving the basic hollowed shape out of the way, and/or to make it easier to work from. But it certainly shouldn't be left at that. Even the Gaurdian tunnels did not suffer us a basic subdivision.

Point and case: Rocky tunnels should (because it looks and performs better) be produced with displacements. Concrete tunnels and the like should (because it looks the same, is easier to work with and performs better) be made with basic brush work. But of course the option is available to create them otherwise. Just don't expect them to give you a better result if you do build them that way.