The Slicer asset allows you to split a larger terrain into smaller individual slices that are close to identical to the source terrain. You can slice a single terrain or a group of terrain, and you can target specific areas of the terrain or slice the entire area of the terrain.
These slices are intended to serve as replacements for the original terrain or terrain group. Once you perform a slice, you technically do not need the original terrain or group, although we recommend keeping the prefabs in your project just in case they are needed in the future.
The slices and original terrain (or group of terrain) should never be used in the same scene together, otherwise Unity will display some Warning Messages in the Console!
You can create this asset by selecting from the Top Menu Bar:
Assets -> Create -> Deep Space Labs -> Terra Slicer -> Slicer
or by right clicking a folder (or inside a folder) within the Project Hierarchy and selecting from the pop up menu:
Create -> Deep Space Labs -> Terra Slicer -> Slicer
By default this Asset is given the name Slicer, however we recommend changing this name to something that will better help you differentiate it with other Slicer Assets in the future.
Using a Scriptable Asset allows us to very easily store the slicing configuration so that it can be re-used in the future. This is important as you may wish to make modifications to the source terrain and re-slice it. The use of a Scriptable Asset also allows you to duplicate the configuration settings to make small modifications for additional source terrain or experimental slices.
There are two reasons:
1) The Unity Terrain system does not store individual position and rotation information for detail meshes and grass. Instead, each terrain is divided into individual zones, and then a detail mesh and/or grass density is applied to each zone for each detail mesh or grass you are using. The slicing tool is able to copy these densities from the source terrain to the slices, however how Unity places the actual detail meshes and grass seems to be up to the terrain shader and is a bit random. Therefore, you may notice some very slight differences in the position and rotation of your detail meshes and grass, between the source terrain and the slices.
2) Unity stores Alphamaps similar to how heightmaps are stored, with alphamap pixel values starting on the bottom and left edges of the terrain and extending to the top & right edges. However, unlike the heightmap, the alphamap is stored as a power of 2 value.
This is unfortunate as it means when a slice is performed, one or more edges of the slice usually end up falling within the gaps between multiple alphamap pixels, rather than on those pixels directly.
To account
Slicing a single terrain is the most common use case, and offers an advantage over group slicing because you can target a smaller region of the terrain (rather than slicing the entire area). This allows you to target specific features of the terrain and extract only the detail you want. In addition, you can create a single terrain slice of your target area, or multiple slices in a grid pattern, depending on how large you want your slices to be.
A terrain group is a group of terrain that share a common name. By slicing a group, you can remove the hassle of slicing each terrain in the group individually, which would be time consuming and tedious. The disadvantage of slicing a group is that there is no ability to target a sub region of the terrains in the group. In reality, targeting a sub region does not make much sense anyway, as doing so would produce slices that do not line up with the slices from other source terrain in the group. As such, you only have the option to slice the entire area of each terrain in the group.
The number of slices, size of the slices you can produce and the area that is sliceable is restricted due to how Unity Terrain work. In short, Unity uses a resolution based system, where different aspects of the Terrain have a unique resolution tied to them. For example, the shape of the terrain mesh is controlled by a heightmap, which has a minimum and maximum resolution of 33 x 33 and 4097 x 4097 respectively. Each aspect and its corresponding minimum/maximum resolution is listed here:
Min: 33 x 33 | Max: 4097 x 4097 - Heightmap Resolution (Holes Resolution is always equal to Heightmap Resolution - 1, so has a min value of 32 x 32 and max value of 4096 x 4096)
Min: 16 x 16 | Max: 4096 x 4096 - Control Texture Resolution
Min: 16 x 16 | Max: 4096 x 4096 - Base Texture Resolution
Min: 0 x 0 | Max: 4048 x 4048 - Detail Resolution
The resolution of each aspect cannot be less than the minimum resolution listed above, therefore we cannot produce slices of any size. Instead, the minimum size of an individual slice is controlled by the resolutions of the source terrain, and in order to perform any type of slice, the resolution of your input terrain(s) must be at least twice the size of the values specified above.
The higher the resolutions, the smaller the slices can be. Also keep in mind that even if one resolution (such as the heightmap) allows for smaller slices, a different resolution (such as the Base Texture Resolution) being smaller is enough to limit the size of the slices. That is, the smallest resolution is usually the determining factor for how small your slices can be.
One exception to this rule is the Detail Resolution. If you set this resolution to 0 (because you are not using detail meshes/grases), the Slicer will ignore the Detail Resolution and won't considere it for the minimum resolution determination. If not using a value of 0, the minimum Detail Resolution is equal to the 8 x 8.
In addition to the resolution restrictions, all terrain used by Unity are restricted to a power of 2 value (or power of 2 + 1 for the heightmap). As such, the size of a slice is restricted to be 1/2, 1/4, 1/8, etc. (1/power of 2) the size of the source terrain. You will never, for instance, be able to produce a slice that is 1/3 the size of the source terrain.
The size of the slices dictates the number of slices you can produce. For instance, if you are able to produce slices that are 1/4 the size of the source terrain on each axis, then you can produce 4 slices on each axis, for a total of 16 terrain (4 x 4). If, on the other hand you are only able to produce slices that are 1/2 the size of the source terrain, you can only produce 4 terrain in total (2 on each axis).
Finally, because the slicing grid must be aligned to the pixels of each resolution, the grid snaps to certain imaginary lines on the terrain, and you will notice it does not move smoothly. This cannot be avoided, however when the resolutions of the input terrain(s) are larger, the movement will appear smoother as you will be able to move the grid in smaller increments.
In order to slice a terrain or a group of terrain, the input terrain must be in prefab format. This is necessary to ensure that the reference to the terrain does not become lost when closing the editor, or performing any action that forces Unity's Serialization process to execute.
If you have a terrain prefab instance in an open scene, you can drag that game object to the appropriate field on the Terrain Slicer, and the tool will automatically locate the prefab root asset in your project hierarchy. That root prefab is then stored on the Terrain Slicer asset, rather than the prefab instance from the scene.
The Slicer is capable of producing prefabs as output, but not scenes. If you need to generate scenes from the Terrain Prefabs, you can use the Scene Generation Tool which is included with SAM - The Streamable Assets Manager.