1
\$\begingroup\$

I am trying to create a textured hexagonal tile map in opengl. I have the VBO and respective index buffer. Additionally I have a texture atlas for texturing individual tiles. I'm attempting to create a distinct texture for each hex without mixing the textures.

I understood that one should use a pair of (U,V) texture coordinates for each vertex. Now if the tile map would not be indexed and have the overlapping vertices, I could just set the texture coordinates for each vertex and get each hex rendering the correct texture. However, with indexing the overlapping vertices are gone and I can only set single pair of texture coordinates for each vertex which results in the textures mixing inside the hexes. Is there a way to texture tiles with indexing or another alternative approach to creating hex maps with different textures?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Vertices can only be merged when every single attributes are the same.

A vertex can have the same position as another without having the same UV, color, or differ in other attributes.

You can still use an index buffer to merge the vertices of triangles making up each individual hexagons (7 vertex instead of 18 to make a nice pie with a center, or 6 (instead of 15) if you don't mind long triangles) but no two tiles will share vertices.

\$\endgroup\$
1
  • \$\begingroup\$ So the individual tiles can be indexed but the whole map grid cannot. Thanks, this should do. \$\endgroup\$
    – sdkkss
    Nov 13, 2016 at 2:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .