Search Unity

Hexagonal map generating and lighting problem

Discussion in 'World Building' started by Wojzax, Feb 14, 2020.

  1. Wojzax

    Wojzax

    Joined:
    Jul 22, 2014
    Posts:
    34
    So I'm generating hexagonal map from hexagonal prefab. Checking height with heightmap, adjusting height of middle verticles (red ones) and adjusting height of other verticles to blend with neighbour hexes.
    The problem is lighting of the map - it generates hard edges between every prefab as seen below.
    I know it's probably like this because multiple objects equals doubling verticles. Is there a way to kinda "weld" those neighbour verticles?

     

    Attached Files:

  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    To get smooth shading, you would need to adjust the vertex normals of those edge vertices as well as the positions. You've matched the positions, but the normals (which you're probably letting the mesh auto-calculate) do not match across the border between hexes.

    Any reason you don't create the whole map as one big dynamic mesh? That would be easier and probably more performant, too.
     
    Wojzax likes this.
  3. Wojzax

    Wojzax

    Joined:
    Jul 22, 2014
    Posts:
    34
    You mean procedurally generated without the use of premodeled mesh parts? I'll try figure it out, although don't know nothing about it yet.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    But it looks like you're already doing essentially that, as you're warping the hexes to fit the height map. You could do the same thing using a mesh of the entire map at once — that would be even easier, because it would be literally just looking up the height for the XZ of each vertex, and updating its position accordingly.
     
  5. Wojzax

    Wojzax

    Joined:
    Jul 22, 2014
    Posts:
    34
    I'm just saying that it's totally new for me to create mesh from scratch, expecially that complicated mesh. Trying to do it from now on.
    Right now I'm trying to find out how many vertices would it have depending on the number of hexes, so I could create vertices array. And it's already preety hard.

    @Edit:
    Yeah, it's probably too complicated for me. I think I'll just go with borders that will cover up those edges.
     
    Last edited: Feb 16, 2020
    JoeStrout likes this.