Archived

This topic is now archived and is closed to further replies.

Speedy models...how do they do it?

This topic is 5647 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 just successfully made a 3D Studio max model (it''s a robot figure) and imported it into my game. It was too large, so I had to use glScalef to reduce it''s size. I am now getting 30 frames per second...I used to get 60 before I stuck my model in there!?! Why has this reduced my framerate by half? It''s a simple model consisting of only one texture, it''s not even animated. I am using display lists to precompile it, yet it still slows stuff down to a crawl. I don''t get it. Half-Life, Quake etc. they all have numerous models running around whilst explosions are going off and buildings and terrains pass by. I play these and get decent frame rates. How do they do it?

Share this post


Link to post
Share on other sites
What else do you have going on in the scene? The pro''s also use advanced frustrum culling algorithms and octrees. Might want to check those out in greater detail.

-Vic

===
www.cnunited.com
===

Share this post


Link to post
Share on other sites
dont turn of vsync. Vysnc isn''t your problem and personally I always enable it because I hate to see tearing.

As for the culling, if you are rendering a single mesh on screen then its not your issue. Ignore that guy too :-)

Instead, check the poly count of your model. Maybe you made it to complex. Depending on your machine specifications, 300 polys may be minimum detail for a caracter or something of the sort vs 10,000 maximum. If you utilized meshsmooth or some other functionality of 3dsm you may easily produce a overly detailed model.

Check the 3dmax help files for the polygon counter. Check how many polys you got. (you may need to check the poly count of the exported model, depending on what you used on the model) Let us know the poly count and your machine specs.

-SniperBoB-

Share this post


Link to post
Share on other sites
most q3 models are approx 1000 vertices or so (or was it polys?) anyway, modeling things in an app like 3d studio max can lead to creating very high amount of vertices. thus requiring more horsepower to push.

what is your REAL framerate before and after placing the model in the scene? turn of vsync and give the numbers. with vsync off your scene could be running at 61 frames per second before the model was added and 59 after. thus you actually get 60 and 30 with it on (since you MUST wait for the refresh of the moniter with vsync on). this is why any benchmark/framerate is pretty much meaningless unless you turn off vsync.

SnprBoB86, obviusly you dont understand the limitations on framerate vsync can impose. you are correct that culling is probably not the issue, but he will need to implement culling anyway. he dont specify how many instances of the model he is drawing per frame, and it could very well be a culling problem.

also most pro games have vsync off by default since it slows things down. also they use culling and have low vertex count models (remeber vertex count is ussually more important then polygon count due to the transformations being done).

i personally think its a combo of a very high polygon count model coupled with vsync. though, its very likly its more vsync then the model, because a single millisecond can determine the difference between 60 and 30 frames per second if vsync is on.

Share this post


Link to post
Share on other sites
quote:
It was too large, so I had to use glScalef to reduce it''s size.

Well that might be your problem right there. Resize it in max, don''t make the CPU work more to resize it in game.

------------
aud.vze.com - The Audacious Engine <-- It''s not much, yet. But it''s mine... my own... my preciousssss...
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155

Share this post


Link to post
Share on other sites
Jeez, does anybody else here really know how vsync works besides me and SniperBob? You guys have kinda the right idea about what it does, but his particular problem doesn''t have anything to do with vsync.

Share this post


Link to post
Share on other sites
quote:
Original post by crrrazydan
Jeez, does anybody else here really know how vsync works besides me and SniperBob? You guys have kinda the right idea about what it does, but his particular problem doesn't have anything to do with vsync.


a person is right, vsync could be having an effect on it. If you don't think so, then you don't understand how vsync works.

If your monitor refreshes at 60Hz, then that means you got 16ms to draw the frame. If he was taking 15ms before, then that's fine, he'll get 60fps. If the model increase the time taken to render the scene to just 17ms (i.e. 2ms more) then you'll drop to 30fps. To show you, here's a diagram:



The top line is the game running at 15ms-per-frame. It ends up running at 60fps, because it hits every vsync. The bottom line is the game running at 17ms-per-frame. It ends up running at 30fps, because it misses every other vsync.

