Search code examples
openglvbotexture-mappinguv-mappingvao

How can I specify multiple UV coordinates for same vertexes with VAOs/VBOs?


I am in a situation where I would like to use VAO/VBO to recycle the same vertexes and use indexes to speed up rendering.

All is fine, apart my textured models use UV coordinates and for the very same vertexes (approx >80%) I may end up having different UV coordinates based on which triangle I'm expected to be rendering (in fact, I'm using md2 models and textures).

This way of rendering was fine and dandy for good old immediate mode; now days, what is the best way to address this and render through VAOs/VBOs?
What comes to mind is to explode the triangles and create very large VBOs with repeated vertexes so that I can link the proper UV coordinate to each of the "same".

I have to say I don't like this... any idea?

Ps. For folks who don't understand the format: if you want to use texture mapping, I believe you have to use the custom UV coordinates based on the triangle you're rendering. Otherwise the texture colours are all messed up!


Solution

  • All is fine, apart my textured models use UV coordinates and for the very same vertexes (approx >80%) I may end up having different UV coordinates based on which triangle I'm expected to be rendering

    Then they are different vertices. A vertex is the whole combination of all its attributes (position, normal, color, texture coordinates, etc.). If only one of these values is different you're dealing with an entirely different vertex.