Most likely, you aren't simply interested in creating terrain for its own sake - you need to get your terrain from World Machine into your other applications. Here's a list of workflows, both generic and specific, to help you along.
Terrain Export from World Machine To Unity
World Machine can serve as an excellent terrain generator for Unity.
Within World Machine
-
Place a Height Output device into your world. Wire the terrain you wish to export into the device's input.
Choose your export format within the File Output device. You should use the RAW16 format.
Build your world and export all files. The "Export Terrain files..." option from the File Menu provides a central location to do both.
Import into Unity
Luckily, Unity makes it easy to import a terrain. Simply follow these steps:
- From the Terrain menu, choose "Create a Terrain"
- Again from the Terrain menu, choose "Import Heightfield"
- By default Unity considers both 8 and 16bit RAWs to use only the .raw extension, whereas World Machine uses .r16. Change the import filter to "All Files" and navigate to where you saved your exported World Machine .r16 file. Select it.
- In the Import dialog, make sure the depth is Bit16 and the byte order is changed to Windows, then hit Import
You should now have your Terrain inside Unity! You will probably have to play with the Terrain Scale to get the size to fit correctly into your scene.
One Warning: Unity interprets raw heightfield origins differently from World Machine; your terrain will appear to be flipped on the Y axis!
One way to fix this is to add a Flipper device in World Machine just before your Height Output and turn on the Y-axis flip. This will make the terrain export identically.
Texture (Splatmap) Export from World Machine To Unity
Unity has built-in support for texture weight or "splat" maps. You can create multiple layers of terrain textures and paint each one onto the terrain.
This simple workflow provides a way to import splatmaps created within World Machine into Unity. Please note that although this method works for basic Unity Terrains, many advanced users run their own terrain shaders that may require a different technique.
Within World Machine
- Create your terrain texturing masks based upon whatever critera you want (for example, using Height Selectors, Slope Selectors, Erosion masks, etc).
-
Use a Splat Converter device to control your splatmaps and enforce proper splatmap weighting (sum-to-one, etc). For more details and an example world using the Splat Converter, see the "Splatmap Converter.tmd" example file included in the World Machine Examples under "New Examples for WM 2.3\Techniques"
- To convert your individual maps into a bitmap, wire them into a Channel Converter, which will produce an RGB image for the first three channels. The fourth will be used as the Alpha channel of the bitmap.
Wire the resulting maps into one or more bitmap output devices to create a 4 channel splatmap. If you are using more than 4 textures, simply create multiple bitmap outputs and adjust the Splat Converter accordingly.
- Build the world and export your terrain and splatmap.
Within Unity
There is one prerequisite you'll need to easily import a splatmap from World Machine. Below is a simple Unity script that helps you import and replace splatmaps. Download it and extract to your Project folder, making sure
that the script ends up inside YourProject/Assets/Editor folder.
- Create your Terrain as above and verify that everything has imported successfully.
- Assign the textures that you want to use on your terrain as normal. Then make sure you save the scene. You will see an all-red splatmap for your terrain appear in the asset browser.
-
Import the splatmap you created and exported in World Machine previously. It should look like this in the browser:
- Go to the Inspector for that imported splatmap and change the following settings:
- Texture Type: Advanced
- Read/Write Enabled: checked
- Format: ARGB 32 bit
And then press Apply.
-
From the Terrain menu, choose "Replace Splatmap...". If you don't see this entry, it is because the Splat replacer script above has not been correctly located in your project folder.
Drag the embedded splatmap inside the terrain to the first "Splatmap" entry, then your imported splatmap to the "New" entry. When importing from World Machine,
if you have not manually flipped your heightfield previously make sure "Flip Vertical" remains checked to match the flipped orientation of the heightfield.
- You're done!