# How can I round coordinates into Hexagon?

Hello! I’ve been testing out unity and made basic random generated basis for biomes, but I encountered an problem that I would hope you could help me solve. As you can see from the image below the error is as follows: When different climates meet (for example dry and hot) it tends to create small chunk of biome of both qualities. The image shows only small proportion and hot regions are generated with equal values as drought so the size difference is only local.

The problem is because regular forest biome takes up around 75% of total surface area it tends to mix irregular zones only at the edges creating these stupid looks… alt text

Either way this is not the problem by itself as I’ve come up with solution in theory, that I can’t work with in practice. Rather than calculating biome of each (x,z) location it calculates biome of chunk and spreads it to surrounding blocks. However I do not like the look of the outcome as large square biomes…

These rounded areas happened with this method :

`````` float x = Mathf.Round(a / chunkSize) * chunkSize;
float y = Mathf.Round(b / chunkSize) * chunkSize;

int biome = math.GetBiome(x, y);
/* math is my own class used to handle various calculations and in this case utilizes perlin noise to create temperatures and output biome id */
``````

Simply breaking it down and reconstructing the rounded number. So into the main question! How can I get biome value in hexagonal pattern instead of squares?
If it wouldn’t be a problem I would like full code because I spent 6 hours trying to figure this out without single success and I’m really bad at using tutorials in practice… The code should be in form where you input block coordinates and you get the coordinates of closest hexagon.
(to replace block’s original coordinates when calculating biome)

Have you tried mathf.lerp?