Search code examples
c#unity-game-enginehexagonal-tilestexturing

Unity: Texturing a Shoreline in a Hexgrid


I'm a beginner programmer and new to Unity. I'm currently practicing hexgrid building with Unity5. My current hexgrid consists of flat hexes, which have either a grassland or ocean 2D texture. (Current hexgrid)

I'd like to have a sandy shoreline in my hexgrid (on grassland tiles which have ocean tiles as neighboring tiles).

My question is: what is the best, most efficient way to implement this?

I thought of making a texture for each possible shoretile, but that would be about 64 different textures depending how many ocean tiles the grassland neighbors and from which direction.

I also need "blurry" texture lines between desert and grassland hexes and deep ocean and shallow ocean hexes, and I have no idea how to do that...

Any advice is appreciated. Thanks!


Solution

  • I think you should only need 4 or 6 textures. With hexes you can only have two scenarios in a land/sea corner. Either the shoreline is forming a peninsula (convex land/concave sea) or a fjord (concave land/convex sea).

    So two main trapezoid textures that paint a beach from the tile edge inwards would cover all land-beaches on peninsulas and all sea-beaches on fjords.

    In the opposite case you'd just need a small triangular extension of that texture to fill in the gap between the trapezoids.

    This is what I mean: https://i.sstatic.net/3OsY7.jpg

    Source: I once tried to figure out how Alpha Centauri draws its terrain by analysing the texture files. I'm reasonably sure that's how they did it.

    As for handling a desert, grass, sea corner I believe they first blended the land terrains and then overlayed the shoreline.