Rendering models with vertex arrays
Hello people.
I'm trying to optimize my game using vertex vertex arrays. I'm doing this in Half-Life, so I have to convert the studio model format to something I can use with vertex arrays. What I do is multiply shared vertices whenever it's necessary, and then I arrange the triangle indexes so that I can directly render them with the vertex arrays. For the duplicated vertices, I add
Now, when I render the models, I transform the original number vertices, and calculate lightvalues for each vertex normal. After this is done, I arrange the lightvalues paralell to the vertex indexes, and I copy the positions of the extra vertices over from their original indexes' positions.
Finally, I set the color and vertex pointers, and I render each of the meshes that have a different texture. I use a glDrawElements call for this.
The problem is, that even if I cancel out vertex transformations and lightvalue calculations and only render the objects untransformed, my rendering is still a lot slower than the immediate method.
I'd like to ask if anyone has a suggestion, because I'm in trouble with this.
Thanks.
Quote:Original post by Andrew Lucas
Now, when I render the models, I transform the original number vertices, and calculate lightvalues for each vertex normal. After this is done, I arrange the lightvalues paralell to the vertex indexes, and I copy the positions of the extra vertices over from their original indexes' positions.
You do this every frame? If so, why? If your data isn't highly dynamic I'd suggest doing once at load time. And if it is dynamic, I guess it would be the coordinates, normals etc. rather than the overall array layout (number of vertices, indices etc.).
Why are you doing lighting calculations and/or transformations in software (on the CPU)? Are you doing anything fancy that isn't possible with standard T&L or shaders?
Hehe.
What I do for each vertex is first add the ambient and shade lighting, and then add light from dynamic lights in. This is lighting. Now, after this I transform vertices by their bone matrices. I'm quite unsure wether this is possible to do using shaders, because to be honest I haven't worked with shaders yet, and I have yet to read any tutorials.
Thanks.
Andrew.
What I do for each vertex is first add the ambient and shade lighting, and then add light from dynamic lights in. This is lighting. Now, after this I transform vertices by their bone matrices. I'm quite unsure wether this is possible to do using shaders, because to be honest I haven't worked with shaders yet, and I have yet to read any tutorials.
Thanks.
Andrew.
Probably you are using some unsupported format like GL_DOUBLE or like 24 bit color
http://www.opengl.org/wiki/Common_Mistakes#Unsupported_formats_.231
Or maybe
http://www.opengl.org/wiki/Common_Mistakes#glEnableClientState.28GL_INDEX_ARRAY.29
and in any case, read about vertex arrays
http://www.opengl.org/wiki/Vertex_Arrays
and everything is on this page
http://www.opengl.org/wiki/General_OpenGL
http://www.opengl.org/wiki/Common_Mistakes#Unsupported_formats_.231
Or maybe
http://www.opengl.org/wiki/Common_Mistakes#glEnableClientState.28GL_INDEX_ARRAY.29
and in any case, read about vertex arrays
http://www.opengl.org/wiki/Vertex_Arrays
and everything is on this page
http://www.opengl.org/wiki/General_OpenGL
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement