index VBO with 2 index array ? is that posible?

Started by
3 comments, last by V-man 16 years, 1 month ago
Hello there Im having trouble rendering my object with index VBO. I use the 3ds max importer from gameTutorials class (if any one knows that). The problem im facing is like this. i have this arrays vertexes Normals texturesUV Problem lays in the fact that texturesUV and vertexes have different indexes. So when i do my rendering everythings work but the texture of the model is wrong. Also the size of texturesUV differe from vertexes and normals. I tryied the fallowing solution. Based on the vertexes indexes at initialization i check wich texture index is for the current vertex and push it in a vector "textures" - so now i have a vector the same size as "vertexes" - but... stii problem - the texture of the model is better (with this i meen - is not as messy as before but still wrong). i can render the object fine with VBO if i compute 3 vectors with all the vertexes all the normals and all the textures uv and bind it to a vbo. But this solution takes me 100fps for my model, since now i dont pass just 3000 individual vertexes but 12000 vertexes - many of them repeating. So i need to do my rendering with indexes. Is there a posibility to have 2 indexes for the vbo - one for vertexes and normals and one for the texturesUV? Thanks alot
Advertisement
No, it is not possible. Your first solution should work though. Make sure that whatever attribute (vertex, normal, texcoord) the index points to is valid. This means possibly duplicating texcoords if there are fewer of them.

I don't know the mesh format you use, but you probably have to sit down with a simple model and understand exactly when and why it skips some texcoords.
Actually you might want to try the reverse. Go through the vertex list and (in essence) duplicate vertexes so that you have as many vertexes as texture coordinates.
thanks - but i always ( i mean with different models ) have much more vertex than textureUV
The GPU is optimized to work with interleaved formats and to have a single index list. It good for the pre transform cache and the post transform cache.
So you have no choice.

12000 vertexes isn't a big deal.
100fps? I can't say much about it since it depends on how much screen space your triangles are taking, how much overdraw you have, the shaders you use.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement