From Valve Developer Community
Jump to: navigation, search
Example of finished terrain exported from World Machine.

Worldmachine Worldmachine is a very powerful tool for creating realistic terrain. Thanks to its ability to export heightmaps, you can convert terrain generated in World Machine into displacements using DispGen for use in the Source Engine.

This tutorial assumes a few things:

  • You have World Machine installed, you know how to use the program, and you have already created the terrain and megatexture you want to import into Source.
  • You have Dispgen installed and working.
  • You know how to convert a texture to a VTF and create a working VMT.

Tip.pngTip:The paid version of World Machine is not required to complete this tutorial, but having it will allow you to export higher resolution assets.
Note.pngNote:This is confirmed to work in version 4017 and above. The UI is different, but everything else is the same.

Exporting the Bitmaps

Screenshot showing the nodes used to generate the terrain for this tutorial. The highlighted nodes are used to export the bitmaps.

To import this into Source, we will need 3 textures: a Heightmap, a Diffuse texture, and a Normal Map. To get a normal map, add a "Normal-Map Maker" device (located under the "Converter" tab). To the input, connect your primary terrain heightmap. From the normal map output, connect a Bitmap Output (found under the "output" tab). Don't forget to double-click on the bitmap output and set a file destination.

Next, we need a heightmap. Connect your primary terrain heightmap to a Height Output node (located under the "output" tab). Double click on it, set your file location, and change your file format to BMP. This is required to import the heightmap into DispGen.

Finally, we need to export the megatexture. Connect the output of your texture to a Bitmap Output and make sure to set your file path.

Go to File -> Export Terrain Files and press "Export All." If you are prompted to build the files, press Yes.

Note.pngNote:A normal map is not required, but it adds fine shadows to the terrain, giving the appearance of extra ridges and detail without the cost of extra polygons.

Generating the displacements with DispGen

Screenshot showing the suggested settings in Dispgen

Next, we need to use DispGen to convert the heightmap into displacements. The settings used for this tutorial are 16384 units for the X and Y size, 4096 for the height, and 256 for the X and Y triangles, but these numbers should be changed to suit the scale of your terrain and the resolution required. In addition, uncheck the box next to "Adjust Terrain to minimize vertical texture stretching" (checking it can cause the texture to become misaligned) and uncheck "Run Smoothing." You can leave the material name alone, as we will be making a custom texture later. These settings can (and should) be changed to fit your map or 3D Skybox

Finally, define your heightmap and VMF Output file and press generate!

Creating the texture

Now, we need to import our megatexture into Source so that we can apply it to the terrain. You can convert your textures into VTFs using VTFEdit. Here is an example VMF for our megatexture:

	$basetexture "worldmachine/terrain1"
	$bumpmap "worldmachine/terrain1_normal"
	$surfaceprop Rock

	$detail "detail/detail_rock001"
	$detailscale 8
	$detailblendfactor 0.47

This VMT includes a detail texture. The detail texture helps add extra texture to the otherwise bland surface, even when viewed at a distance. The high detailscale adds detail without having too much repetition.

Applying the texture and finalizing

Screenshot showing the settings to fit a 512x512 texture to a 16k terrain.

It's finally time to texture the terrain! Open the VMF from wherever you saved it in DispGen. The first thing you should do is select all of the displacements (by drag-clicking a box around them in one of the 2D views) and group them together so they are easier to handle. Next, select all of your displacements, press Shift + A to open the Face Edit Tool, and navigate to the displacement tab. There, you need to make sure your displacements are either power 2 or 3. If they are Power 4, reduce them to power 3 or lower to prevent crashes. After reducing the power, you may need to sew the displacements to get rid of gaps between them.

Next, we need to fit the texture to our terrain. With all of your displacements still selected, navigate back to the Material tab. There, press Browse, search for your texture, select it, then hit apply. Check the box that says "Treat as one," then press "Fit." Your terrain is now ready to go!

Before compiling, don't forget to add a skybox, an environment light, and change your map's skybox to one available in your game, as DispGen sets the skybox to one from Half-Life 2.

Environment articles:
Skies and environment maps Skybox (2D)Skybox (3D)HDR SkiesSkybox with TerragenSkybox with Terragen - AdvancedList of skies
Terrain and displacement mapping DisplacementsCreating Holes in DisplacementsDigital Elevation ModelsCreating custom terrain with Worldmachine