Search code examples
3dblenderdirectx-11vertex-shadercollada

Why do 3D models have duplicate vertex positions with different uv coords


I am experimenting with exporting the Collada format from Blender, and with using more complex objects and texturing, I have noticed during the index "p" section, it will list the same vertex information but using different normals and uv coords.

Two main questions that I feel are pretty important.

1: Why? Shouldnt it only have 1 vertex position and 1 UV coord for that position?

2(the most important question of all): What happens if this vertex information gets put into the Vertex Shader out of order? For example, Index 1 vertex, and index 10 vertex share the same Position, but have different Normals and UV Coords. What if Index 10 went first, and then Index 1? And vice versa, does this change anything inside of the Pixel Shader? How does this effect the rest of the pipeline?

Thank you!


Solution

  • A vertex is defined by the combination of all information that defines it. So your vertices are five dimensional: (x, y, z, u, v). For any two vertices, if u1 != u2 or v1 != v2 they are not the same vertex. Fixed-pipeline GPUs didn't support the extra level of indirection that would come if you wanted to say "vertex is position A plus texture position B plus normal C plus ...", and it is still not standard to add that level of indirection with programmable GPUs because it usually amounts to spending more on memory bandwidth than it saves. You could, but people generally don't.

    A vertex shader has no concept of where the vertex it is processing fell in the ordering; as long as the geometry pipeline keeps track then no problems ensue.