Skip to end of metadata
Go to start of metadata

Overview

This tutorial will show you how to create a terrain heightmap & colormap in World Machine, to be used with CRYENGINE.

We will use the Free version of World Machine (WM) to create the content & allow for a wider audience to take part. The free version is limited to export out a max 512x512 image, so we will stick with these dimensions. 

This will not show you how to make fantastic landscapes in World Machine, but is more focused on the workflow of WM -> CE.

Attached is a zip file with the working files & level created with them during the tutorial: wm_to_ce_tutorial.rar

Setting up World Machine

First off, know the scale you are working with. Under World Commands\Project World Parameters you can see how WM is setting up the scale.

Because CRYENGINE supports the standard power of 2 resolution sizes (256, 512, 1024, 2048, 4096, etc) uncheck the (+1) checkbox to make the map size 512x512.

With it now displaying 512 x 512 resolution, click OK to save and close the dialog.

Creating the Heightmap

Double click the Height Output node on the WM graph (red box on the right). This is where we are going to pick the output file type.

CRYENGINE supports 4 of the different file types that you can directly export out from WM. One low precision 8-bit BMP, and three higher precision 16-bit images RAW16, PGM & TIFF.

Always use the 16bit variations as they give a much better terrain quality, as the 8bit BMP suffers from a lot from "terracing".

We will use the RAW16 ( or ".r16" in windows explorer) file type.

Specify the location where you want to save it & click the write output to disk! button to create the file. We are now ready to create the colormap.

Creating the Colormap

Next we are going to have to add a few more nodes into the WM graph. These will allow us to save out the file, color the colormap & preview the data in WM before we export.

  • First we will add the Bitmap Output node to export out the image we want. This can be found in Devices -> Output -> Bitmap Output.
  • Then we also need a Colorizer node. This allows you to select from a bunch of presets that will distribute the color over the terrain. To add this, go to Devices -> Converters -> Colorizer.
  • Finally but not required, is the Overlay View node. This helps you visualize the height & color maps together inside WM. This is also found in Devices -> Output -> Overlay View.

Connect them up as shown below, with the logic coming out of the back of the Terrace node.

Colorizer Node

Inside the colorizer node (double click to open) you can pick from the drop-down list one of the presets to get you started. This is enough for now to apply some color onto the terrain.

Bitmap Output Node

Click on the Bitmap Output node to open its properties. The file type CRYENGINE accepts for the terrain colormap is BMP.

So set the exported file type out as BMP. Click the write output to disk! button to create the file then click OK.

Overlay Node

This last node doesn't create any files for CRYENGINE to use, but is very helpful in WM to visualize what you are creating. It overlays the colormap onto your heightmap (if you set it up that way), to give you a preview of the terrain you are creating. 

Simply add the HM (heightmap) & CM (colormap) to the inputs of the node (they will only go in one way). Now press F8 (3d View) to see the terrain rendered with the colormap applied on top.

Now is a good time to save your World Machine project.

You have now created all the files you need for CRYENGINE. So we have saved out from World Machine:

  • image.bmp (8bit colormap).
  • output.r16 (16bit heightmap).
  • project.tmd (World Machine file).

Setting up the level in CRYENGINE

Open Sandbox and Create a new level

In Sandbox, Create a new level and select from the settings a terrain resolution of 512 x 512 to match the terrain size we just exported from WM.

Also set the Meters Per Unit value to 1 (this is the multiplier we use to make a terrain bigger than the imported source image).

Heightmap size

Multiplier

Resulting terrain size

512 

1

512m x 512m

1024

1

1024m x 1024m

2048

1

2048m x 2048m

512

2

1024m x 1024m

1024

2

2048m x 2048m

2048

2

4096m x 4096m

Icon

What this means is that on a multiplier of x1 level, the distance between each point on the HM is 1 meter. On a x2 level, the distance is 2 meters per vertex. So as you increase this multiplier, you are spreading out the vertices on the HM, and it is trading off its detail vs space covered.

Importing the Heightmap

Import the heightmap

Open the terrain editor, Terrain -> Edit Terrain. Then inside the Terrain editor go to File -> Import Heightmap.

Pick the heightmap (.r16) file we just created from WM (by default it should be in: Documents\World Machine Documents) and click OK.

Now you probably cannot see it, you will have to fly out to see more of the level, but eventually you will see something like this:

Set Terrain Max Height

What has happened here is that the XY dimensions are correct (we set them to 512x512). But the Z value is too high.

To get this into a more usable heightmap, we need to go to the terrain editor, Modify -> Set Terrain Max Height.

Give it a low value of 128. The top of the terrain will clip off, in the 3d viewport, but this is ok as we are about to re-import it again.

Icon

What this is doing is setting the white point (255) of the greyscale heightmap to a maximum of 128m in the engine.

Now re-import the heightmap again & notice how we have lost the huge cliff faces & and acquired a more flatter landscape, due to setting a reasonable value for the height.

Jump in game & try it out (CTRL+G). It's the best way to get an idea of the scale of the world you are creating.

Importing the Colormap

Currently we are using the default terrain material (black & white checkbox). To change the terrain texture, we need to change two things: the low detail & the high detail texture and materials. See Painting Terrain for more information.

  • Low Detail - This is what you see in the distance when looking at your terrain. It is based off of the colormap.
  • High Detail - This is what you see close to the camera. When you look at the floor, you will see nice high detail textures. The engine handles the transition between the two textures, based on distance from the camera.

