This article is adapted by the editor with the Russian translation of the original manual: “Terrain export from world machine to unity” . World Machine can serve as an excellent terrain generator for Unity. Unity also has native support for textures and splatmaps. You can create and use several layers of terrain textures at the same time. Here is a simple working code for importing into Unity areas from World Machine. Please note that, although this method works for the main localities in the unity, many advanced users can create their own local shaders, which may require a different technique.
What you need to do to export to World Machine
Expose Height Output in your world. Remember this value .
Create texture masks for terrain based on any criteria (using: Height Selectors, Slope Selectors, Erosion masks, and others).
Use Splat Converter to control and respect the weight of your splatmaps . You can also use Splat Converter included in "New Examples for WM 2.3 \ Techniques"
To convert individual cards in a bitmap image, link them to a channel converter, which will produce RGB images for the first three channels. The fourth will be used as an alpha channel bitmap. Wiring the resulting cards in one or several raster output devices to create a splatmap 4 channel. If you use more than 4 textures, simply create several raster outputs and adjust the Splat converter accordingly.
Select the format in File Output that will be used to export from WM . In this case, you must use the RAW16 format.
Build your world and export all files. Select Export Terrain files in the Files menu, which is the central location for such commands.
What needs to be done to import into Unity3D
In your project, in the GameObject menu, select 3D Object -> Terrain .
Select the object and the Terrain component and open the Terrain Settings section. It is recommended to edit the Detail Resolutoin , Control Texture Resolution and Base Texture Resolution values.
* If you are going to import a landscape in RAW16 format, then it is better to first place this file in your project (for RAW8, you can not do this).
Click the Import Raw button.
In the window that opens, find and select the landscape that you want to import. If you are importing a file in the RAW16 format, select the “All files” file type.
In the Depth option in the menu that appears, select “bit16” if you are importing a landscape in RAW16 format, for RAW8 format, select “bit8”. Also make sure that the Byte order value is set to “Windows” and the Width / Height values of the height map correspond to the values of the terrain you import.
Change the Terrain Size to the values from the imported area (X corresponds to the Width value of the height map, Z is Height, and you have to remember the Y value) in order for the recreated terrain to match the one you exported from WM .
Click the Import button.
Assign the textures you want to use in your area, as usual. Then make sure you save the scene. You should see a red splatmap for the terrain, which will appear in the asset window.
Import (simply drag and drop into the unity window) the splatmap created and exported to WM earlier.
Go to the inspector for the imported splatmap and change the following parameters:
Download and import the script below into your project and place it in the “YourProject / Assets / Editor folder”: download .
From the Terrain menu, select Replace Splatmap. If you do not see this inscription, it means that the ReplaceSplatmap.js script was not properly located in the project folder. Drag the splatmap embedded inside the landscape to the first “Splatmap” field and the imported splatmap to the “New” field. Make sure that “Flip Vertical” matches the orientation of your area.
If you are an indie developer, then you can take a pie from the shelf: you are finished!
PS: That's all for now. Perhaps there will still be a video of the whole process.