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.
This tutorial may rely on the GameSDK Sample Project. We recommend that you download this from the Asset Database, import it into your Launcher, start it from there and then create a new level.
See this page to find out how to import a project to your Launcher. (The default folder for the GameSDK Sample Project when downloaded is C:\Program Files (x86)\Crytek\CRYENGINE Launcher\Crytek\gamesdk_<XXX>\GameSDK
)
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.
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.
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.
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
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:
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
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 |
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.
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
The terrain above is the heightmap included in the sample files; the one you made in WM earlier will most likely look different.
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.
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 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.
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.
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
Now your terrain should look something like this:
Pic10: Colormap imported
You may notice the current output is too bright. To darken, simply adjust the Colorizer node settings in WM.
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.
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.
Or if you create your own terrain textures / materials, make sure you set the shader type to Terrain.layer from the default Illum Shader.
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.
Pic12: Material folder button
Materials\terrain
folder you can see the available terrain materials.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.
So to recap... grass covers 0-30 degrees, and the rock material covers 30-90 degrees. Without overwriting each other.
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
By default, the Layer Painter will paint both the High and 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.
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.
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:
To complete this tutorial and make this playable in the game launcher, we will do a few more things.
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.
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