Consider the typical draw call
webgl.bindBuffer(webgl.ELEMENT_ARRAY_BUFFER, faces);
webgl.drawElements(webgl.TRIANGLES, nfaces * 3, webgl.UNSIGNED_SHORT, 0);
Now, let's say for simplicity that I am rendering a cube. If the component of each Vertex are its position px, py, pz and its normal nx, ny, nz, then I have 8 unique vertices.
I can then keep a buffer with these 8 vertices, keep another “faces” buffer with indices to which vertex each face uses, and there you go, shared vertices through an indexed drawElements call. Fine.
When we introduce UV coordinates, though, I don't have 8 unique vertices anymore. I end up with each face requiring exactly three unique vertices.
The faces buffer, then, might as well be [(0,1,2), (3,4,5), (6,7,8) … and so on].
So, as vertices carry more information, they become impossible to share. Yet, I need an index buffer in order to be able to call drawElements. An index buffer whose content ends up being nothing but a sequence of 0 … nverts-1 integers.
Am I missing something?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…