Also known as: Cast, Heightfield to ID, ID to Heightfield
Converts between heightfields and ID maps (byte grids and integer grids).
When to Use
- IDs from a mask: Turn a grayscale mask into whole-number material or region IDs.
- Processing ID maps: Turn an ID map back into a heightfield you can filter and combine.
- Changing formats: Change an ID map between the byte and integer formats.
ID maps
Most World Machine data is a heightfield: a smooth value between 0 and 1 at every point. An ID map instead holds a whole number at every point, such as a material number, a region number, or a biome index. IDs are never blended: a point is either material 3 or material 4, never 3.5. World Machine has two ID map formats:
- Byte Grid: IDs from 0 to 255. Compact, and enough for most material maps.
- Integer Grid: Much larger IDs, for when you need more than 256 distinct values.
Devices such as Texture Weightmap (in Material ID mode) produce ID maps, and the Colorizer can display them in color.
How to Use
Connect a heightfield or ID map to the input and choose the format you want in Output Format.
To view or process a material ID map as a heightfield:
- Connect the ID map to the input and leave Output Format on Heightfield.
- Set Min ID to 0 and Max ID to the highest ID in your map, so the IDs spread across the full 0 to 1 range.
- Filter or combine the result like any other heightfield.
To build an ID map from a mask:
- Connect a heightfield, for example a terraced or quantized mask, to the input.
- Set Output Format to Byte Grid.
- Set Min ID and Max ID to the range of IDs you want the mask’s 0 to 1 range to cover. For four materials numbered 0 to 3, use 0 and 3.
How the conversion works
Min ID and Max ID define which range of IDs corresponds to the heightfield’s 0 to 1 range:
- Heightfield to ID map: A height of 0 becomes Min ID, 1 becomes Max ID, and values in between are rounded to the nearest whole ID. With the defaults of 0 and 255, a height of 0.5 becomes ID 128.
- ID map to heightfield: Min ID becomes 0 and Max ID becomes 1, with the IDs in between spread evenly. IDs below Min ID become 0, and IDs above Max ID become 1.
- ID map to ID map: IDs pass through unchanged, except that any IDs outside the Min ID to Max ID range are clamped to it. IDs are not rescaled between the byte and integer formats.
- Heightfield to heightfield: The input passes through unchanged.
When converting to a Byte Grid, any ID above 255 is stored as 255.
Inputs
| Port Name | Type | Required | Description |
|---|---|---|---|
| Primary Input | Heightfield, Byte Grid, or Integer Grid | Required | The map to convert |
Outputs
| Port Name | Type | Description |
|---|---|---|
| Primary Output | Heightfield, Byte Grid, or Integer Grid | The converted map, in the format chosen by Output Format |
Parameters
Output Format
Default: Heightfield Options: Heightfield, Byte Grid, Integer Grid
The format to convert the input into.
Min ID
Default: 0
The ID that corresponds to a height of 0. Typed in rather than set by slider.
Max ID
Default: 255
The ID that corresponds to a height of 1. Typed in rather than set by slider; you can enter values above 255 for integer grids with many IDs. If Min ID and Max ID are equal, converting IDs to a heightfield gives 0 everywhere.
Tips and Tricks
- When building IDs from a heightfield, use a mask with flat steps (such as the output of Terrace) so that each region lands cleanly on one ID; a smooth gradient produces a band of every ID in between.
- Setting Min ID and Max ID to the same values in both directions lets you round-trip a map from ID to heightfield and back without changing it.
- To make a mask from a single ID or range of IDs, use the Select by ID device instead.