This is a pretty simple question. If I was to use multiple images in a single texture for a 3D cube, how would I go about re-using each vertex (having 8 total vs 24)?

With a single buffer of 8 vertices, I don't see how I'd properly reuse the UV values.

Any help on that? I know it's not terribly clear, but I figured it was a simple question.

The 2D method is pretty easy, the next coordinates would be the same as the first (0,0 and 0,1 respectively).

Texture Mapping enter image description here

However, the above 3D version has me quite befuddled.


1 Answer 1


Just duplicate the vertices. Sharing vertices is generally for when you have “smooth” surfaces with attributes that are continuous across the adjacent edges, not sharp edges like those of a cube. It is quite typical to use duplicated vertices when drawing cubes.

  • \$\begingroup\$ When I duplicate the vertices, I get 'cracks' between faces at certain distances/angles. Having one large object fixes that issue. It's not a problem to generate all 24 vertices, it just seemed extremely unnecessary to multiply memory usage by 300%. This is all for a cube-like terrain with very small 'cubes' and a very large need for very long range view distances. Keeping memory requirements low is already going to be a challenge for me with millions of quads visible at a time. Even if the cracks is an issue to be fixed via another method, that's still a lot of extra memory to be used. \$\endgroup\$
    – Mythics
    Commented Jul 11, 2012 at 2:10
  • \$\begingroup\$ Cracks should not be a problem as long as you generate identical vertex positions for the duplicated vertices; the simplest way to ensure this is to scale your world so that cube vertices have integer coordinates. (If you're still getting cracks, I suggest you post screenshots of your scene so we can look for possible problems.) Also, if you are doing a cube terrain then you should not be drawing all six faces of every cube, but only the visible ones (ones that are not facing onto another opaque cube), which will cut down on the number of would-be-duplicated vertices. \$\endgroup\$
    – Kevin Reid
    Commented Jul 11, 2012 at 3:39
  • \$\begingroup\$ You're definitely right about the cracks. Figured out that it was a texture issue. My next question then lies in the possibility of using multiple UVs per vertex rather than duplicating the entire vertex. I've not done anything like that before and it might warrant posting it as a separate question, but if you have any familiarity with it, please let me know. Thanks :) \$\endgroup\$
    – Mythics
    Commented Jul 11, 2012 at 13:11
  • \$\begingroup\$ Unfortunately, I'm not familiar with DirectX. But in (modern) OpenGL, it is not possible to reuse some vertex attributes but not all of them. I doubt you will find such a feature; in most current 3D graphics applications, nearly all of the vertices are “smooth” as I put it (defining the interior rather than the edge of a smooth surface), so it is probably not worth supporting this special case. \$\endgroup\$
    – Kevin Reid
    Commented Jul 11, 2012 at 16:30
  • 1
    \$\begingroup\$ As someone who's worked on such ideas in XNA, I don't think there's any way around using 24 vertices per cube. Aggressive culling of non-visible faces helps mitigate the problem. Even if you could store all 3 tex coords in one vertex, you'd also have to store data which tells the shader which coordinate is for which face, how to identify when to draw what- quickly your 'compact' vertex will become bloated and just as costly. \$\endgroup\$
    – A-Type
    Commented Jul 11, 2012 at 19:22

You must log in to answer this question.

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