Sign in to follow this  
Kiamo

Indexed models?

Recommended Posts

Hello, I have loaded MD2s and MS3D binary models, but both have proven somewhat inefficent to render as their tex coords do not match vertices, so I cannot build an index array to draw with.. I have to use direct mode (glDrawArrays). I can get the models rendering pretty fast with this method (I've done about every optimization I can, producing ~11 million tris/sec single texture and light on a Mobility 9600, but I have achieved 55 million with well-optimized indexed meshes before (such as a world) on this same card. I'd like to see in the 20s or better with just straight drawing of models, but I think I would require properlly indexed meshes with shared vertices to achieve this. I was wondering if anyone knew of a model format that gives graphics-rendering friendly indices or knows of a way to optimize other formats (such as these) to be able to draw with such. MD2 and MS3D have triangle indices that reference shared vertex points for position, but the tex coords on both formats do not match. Near as I can tell, in order to blow the arrays out to be drawn, matching a tex coord to a vertex, you have to use one vertex per actual use, meaning no indices (nothing is shared) as 5 triangles may share 1 vertex, but use 5 different tex coords. I hope I made my question clear and thanks for any help.

Share this post


Link to post
Share on other sites
As a pre-processing step you can split and merge vertices to obtain optimal indexing with such meshes. Sometimes a vertex with its uv will be used multiple times and indexing may still be useful.

A more fitting approach is to work with multiple vertex streams, that is, put every vertex element in a separate buffer (one with positions, one with uvs) and then index them as specified. This matches the file format you described and will probably give maximum performance.

Greetz,

Illco

Share this post


Link to post
Share on other sites
Quote:
Original post by Illco
As a pre-processing step you can split and merge vertices to obtain optimal indexing with such meshes. Sometimes a vertex with its uv will be used multiple times and indexing may still be useful.

A more fitting approach is to work with multiple vertex streams, that is, put every vertex element in a separate buffer (one with positions, one with uvs) and then index them as specified. This matches the file format you described and will probably give maximum performance.

Greetz,

Illco

Can you explain this a bit better? How can I use two element buffers? I'm using OpenGL, and, as far as I know, I can only reference one index buffer at a time and all the vertex data buffers indices have to match... Or am I misunderstanding you here?

Share this post


Link to post
Share on other sites
I don't know how MD2 stores stuff, but I've done MD3 before, and MD3 has constant indices, constant uvs, and an array of xyzn frames. So basically, you would create an index buffer, a uv buffer, and your normal and position buffers, with the last two being the size of the uv buffer (NUM_VERTS) times the number of frames of the model (NUM_FRAMES). Layout the frames contiguously and you can just pull something like this.

glVertexArray(3,GL_FLOAT,stride,pointer + frame * NUM_VERTS * sizeof(vertex));

If that's not what you're asking about, sorry :P. If you mean that the same vertex can have multiple uv in the same frame, you just need to make a preprocessor that creates every combination in use, and reworks the indices, or something like that. Barring that, MD3 is pretty easy and pretty nice to work with, for vertex-keyframing stuff.

Share this post


Link to post
Share on other sites
Quote:
Original post by w00f
I don't know how MD2 stores stuff, but I've done MD3 before, and MD3 has constant indices, constant uvs, and an array of xyzn frames. So basically, you would create an index buffer, a uv buffer, and your normal and position buffers, with the last two being the size of the uv buffer (NUM_VERTS) times the number of frames of the model (NUM_FRAMES). Layout the frames contiguously and you can just pull something like this.

glVertexArray(3,GL_FLOAT,stride,pointer + frame * NUM_VERTS * sizeof(vertex));

If that's not what you're asking about, sorry :P. If you mean that the same vertex can have multiple uv in the same frame, you just need to make a preprocessor that creates every combination in use, and reworks the indices, or something like that. Barring that, MD3 is pretty easy and pretty nice to work with, for vertex-keyframing stuff.

I do mean the same vertex can have many different UVs, that is correct, but the problem is when I blow out every possible match, there is now triangle count * 3 unique vertices (in other words, nothing shared)... Unless I am missing a potential trick or doing something wrong. :(

So Direct3D allows you to call multiple arrays with unique index buffers in one draw call?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this