# Tiling a Sphere with Hexes

It is not possible to tile a sphere with regular hexes. However, we can map a wrapped grid to a sphere in such a way that it looks like the sphere is tiled with hexes.

The basic idea is to use a wrapped hex grid (using a parallelogram wrapping). A section inside the parallelogram – the “window” – is projected to a sphere (the projection we use is an approximation). For best effect, this section should display approximately half the cells in the width, and half the cells in the height. If we have more cells along the width, it will feel like the sphere has more than 360 degrees as we rotate it along the vertical, and similarly for the height. To make it possible to rotate the sphere, we simply move the grid, reprojecting the window each frame. Once we have moved exactly one cell, we snap the grid back to the original position, and move all the cell textures one cell to the direction of rotation. (This is similar to the scrolling example).

Here is a demo of this scheme.

- Use arrow keys to rotate the sphere.
- Use <SPACE> to toggle seeing the complete grid.
- Use <C> to toggle between cameras.

[unity src=”2272″]

Download the package below, and import it into a project that already has Grids: