How do you Calculate Vertex Coordinates for Triangles to Smooth Terrain Transitions on a 2D Grid Map

34 Views Asked by At

I’m working on a 2D grid-based map where each cell represents a specific terrain type (e.g., water, sand, grass). I currently have a functional map with distinct terrain zones, I’m looking to visually enhance it by smoothing out the edges between different terrain types by using triangles. The first image shown is how the grid is originally laid out with no triangles. The second image shown is what I’d want the map to look like with the enhancement.

I want to know how I could get the coordinates that make up each vertex (grid position) of the each of the triangles keeping in mind that the top left of the cell is the grid position. Is there a specific algorithm I could use to determine this?

Original Map Enhanced Map

I started by identifying the border cells where two different terrain types meet. I attempted to generate triangles along these borders by creating vertices at the midpoint of the edges of each cell. However, I'm struggling with creating the algorithm to place these vertices correctly and to determine how to form the triangles for a smooth transition.

0

There are 0 best solutions below