edit: fix up img tag...


codeka.com - Just click it.

[edited by - Dean Harding on June 26, 2002 4:02:35 AM]

Share this post


Link to post
Share on other sites
Yeah, Dean''s right. I had this problem with vsync in my engine, and when I turned it off, the performance went through the roof. Don''t forget that you can use the EXT_swap_control extension to modify the vsync through your program.

However, while I think that vsync is one of the problems, using glScalef is almost certainly killing performance, as LockePick notes. In every OpenGL document I''ve read, it always says to never let the hardware scale your polygons. Just think, every vertex of your model is being scaled before it''s displayed. That will certainly degrade performance, especially when you bring animation into the mix...


Movie Quote of the Week:

"I''ve seen things you people wouldn''t believe. Attack ships
on fire off the shoulder of Orion. I watched C-beams glitter
in the dark near the Tannhauser gate. All those moments will
be lost in time, like...tears in rain. Time to die."

- Roy Batty, Blade Runner.

Try http://uk.geocities.com/mentalmantle - DarkVertex Coming Soon!

Share this post


Link to post
Share on other sites
if you dont have rescaleNormals, or normalize ative then a scale is nearly free, because you still multiply each vertex with a matrix, and that matrix isnt bigger or smaller if you have/omitt scale in it, the only overhead is the curr_Matrix * Scale which should be once a frame..

Share this post


Link to post
Share on other sites
Hey guys, thanks very much for all the feedback. Here is an update and some answers to your questions.
By the way, I am still getting half the framerate when I use my 3dsm robot model.

General info:

My PC is an Athlon 800 with 256 MB Ram and Geforce 2 GTS.
I am only importing/drawing one robot model.
The frame rate goes down when my camera is pointing at/viewing the robot. Makes sense, OPengl doing it''s own frustrum culling.

When VSYNC was still on:

My FPS without model was 60.
My FPS with model was 31.

With VYSNC switched off:

My FPS without model shot up to 80 ( yippee ).
My FPS with model halfed to 40 ( boooo ).

My model is made of 2629 vertices and 4938 faces. It has only one texture at the moment.
I have also now reduced the scale of my model in 3DS Max so I dont have to do it in my opengl application.

So basically, it was a good idea to switch off vsync, but my model still reduces my frame rate by an unacceptable level. Why?

Please help.

Share this post


Link to post
Share on other sites
I''d say there is something pretty wrong with your system here. 4900 tris @ 40 fps is less than 200k tris/sec. This is about 1/100th of the GF2 GTS brute-force power. You achieve the same level of performance than i did on a Vaudoo 2, five years ago on my P200. I''m not sure that drawing the model is the bottleneck. You only get 80 fps when nothing is drawn ? You should get more than 400 fps! I would first suggest that you make sure you are running full hardware acceleration (check the pixel format!), or not falling back to a software path (like using the accum buffer or other "extra" feature..). An update to the drivers, if not already done, would greatly help.

Y.

Share this post


Link to post
Share on other sites
One thing I can add about frame-rates is how you output the actual frame-rate you calculated.

I would recommend NOT using something like
SetWindowText( )

and use your own font rendering with the FPS displayed in the corner or something.

I noticed in running tests that you can get a lot of inaccuracies using the SetWindowText( ) function.

Anyway food for thought

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Dark_Streak

The frame rate goes down when my camera is pointing at/viewing the robot. Makes sense, OPengl doing it''s own frustrum culling.



HAH! Fillrate. What are the dimensions of the texture you''re using?

Share this post


Link to post
Share on other sites
Just wanted to point out to people that the scale operation isn''t what is causing the slowdown... he said he was using a display list, and in this case only the resulting vertices (ie after all matrix transformations have been applied) are being stored... there should be no re-transforming when the display list is called.

Other than that, I am of no help

Share this post


