Snarkpit Articles

Realistic tunnels and caves

Shows you how to make a tunnel through the use of displacements
Before you do this tut you should allready have fooled a little bit around with displacement surfaces so you know the basics; there are two here by Reno worth checking out.

In order to create our tunnel we will be looking at the following:
  • Creating "displacement surfaces"
  • Using "subdivide"
  • Using "sew"
  • Using the "power of" setting
  • Using "noise"
  • Using "paint geometry"
  • Using "invert alpha"
  • Using "paint alpha"

Stage 1 - Creating the base brushes for the displacement surfaces

Start off by making 9 world brushes and place them like this:

Article image


Article image


Texture all brushes with "de_chateau/rockf_blend" except for the two brushes that make up our road - for those use "de_chateau/groundd_blend"

Note - You don't have to texture the sides that won't be seen with the "nodraw" texture, as they will be discarded when we create the displacement surfaces - I just use it to show which sides we will be using ...

Notice how the edges of the side cliff brushes are lined up with the top surface of the ground and road brushes:

Article image

Stage 2 - Creating the displacement surfaces

Now open up the "texture application tool" and select all the faces we will be using (15 faces total).
Don't forget the inside roof of the tunnel!!
With all faces selected switch to the "displacement" tab in the "texture application tool" and then click the "create" button, and all the surfaces will be turned into displacements.
Notice how all the non-selected faces were discarded during this process:

Article image


For the creation of the displacement surfaces I set "power of" to 2.
If you set it to 3 or 4, the surface will be made up of more triangles giving you greater detail. You can just use 2 for now.

You could now manually paint the terrain to get what you want but it's a lot quicker to use the various displacement tools, which we will do in the next stage ...

Stage 3 - Editing the displacement surfaces to create realistically looking terrain

With all the faces still selected click the "subdivide" button and notice how all the angles between the various surfaces are rounded off (both inside and outside angles):

Article image


Now select the top 6 surfaces and click "paint geometry". Then manually raise the vertices at the back of the top surfaces to make a cliffside out of it like this:

Article image


Note - You should experiment with the various settings in the "displacement paint geometry" dialog to understand what they do - for now just use the same settings I did.

Now I want to make my terrain a little more bumpy - This could be done manually, but it's quicker to just add some "noise".

Select the cliff side and ground surfaces (we don't want to bump up the road so don't select those two surfaces). Then click the "noise" button and enter values of 20 min and 30 max and click "OK":

Article image


The terrain now got a little more bumpy - The effect would have been greater had we used a "power of" value of 3 or 4 when we created the displacement surfaces.

Notice how doing this this made holes in the seams between our various surfaces:

Article image


In order to rectify this - select all surfaces again and click the "sew" button and all the holes in the seams will be closed back up:

Article image

Stage 4 - Painting the surfaces

Now, even though our terrain is beginning to look nice enough - the texturing makes it look unrealistic. We are going to adress this now.

First off, select the road and ground surfaces then click the "invert alpha" button. This switches the texture to the other part of the blend texture. So now the ground looks like grass and the road looks like dirt:

Article image


Then finally select all the surfaces and click the "paint alpha" button. Now you can use the left and right mouse buttons to paint the textures so that you create nice blends in the transitions between the surfaces. Make sure that you have the settings in the "displacement paint alpha" window set to something like this:

Effect: Raise/Lower
Brush: 1
Value: 22

After having painted the surfaces you should end up with something like this:

Article image


Now you are pretty much done. You could allways put more work into making the terrain and texture blending look even better than this. By selecting all faces and setting the "power of" setting to 3 you will get a lot more triangles/vertices to work with, which gives you more control both when making the terrain itself as well as blending the textures. This is however more expensive in terms of performance:

Article image


When that is said - displacement surfaces are pretty cheap for the engine to render so you can get away with quite detailed terrain if you don't go overboard with other stuff like complicated world brushes, phsyics, models, water etc ...

There is one thing however, that you need to be aware of. Displacement surfaces do NOT block VIS! So in order to rectify this, you should place ordinary world brushes textured with "nodraw" underneath all of your displacement surfaces.

Discussion

Posted by Le Chief on Sun May 4th 2008 at 8:47am

Posted by C-J on Thu Mar 20th 2008 at 9:01am

Fantastic. Makes something that could be a bugger to work out on your own very simple.
Might be worth adding that you can only make a displacement surface on a 4 edged face, but that's minor.
Posted by Chefi on Wed May 9th 2007 at 3:34pm

This tutorial was great because it didint just and only tell how to make that damn hole in wall aka. cave. It also told almost all basics to make these surfaces look nice. I allready know all this but I can imagine that this is very clear tutorial for newbie.
Posted by Jon M on Sun Jan 7th 2007 at 3:43pm

I signed up just to say, this is the single most helpful tutorial I've read in a long time. Thank you.
Posted by Hashbrown on Tue Aug 1st 2006 at 9:58am

Very nice tutorial man! helped me out alot. i have been trying to figure out how to blend textures togather for some time now and this is the best demonstration of it ive seen! hehe keep all the good tutorials coming man!
Posted by Orpheus on Tue May 2nd 2006 at 5:35pm

I plan on reading this closely and I feel its a great tutorial but, it is not 56k friendly. It took 6 refreshing to get all the images to complete and several minutes. They could have been reduced by 20-30% easily.

I would appreciate it updated with better image sizes please.
Posted by Murdoc on Thu Oct 27th 2005 at 1:02pm

Great job man, good tutorial, my maps always get messed up when I tried to achieve natural looking caves before. was very helpful to me.
Posted by t3h th1ng! on Tue Jul 5th 2005 at 10:32pm

Posted by Lethal.au on Mon Jun 6th 2005 at 8:25am

Wow this was i great tutorial!!! i found it very easy to follow and got a very nice cave at the end :) im glad people who know hammer well can take time to help out us noobs. A masterpiece
Posted by G4MER on Mon Jun 6th 2005 at 1:01am

What they ^ said. =)