Original Post
hey,
i'm trying to load a collada file into vertex and index buffers with triangle primitives for DirectX11.
the problem i'm facing now is the speed of loading loads of indices.
lets say i have a mesh with triangles and vertices containing only POSITION coordinates, no NORMALs, no TEXCOORDs, for the sake of simplicity.
with indices like this:
indices:"0 1 2 0 2 3 0 3 4"
specifying 3 triangles with vertices at "0 1 2", "0 2 3" and "0 3 4".
if i were to just simply copy those indices into an index buffer,
and build a vertex buffer by looking up the vertices in the vertex source once for each index,
then i would have a lot of duplicate data:
"a b c a c d a d e"
and a redundant index buffer of:
"0 1 2 3 4 5 6 7 8 "
this means 3 times vertex a, 2 times vertex c and 2 times vertex d in the example above.
so when i'm loading the vertices, i only add vertices when they are not unique, when they are, i just simply refer to the first occurrence of that vertex.
this gives me a more acceptable vertex buffer:
"a b c d e"
and an index buffer
"0 1 2 0 2 3 0 3 4"
but this process requires me to look into the vertex buffer to find matches and their index.
Even when accelerated by using a dictionary system it's still rather slow.
Due to the required look-ups to previous data, this can't be efficiently ran parallel across threads either.
I know this should is a one-time operation, as the results of this operation will be saved in an own data format for the meshes.
But i'd still like to know if there is a faster way to do this?
i'm trying to load a collada file into vertex and index buffers with triangle primitives for DirectX11.
the problem i'm facing now is the speed of loading loads of indices.
lets say i have a mesh with triangles and vertices containing only POSITION coordinates, no NORMALs, no TEXCOORDs, for the sake of simplicity.
with indices like this:
indices:"0 1 2 0 2 3 0 3 4"
specifying 3 triangles with vertices at "0 1 2", "0 2 3" and "0 3 4".
if i were to just simply copy those indices into an index buffer,
and build a vertex buffer by looking up the vertices in the vertex source once for each index,
then i would have a lot of duplicate data:
"a b c a c d a d e"
and a redundant index buffer of:
"0 1 2 3 4 5 6 7 8 "
this means 3 times vertex a, 2 times vertex c and 2 times vertex d in the example above.
so when i'm loading the vertices, i only add vertices when they are not unique, when they are, i just simply refer to the first occurrence of that vertex.
this gives me a more acceptable vertex buffer:
"a b c d e"
and an index buffer
"0 1 2 0 2 3 0 3 4"
but this process requires me to look into the vertex buffer to find matches and their index.
Even when accelerated by using a dictionary
Due to the required look-ups to previous data, this can't be efficiently ran parallel across threads either.
I know this should is a one-time operation, as the results of this operation will be saved in an own data format for the meshes.
But i'd still like to know if there is a faster way to do this?