Jump to content
  • Advertisement
Sign in to follow this  
My_Mind_Is_Going

Optimize model rendering

This topic is 3969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm building a demo that is rendering a bunch of md2 models running around, and I'm looking for a way to speed up the rendering. Currently I'm interpolating between key frames every frame so I'm constantly recalculating vertices and normals and then just using immediate mode calls to draw. The two common methods for optimization are to use display lists and/or vertex arrays right? It doesn't seem like either of these is really applicable to my situation though because I would have to recompile the display list every frame as all the gl calls have changed and the same goes for using a vertex array which I would have to rebuild each frame. Actually using the arrays seemed like it might help but I've implemented it and it actually makes my framerate worse. Is there anything else I might try? I've heard people talk about VBOs, is that my only likely option? Thanks for the help as usual.

Share this post


Link to post
Share on other sites
Advertisement
Another pretty effective way is to have a few buffer slots (2 or 3) and assign these to a specific vertex attrib, then have the VS happily interpolate those vertex keyframes depending on a uniform weight.
This turns out a bit faster on a few systems I've tested but your mileage may vary according to your drivers and memory.

Share this post


Link to post
Share on other sites
i made a guantlet game last century, from memory it ran @ ~20fps with ~200 md2's onscreen this is with a nvidia tnt1, amd k6-300.
moral of the story, md2's contain very few verts ~500 max i think. with plain VAs u should get good framerates even with old hardware, ie look elsewhere for the bottleneck

Share this post


Link to post
Share on other sites
That's the thing, generating the vertex array each frame (I'm not reallocating the memory each frame don't worry) actually seems to be slower than just using immediate mode. I'm testing with about 100 models right now and the framerate is dipping down to around 15 fps. When I comment out the immediate mode calls, so it's still performing all the interpolation calculations the framerate jumps up to like 140-150. This is all on my laptop (1.5GHz Turion) which is pretty weak but not horribly outdated or anything, should be faster than a K6 I would think.

edit: Just checked, this model has 670 triangles so that's 2010 vertices plus the weapon model adds another 366.

[Edited by - My_Mind_Is_Going on August 2, 2007 9:02:16 AM]

Share this post


Link to post
Share on other sites
Quote:
Just checked, this model has 670 triangles so that's 2010 vertices

theres a problem right there
the number of triangles should be quite close to the number of verts ie with 20percent

ie a triangle does have 3 verts but the neighbouring triangles share 2 of these verts
ie 2 triangles
<|>
have 4 different verts not 6

Share this post


Link to post
Share on other sites
No offense to zeds but that calculation he came up with doesn't matter. Because either way, the GPU draws the same amount of triangles.

VBO's are in the GL 1.5 specification, you should have it even on a 5000 series nvidia card (no idea about ATI).

Seriously VBO's are the way to go. But first:

How many frames of animation do you have?

One frame of animation will cost you 2010*3(coordinates)*3(normals), which isn't that bad. If you have alot of textures/models/etc, then static frames are going to eat your GPU memory fast.

Another thing, are you interpolating for each model? If so , thats probably eating your CPU like mad.

Share this post


Link to post
Share on other sites
I eliminated all the unnecessary vertices but using a vertex array is still slower than immediate mode which seems pretty stange.

I have to calculate all the interpolated quantities with either method so the difference between the two is that in one I have ~2000 glVertex calls and in the other I write ~350 vertices to a vertex array and then send an index array of ~2000 values, the latter being the (slightly) slower of the two. Does this sound wrong it anyone else?

Edit: I thought it might be the CPU but just commenting out the glVertex,glNormal, and glTexCoord calls in the inner loop causes the frame rate to jump by like 80-90 fps. I am interpolating for each model but it seems like I have to since I don't don't have any way to know which models are in which animation state (especially since they can have variable interpolation rates), they're all pretty much doing their own thing.

As for VBOs being part of the GL 1.5 specification, I've never used extensions before for anything but don't I have to use them to access any features beyond GL 1.1 or something? I'm really not clear on how the whole windows drivers vs. vendor drivers business works.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!