Question

image showing my uv mapping problem

As shown by the picture above, one vertex needs to map to two different uv coordinates. I know that I can index verities with another buffer by binding it to GL_ELEMENT_ARRAY_BUFFER, but this binds the the uv in the same index. I can't find any documentations or article showing how to index uv's. I think that there is a way to do this, because it seems like something that people would find useful. How do I do it ?

Was it helpful?

Solution

Simply said, there is no way to index individual attributes of a vertex. The use of an element/index buffer applies to sharing a permutation of attributes e.g. position, uv. Since one of the attributes cannot be shared, neither can the other attributes. A simple solution to that problem, is duplicating the required information to construct a new permuation (with a different uv-coordinate).

Effectively what you need to have support for, are multiple element/index buffers, one for each attribute: element/index buffer for normal attributes, element/index buffer for uv attributes, element/index buffer for positional attributes. But in the current generations of either OpenGL (3 or 4) or DirectX (11) (and presumably on a hardware level itself) this simply does not exists.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top