Jump to content
  • Advertisement
Sign in to follow this  
ade-the-heat

load of enemies with md2 format.. findings..!

This topic is 4812 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 have an enemy type in the md2 format. There are about 180 of these enbmies in my level. The md2 format itself takes quite a bit of memory, and to draw these guys really hits the frame rate, so I spent the last 2 days getting the speed up by hook or by crook and this is what I found !! 1. reduce the ram usage by sharing the geometry amongst the enemies, eg create a geometry class for this enemy and pass its pointer to all the enemies, got ram down from 300MB down to 40MB ! 2. obviously frustum cull all of them - but even so we're still left with the situation that you're drawing dozens of these enemies as they are hidden behind buildings. So at the moment I was at 30 fps soooooo.....-> 3. occlusion cull the enemies ! each enemy is about 600 triangles so this is important. I didn't want to use the GL occlusion extension as it was a bit difficult with my set up so I used my own occlusion test: pseudo code:

if enemy in frustum
   get vector V0 from camera position (P0) to the enemy
   loop for each building
       if building->RayCollide(P0, V0, HitPoint)
           //the ray from the camera to the enemy hits this building
           distance = HitPoint - P0
           if distance < V0
              //building must occlude part of the enemy 
              occluded=true;
              break;
           end if
       end if
    end loop

    if !occluded
        DrawEnemy
    end if
endif

fps went up from around 32 to about 42 Note the RayCollide function simply checks if ray hits bounding box of building -simple maths/physics 4. don't re-calcuate the vectors if you can ! eg what I do is that if I've calculated the new vertices in this percentage in the frame - then I re-use these vertices for all the other enemies that get drawn and are running, so, if you're drawing 7 enemies running you're only calculating the vertices once saving you 6 *600 triangles calculations (and their tex and normals) Frame rate went up from 42 to around 52 at the worst case 5. Using glDrawArrays to plough through the already calculated run vectors for the other enemies that are running didn't make any noticeable difference - maybe a frame or two at best 6. Dumping the already calculated run vectors onto VBos and using glDrawArrays with VBO also didn't make much difference. check this out at www.3drock.co.uk (game City Here -- at the bottom) if anyone is listening I hope this is helpful !! Ade

Share this post


Link to post
Share on other sites
Advertisement
tbh, as intresting as these 'tips' are, without seeing the code behind it its hard to tell just how usefull they are.

You could be making some mistakes which are leading to reduced FPS (the VBO section for example) and other things which could also improve things, as such I would advise anyone to take these results with a pinch of salt and not as hard and fast rules.

Share this post


Link to post
Share on other sites
I'd like to point out that the MD2 file format was developed in a time when graphic hardware acceleration was not available/expensive/not as good as today, nowadays going with an skeletal based format such as MD5 is much more flexible, and memory friendly, that said, is a bit harder to write a loader for it.

Also, point 1 is common sence [lol].

Share this post


Link to post
Share on other sites
MD5 format ?! Never heard of it !
I just get up to speed with something and then it all changes !

Phantom- I did say these were simple ball park figures - probably not for the expert 3d programmer

cheers

Share this post


Link to post
Share on other sites
You could try to put all the models in a big VBO to avoid VBO switching. You'll need to calculate the memory sizes for the models and check not to break the maximum vbo size. Texture coordinates will just reside at the beginning of the buffer since they're the same for all instances.

You should also consider doing the frame interpolations in a vertex shader (Nvidia had a demo on that). I don't know how that works but I would guess ideally you load a big VBO with all the frames and use the shader to interpolate between specific frames.

Share this post


Link to post
Share on other sites
Hmm...Quite interesting.
One more question concerning md2 format,as you may have already experienced this sort of problem with MD2 file format,since you've made this post.
Have you ever noticed the thing that a particular vertex may have DIFFERENT texture UV,if it belongs to more than one triangle(So the indixes into texture coord array are different?)?

Share this post


Link to post
Share on other sites
Quote:
Original post by ade-the-heat
MD5 format ?! Never heard of it !


It's the format for Doom 3, it consists really of 3 text formats .md5mesh which contains mesh data (geometry), .md5anim which contains animation data (Quaternions needed) and .md5camera, which has camera information.

More information here, a GPL [sad] parsing library here and an incomplete LGPL [smile] parsing library by me here, CVSROOT :pserver:anonymous@cvs.aeongames.com:/cvsrepo , module MD5Lib, empty password.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!