The Low Detail Texture

First we will replace the low detail texture.

Open the Terrain -> Export/Import Terrain Texture tool. This opens up a new window with a top down overview of the entire level. 

  • Click on the image (with 256 in the middle). This is one terrain texture tile, currently set to 256 which is ½ of our terrain texture resolution. Click the Change Tile Resolution button & pick 512x512 from the drop-down list. If nothing happens, make sure you have highlighted (it will show as grey when selected) the tile by clicking on it.
  • This has now set our terrain texture resolution to the same as our heightmap & also the same size as the texture we exported out from WM. You must make sure that the texture dimensions are the same as the tile resolution, otherwise it will produce an error.
  • With the tile still selected, click Import and select your terrain texture created from WM. Once selected, click Close on the Import tool and the terrain color will update. Fly up high and check the alignment of the colormap on the terrain. Is it rotated? Does the snowy part follow the highest ridge in the map? If not rotate the image 90 degrees CW in Photoshop.

Now your terrain should look something like this:

Icon

You may notice the current output is too bright. To darken, simply adjust the Colorizer node settings in WM.

The High Detail Texture

Open the Terrain -> Terrain Textures Layers panel.

This is where you set & assign the different grasses, rocks, earth textures to be seen up close by the player. 

Icon

What makes a material a "terrain material" is the applied shader. Every material in the included Materials/terrain folder uses the Terrain.layer shader. You can only apply these materials to the terrain layers.

We will add two layers to the terrain texture. One to cover the flat areas (grass). And another to deal with slopes (rock faces). These can all be defined here but applying a set of rules to each terrain layer such as min / max angle, min / max height.

  • Select & highlight the first layer in the list (default) and click the link in the material column. This will take you to the Material editor. Browse under the Materials\terrain folder you can see the available terrain materials.
  • Select or highlight in the material editor grass_01. Now back in the terrain texture layers window, click the Assign Material button. This will apply that material to the terrain layer.
  • Give a name to the terrain layer that represents the material applied to the layer, like Grass. This is only for your benefit when you come to painting with these layers later on.
  • Now we will define some rules to this terrain layer. We will only change the Max Angle here to 30 degrees. So when we come to paint with this layer later, it will not try to paint on any surface slope that is greater than 30 degrees.
Icon

As this material was applied to the default terrain layer, this has now flooded the entire terrain with this material. As a good workflow practice, make sure to pick a generic texture such as grass or mud that will be seen everywhere, until you paint down the new texture you want in its place.

  • Next we will add another Terrain Layer. Click Add Layer in the control panel on the left. Assign the name Rock.
  • Click once again on the terrain material click the link to go to the material editor and pick a rock material like cliff_gray_3d, and assign it to the layer.
  • Define the rules once again, but this time set the Min Angle to 30 degrees.

So to recap... grass covers 0-30 degrees, and the rock material covers 30-90 degrees. Without overwriting each other.

Painting Terrain Layers

In the RollupBar, select the second tab (Terrain). This is where we have access to paint the terrain layers we just created.

Down the bottom of the panel, you can see a list of the terrain layers, grass & rock. As you click between the two layers, you will notice the Slope Rules change between the different layers (what we just set up).

Icon

By default, the Layer Painter will paint both the High & Low terrain textures at once. Since we created our low detail texture in WM we do not want this to happen.

There are 3 ways to apply the terrain textures inside this tool.

  • Paint both High & low detail at once (Default mode).
  • Paint High detail only.
  • Paint Low detail only.

Painting High detail Only

This is the method we want to use as we do not want to paint the low detail texture, as this was created in WM (the colormap).

To achieve this, set the Hardness Slider down to 0. 

This will then only paint the high detail textures (the materials we assigned earlier (grass_01 & cliff_gray_3d). Now you can paint down the terrain layer safely without overwriting the texture we imported from WM.

Painting low detail Only

To overwrite the texture we imported from WM, without adding the high detail uncheck the PaintLayerId (DetailLayer) checkbox.

Also set the Hardness Slider back to 1Or if you just need to adjust the texture slightly, set the slider to something in-between 0 - 1 depending on how much you want to overwrite (think opacity).

Now using the Paint High Detail Only Method above, select the Rock layer & set the brush radius to something big and paint over the entire terrain in 1 go.

This has now obeyed...

  • The slope rules set down earlier.
  • Only detail texture painted down.

Finishing off

To complete this tutorial & make this playable in the launcher, we will do a few more things.

Generate the Terrain Texture

Now we have our terrain Heightmap & Colormap in the engine, we just need to generate the terrain surface texture & we are done.

To do this, go to File -> Generate Terrain Texture. 

 

Accept the defaults, 4096x4096 + Terrain Color Multiplier = 1 + High Quality On. Click ok and it will generate the texture.

Add a SpawnPoint

In the RollupBar go to the first tab (Objects) and click the Entity Button.

Browse to the Others folder and add a SpawnPoint. Place this inside the level on the terrain where you want the player to start.

Export to Engine

Now you are finished importing a Terrain Heightmap & Colormap from WM  -> CRYENGINE.

File -> Save your work, then File -> Export to Engine.

Result

Now with some quick vegetation distribution, some Time of Day tweaks, adding in a skydome and you should have something like this:


The aforementioned grass material was switched out for a more 'dry/dirt' material to suit the brown colormap.