Link to post
Share on other sites
how much geometry is before the model is shown? halving the framerate would make it seem the model is the same amount of polys as the world thus 80 or 40 is quite low (since you say you are drawing the model with display lists and a single texture thus should be using only 3 or 4 calls at most per fram to draw the model).

are you loading the mdoel every frame?
are you creating teh display lists every frame?
allocatin gmemory every frame?

if so there may be problems. your robot model has TONS of vertices and polys, but since your only drawing it once it should not kill yoru performence too much.

post the actual per frame drawing code. omit things not impoartnat and replace with psudeo fuction names. for instance if you are loading a model or something, just say LoadModel() or LoadWhateverYouareLoading(). important are actual drawing calls.

Share this post


Link to post
Share on other sites
um. how the heck could glScale possibly slow the rendering down?! it''s only scaling the modelview matrix, it doesn''t ''add'' any extra calculations beyond that... Unless of corse, you do normalize your normals... but on a GF, this is effectivly a free operation.

Share this post


Link to post
Share on other sites
Have you checked for software rendering?

do a glGetString(GL_RENDERER). If it returns anything along the lines of GDI Generic, you''re software rendering.

- Josh

Share this post


Link to post
Share on other sites
I am still having no luck, and I am still no closer to solving this mystery. Which is quite frankly beginning to really p*** me off, because what sort of game will it be if it struggles to display one model.

Anyway, I wont give up till it''s solved. Thanks to everyone who is trying to help me solve this.
Just to clear something up...I am drawing a terrain and a sky plane. I did not explain this before, some of you thought I was just drawing a model - this will explain why my framerate is lower , but it still does not explain why I am getting half the framerate when I draw my model.

I used glGetString(GL_VENDOR), glGetString(GL_VERSION) and glGetString(GL_RENDERER) and was told that I am using: NVIDIA Corporation V1.3.0 (Geforce 2 GTS/PCI/3DNOW!).
So I take it this means Im definately not in software mode.

In answer to Anonymous Poster: The texture I am using for the model is 256 * 256, as are most of my textures.

Here is my drawing code:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

g_Camera.Look();

setLights();

glEnable(GL_LIGHTING);
drawBaddy(10,vNewPos.y,10); // This is where I draw the model.

glPushMatrix();
glTranslatef(0,(vNewPos.y + 0.0001f),0);
glDisable(GL_LIGHT0);
glDrawShed();
glEnable(GL_LIGHT0);
glPopMatrix();

glDisable(GL_LIGHTING);
RenderHeightMap();
glEnable(GL_TEXTURE_2D); // terrain turns off texturing

glBindTexture(GL_TEXTURE_2D, g_Texture[3]);
RenderSkyPlane();

glDrawHUD();

SwapBuffers(g_hDC);

And thats it. In my initialisation code I do the following to load my model:

Load3ds.Import3DS(&g_3DModel, FILE_NAME); // Load my model
BuildBaddy(); // Draw into a display list.


Below is my function for calling the model display list.

void drawBaddy(float x, float y, float z)
{
glDisable(GL_FOG);
glPushMatrix();
glTranslatef(x, y, z);
glRotatef(shedRot,0,1,0);
glCallList(glBaddies);
glPopMatrix();
glEnable(GL_FOG);
}

Thanks guys. Hope you can see something I can''t

Share this post


Link to post
Share on other sites
I am running the game at 800 * 600 with 16 bits per pixel.

Changing these values makes no significant difference. I can run it in windowed and fullscreen mode.

Also, I realise that the way I calculate FPS and display it to the window frame may not be the best way to check FPS, but this is irelevant because I notice a slight stutter when viewing the model in my scene, which implies the model is indeed incurring a performance hit. Why though?

On the point of using models, I would like to improve it. So, anyone know of any good tutorials helping people learn how to create models for games. I have seen lots of tutorials for 3D studio max, but they are all concerned with making nice scenes and special effects...and they dont seem to be bothered how many polygons their scenes will end up having. Fair enough, I guess as they wont be sticking what they have made into a game.

[edited by - Dark_Streak on June 28, 2002 5:07:00 PM]

Share this post


Link to post
Share on other sites