Displacement Surfaces 1: The Basics
by ReNo (view all articles)

unrated
An introduction to terrain creation
by ReNo (view all articles)

unrated

With the new version of Hammer, Valve have given us a new tool to aid us in the creation of realistic terrain. While in the aging Half-Life 1 engine we were forced to use slow and methodical triangle terrain methods, in the Source engine we have the luxury of using displacement surfaces. In this tutorial I will show you how to make basic use of these to create some realistic terrain.
The first step in using displacement surfaces is to place a brush where you wish your terrain to be situated. At this point it is necessary to point out that the brush must be four sided - circles or triangles for example just won't work. In this example, I have a path and I want the terrain to be a section of grass beside it. The following screenshot demonstrates the brush layout.
Next up you need to specify which face is to become a displacement surface (ie. the surface we want to make uneven). In this example that will be the top face of the grass brush. To reach the displacement tool we open the texture application tool (shift-a) and switch to the displacement tab. Select the face you wish to manipulate and press the create button. This will bring up a dialog box, as shown below.
The dialog box asks you for a value that will determine the number of points we can manipulate on our surface. While more points will result in a more realistic surface, keep in mind that it will also have a greater effect on the performance and take longer to edit. The default value of 3 seems to be a reasonable value to begin with, so stick with that and press enter.
At the time of writing, the newest version of hammer is still victim to quite a number of bugs, and the displacement tool seems to be one of those that is worst hit by them. If at this point the face you have just turned into a displacement surface turns blank white, do not despair. It would seem that Valve are planning for this to display a wireframe mesh in order to make terrain manipulation as easy as possible, but for the time being it doesn't appear to be working. In order to get your texture to reappear on the face, ensure that the "grid" mask option is checked.
After that aside, our next step is to begin playing with our mesh. Select the "paint geometry" option from the displacement tool dialog and ensure the follow options are set in the new dialog you will be presented with...
Effect - Raise/Lower (and check "Spatial")
Axis - Face normal
Distance - 4
You will now have a little spherical select pointer with an arrow pointing upwards, that moves around your terrain and snaps onto various points. It is this little tool that we use to manipulate our flat plane into something far more interesting. Pressing the left mouse button and dragging while on a point will raise it, while pressing the right mouse button will lower it. Tapping either of these buttons will raise or lower by the specified distance value. Here is a screenshot showing this process...
You may notice that it is nigh on impossible to accurately move parts of the terrain as the pointer keeps jumping to different points on your surface, but thankfully you can lock it onto one point by holding shift while you make your changes. You can also manipulate multiple points at once by holding down alt and left-dragging the mouse to increase the size of your selection sphere. With no grid overlay this is made more difficult than it should be, but with care and patience it is perfectly useable. Below is an example of what you can create with this new feature of hammer...
The displacement surface tool also gives you access to a host of other features to simplify terrain creation. One of these is smooth, which is accessed by going into the paint geometry option and selecting it from the list of effects. Now hammer will smooth out the terrain as you manipulate it with your selection sphere, and the larger the sphere then the more points it will smooth at once (resulting in a very quickly flat surface if you make it too large!). Another is the noise ability, which does the opposite to smooth by adding a random height to each point on the surface between the specified minimum and maximum values. By using the "raise to" effect you can accurately move the selected point/(s) to the height entered in the distance input. You also have the ability to move your entire terrain up and down by an arbitary value - so should you have made the perfect terrain but it is too high for its purpose, then you can shift all of your terrain downward (or upward) by specifying an elevation value. The scale option will multiply each points height by the given value, so if you want to make your terrain more extreme then experiment with this.
Please note that this is not an exhaustive list of the displacement surface tool's features, and there will be more tutorials on how to best use this tool in the near future. For the time being - get those safety glasses on and experiment! Leave comments, suggestions or questions below as always
Displacement surfaces do not block VIS, so when using them in your level (especially with ground and rocky walls) you must be careful to seal it off some other way. If you are using a skybox, simply place more skybox brushes behind/under it, otherwise use the NODRAW texture:
If you do use NODRAW behind, note that the displacement surfaces can 'overlap' it and even extend out behind, but they will not be lit so you will get dark patches in these areas (plus no debris will fly out when shot).
The first step in using displacement surfaces is to place a brush where you wish your terrain to be situated. At this point it is necessary to point out that the brush must be four sided - circles or triangles for example just won't work. In this example, I have a path and I want the terrain to be a section of grass beside it. The following screenshot demonstrates the brush layout.

