Search Unity

Generate a Masking Texture of Hex shapes in C#?

Discussion in 'Scripting' started by TheProfessor, Jul 2, 2015.

  1. TheProfessor

    TheProfessor

    Joined:
    Nov 2, 2014
    Posts:
    74
    I have the problem in that I want a game that uses a hex grid and to have the tiles of my textures blind when two tiles with different textures are adjacent, similar to Civilization.

    One idea I was suggested was by having a series of masking textures like so:



    Where you see it is composed of Black and White hexagons but with a blurred outline so that it enables textures to be blended together.

    Each masking texture generated would correspond to a particular terrain type, I could use shaders to blend my textures together for my whole mesh.

    If this seems feasible what I need to figure out is how to generate a texture composed of hexagons with blurred edges when adjacent to a differently coloured hexagon.

    The current solution I am going to use in the meantime as the above is so far above my technical ability, is to use masking but on an individual tile by tile basis and pass the shaders of the tile the texture of the adjacent tile and use masking like this:



    This I feel should also work and requires less elaborate coding at the moment; but I feel that the above solution would be more consistent and less reliant on my brush skills.

    Are there any suggestions or tutorials for how to either blend tile textures across adjacent tiles or otherwise how do I generate a texture of hexagons with a blurr effect?
     
  2. TheProfessor

    TheProfessor

    Joined:
    Nov 2, 2014
    Posts:
    74
    So I can probably just blur the mask filter, somehow, I'd need to double check shader forge, but I'm unsure how to create a texture populated by shapes.