Generating on Mesh Surfaces Tutorial
This tutorial continues from the Getting Started tutorial. It is recommended you complete that one before starting this.
Note
Generating on Mesh Surfaces is only available in Tessera Pro
By default, Tessera generates tiles in a regular grid - every cell is the same and shape, and placed in the same relation to each other.
Surface mesh generation allows you to ignore this entirely. Instead, each tile will be placed in a cell corresponding to the face of a given mesh.
That means each cell will have a different shape, and the adjacency connections between cells are determined by the edges of the mesh. The local y-axis used when designing the tile will get rotated to match the normal of the face, and similarly the local x and z axes will point tangent to the face.
Let's make a micro-planet as an example.
Start with the generator created in the previous tutorials and find the Surface Mesh
property in the inspector. Click the icon and select cube_sphere
, a mesh that comes in the Samples folder of Tessera Pro. You can use any quad mesh (i.e. all the faces have exactly 4 edges).
Depending on which assets you use, you may see the following warnings:
The surface mesh feature requires certain import settings to be configured. Press the fix it buttons will automatically change the assets as needed.
After setting a mesh, the inspector UI will have changed a little:
If you enable gizmos, you should be able to see a wire mesh.
That's pretty much it. Hit generate, and see the results.
As you can see, one tile has been generated for each face of the mesh. Further, Tessera has transformed any meshes associated with the tile to make them fit the face. That gives us a totally seamless result with non square tiles, even though all the designed tiles were square.
Tessera will transform meshes found in MeshFilters, MeshColliders and BoxColliders. It'll also modify the position, rotation and scale, so the created GameObjects interact most compatibily with the other features of the game.
Caveats
A few features do not work with meshes:
- You cannout use Tilemap Output as Unity Tilemaps expect a regular grid of tiles.
- The mirror constraint is not supported.
When pressing the Generate button in the Editor, it is not possible to undo the action as Unity can get extremely slow serializing all the transformed meshes.
The mesh distortion pushes around vertices, but never adds any. You may need to add extra vertices to your tile models so that adjacent tiles still line up after distortion.
You are recommended to use tiles with Reflectable and Rotatable enabled. It still works when they are turned off, but it can be hard to control the direction of each cell's local x-axis. It is determined by the order of vertices in the face of the mesh, and most editor programs do not let you easily manipulate this.
Smooth normals
You can configure if normals should be smoothed between adjacent faces of the mesh. For smoothing to work, the surface mesh must have UVs configured.
Multiple layers
Just as regular generators support a 3d layout of tiles, so does generating on a mesh surface. By setting the Layers property (or size.y
in the API) to a value larger than one, you will stack multiple copies of the mesh surface above one another. Each layer is an expansion of the mesh along the vertex normals by the amount given in Tile Height (or tileSize.y
in the API).
If you've set up your generator with the 3d tiles and skybox described in the 3d tutorial, then you can get results like the following on cube_sphere
.
Submeshes
If you are Mesh object you've selected for the surface has multiple submeshes, (i.e. multiple material slots), then you can filter which tiles are appropriate for which part of the submesh, similar to volumes, above.
The Generator inspector will automatically detect this case. Simply turn on "Filter By Submesh" and then select which tiles appear where.
Tessera Pro comes with a City example that demonstrates this.
Triangle grids
The above tutorial demonstrated using cube tiles on a quad mesh. But if you use triangle tiles you can instead use triangle meshes.