Next up you need to specify which face is to become a displacement surface (ie. the surface we want to make uneven). In this example that will be the top face of the grass brush. To reach the displacement tool we open the texture application tool (shift-a) and switch to the displacement tab. Select the face you wish to manipulate and press the create button. This will bring up a dialog box, as shown below.

The dialog box asks you for a value that will determine the number of points we can manipulate on our surface. While more points will result in a more realistic surface, keep in mind that it will also have a greater effect on the performance and take longer to edit. The default value of 3 seems to be a reasonable value to begin with, so stick with that and press enter.
At the time of writing, the newest version of hammer is still victim to quite a number of bugs, and the displacement tool seems to be one of those that is worst hit by them. If at this point the face you have just turned into a displacement surface turns blank white, do not despair. It would seem that Valve are planning for this to display a wireframe mesh in order to make terrain manipulation as easy as possible, but for the time being it doesn't appear to be working. In order to get your texture to reappear on the face, ensure that the "grid" mask option is checked.
After that aside, our next step is to begin playing with our mesh. Select the "paint geometry" option from the displacement tool dialog and ensure the follow options are set in the new dialog you will be presented with...
Effect - Raise/Lower (and check "Spatial")
Axis - Face normal
Distance - 4
You will now have a little spherical select pointer with an arrow pointing upwards, that moves around your terrain and snaps onto various points. It is this little tool that we use to manipulate our flat plane into something far more interesting. Pressing the left mouse button and dragging while on a point will raise it, while pressing the right mouse button will lower it. Tapping either of these buttons will raise or lower by the specified distance value. Here is a screenshot showing this process...

You may notice that it is nigh on impossible to accurately move parts of the terrain as the pointer keeps jumping to different points on your surface, but thankfully you can lock it onto one point by holding shift while you make your changes. You can also manipulate multiple points at once by holding down alt and left-dragging the mouse to increase the size of your selection sphere. With no grid overlay this is made more difficult than it should be, but with care and patience it is perfectly useable. Below is an example of what you can create with this new feature of hammer...

The displacement surface tool also gives you access to a host of other features to simplify terrain creation. One of these is smooth, which is accessed by going into the paint geometry option and selecting it from the list of effects. Now hammer will smooth out the terrain as you manipulate it with your selection sphere, and the larger the sphere then the more points it will smooth at once (resulting in a very quickly flat surface if you make it too large!). Another is the noise ability, which does the opposite to smooth by adding a random height to each point on the surface between the specified minimum and maximum values. By using the "raise to" effect you can accurately move the selected point/(s) to the height entered in the distance input. You also have the ability to move your entire terrain up and down by an arbitary value - so should you have made the perfect terrain but it is too high for its purpose, then you can shift all of your terrain downward (or upward) by specifying an elevation value. The scale option will multiply each points height by the given value, so if you want to make your terrain more extreme then experiment with this.
Please note that this is not an exhaustive list of the displacement surface tool's features, and there will be more tutorials on how to best use this tool in the near future. For the time being - get those safety glasses on and experiment! Leave comments, suggestions or questions below as always

Visibility note
Displacement surfaces do not block VIS, so when using them in your level (especially with ground and rocky walls) you must be careful to seal it off some other way. If you are using a skybox, simply place more skybox brushes behind/under it, otherwise use the NODRAW texture:

If you do use NODRAW behind, note that the displacement surfaces can 'overlap' it and even extend out behind, but they will not be lit so you will get dark patches in these areas (plus no debris will fly out when shot).