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
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.
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.
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.
Connect them up as shown below, with the logic coming out of the back of the Terrace 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.
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.
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:
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 |
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, 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:
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.
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.
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.
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.
Now your terrain should look something like this:
You may notice the current output is too bright. To darken, simply adjust the Colorizer node settings in WM.
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.
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.
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 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).
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.
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.
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 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 & set the brush radius to something big and paint over the entire terrain in 1 go.
This has now obeyed...
To complete this tutorial & make this playable in the launcher, we will do a few more things.
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.
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.
Now you are finished importing a Terrain Heightmap & Colormap from WM -> CRYENGINE.
File -> Save your work, then File -> Export to Engine.
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.