This tutorial will show you how to create a terrain heightmap and colormap in World Machine, to be used with CRYENGINE.
We will use the Free version of World Machine (WM) to create the content and 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 WM, but instead is more focused on the workflow of exporting a terrain from WM to CRYENGINE.
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.
Pic1: Setting the map size to 512x512 in World Machine
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 and TIFF.
Pic2: Supported file types
We will use the RAW16 ( or ".r16" in Windows Explorer) file type.
Specify the location where you want to save it and 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 and 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 and 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.
Pic3: Node connections
Inside the colorizer node (double-click to open) you can pick one of the presets from the drop-down list to get you started. This is enough for now to apply some color onto the terrain.
Pic4: Picking preset in colorizer node
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.
Pic5: Bitmap Output properties
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) and 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; we have created 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 (File -> New) and select from the settings a terrain resolution of 512x512 to match the terrain size we just exported from World Machine.
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).
Pic6: Creating a new level
Resulting terrain size
512m x 512m
1024m x 1024m
2048m x 2048m
1024m x 1024m
2048m x 2048m
4096m x 4096m
Importing the Heightmap
Import the heightmap
Open the Terrain Editor (On the right of the viewport in the default UI, or in Tools -> Terrain Editor). Then inside the Terrain editor go to File -> Import Heightmap.
Pick the heightmap (hm.r16) file we just created from WM (by default it should be in:
Documents\World Machine Documents) and click OK.
Now you probably can't see it, you will have to fly out to see more of the level, but eventually you will see something like this:
Pic7: Imported heightmap
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 and choose Edit -> 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.
Now re-import the heightmap again and notice how we have lost the huge cliff faces and acquired a flatter landscape, due to setting a reasonable value for the height.
Pic8: Re-imported heightmap
Jump in game and try it out (Ctrl+G). This is 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 and white checkbox). To change the terrain texture, we need to change two things: the low detail and 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.
In the Terrain Editor, go to File -> Export/Import Terrain Texture. This opens up a new window with a top-down overview of the entire level.
Pic9: Importing Terrain Texture
- 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 and pick 512x512 from the drop-down list. If nothing happens, make sure you have highlighted the tile by clicking on it (it will show as grey when selected).
- This has now set our terrain texture resolution to the same as our heightmap and 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 clockwise in Photoshop.
Now your terrain should look something like this:
Pic10: Colormap imported
The High Detail Texture
In the Terrain Editor, click the Paint button at the top:
Pic11: Paint button
This is where you set and assign the different grasses, rocks, earth textures to be seen up close by the player.
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. We'll also apply a set of rules to each terrain layer such as min / max angle, min / max height.
- Select and highlight the first layer in the list (default) and click the Folder button next to Material at the bottom:
Pic12: Material folder button
- This will let you select a material for your layer. Browse under the
Materials\terrainfolder you can see the available terrain materials.
- Select or highlight in the material editor grass_1 and click Open.This will apply that material to the terrain layer.
- Double-click on the name of the layer at the top of the Terrain Editor (currently "Default") and give it a name 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 paint with this layer later, it will not try to paint on any surface slope that is greater than 30 degrees.
- Next we will add another Terrain Layer. Right-click in the section oft he Terrain Editor where your "Grass" layer is and choose Create Layer. Give it the name "Rock".
- Click once again on the Folder button and pick a rock material like cliff_island_3d.
- Define the rules once again, but this time set the Min Angle to 30 degrees.
- Right click on the name of the layer at the top of the Terrain Editor and select Flood Layer.
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 lower half of the Terrain Editor, you can click the Paint button to activate terrain painting mode:
Pic13: Terrain Paint button
In the top of the panel, you can see a list of the terrain layers, "Grass" and "Rock". As you click between the two layers, you will notice the Slope Rules change between the different layers (what we just set up):
Pic14: Layer painter
There are 3 ways to apply the terrain textures inside this tool.
- Paint both high and 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 and cliff_island_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 Paint Layer Id checkbox.
Also set the Hardness Slider back to 1. Or 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 and 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.
To complete this tutorial and make this playable in the game launcher, we will do a few more things.
Generate the Terrain Texture
Now we have our terrain Heightmap and Colormap in the engine, we just need to generate the terrain surface texture and we are done.
To do this, in the Terrain Editor, go to File -> Generate Terrain Texture:
Pic15: Generating the terrain texture
Accept the defaults. Click OK and it will generate the texture.
Export to Engine
Now you are finished importing a terrain heightmap and Colormap from WM to CRYENGINE.
File -> Save your work, then File -> Export to Engine.
Now with some quick vegetation distribution, some Environment Editor tweaks, adding a skydome and you should have something like this:
Pic17: End result