Sign in to follow this  

Why would combining meshes in a model make it SLOWER?!

This topic is 3725 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 doing a game that requires a lot of trees and I'm trying to make it faster. I'm using Blender to make the single tree model that I'm using so far. The model has one trunk cone and three cones for the leaves/branches, one above the other. So each tree requires 4 draw calls total. I've always been under the impression that fewer draw calls is faster, so I modified the tree in blender by combining the three leaf/branch cones into one mesh. Now each tree requires only two draw calls. But here's the weird part: Drawing the exact same scene I get... 4 draw calls per tree = ~40 FPS. 2 draw calls per tree = ~31 FPS. That's just plain weird. I was thinking about creating a function that would combine the models of buildings into one big model since they don't move, but after seeing how lowering the draw calls for the trees actually made performance worse, well... it doesn't seem like such a good idea anymore. Any ideas why this is like this? ~ C

Share this post


Link to post
Share on other sites
I guess the first question is how are you drawing these trees? Using OpenGL or DirectX or maybe some custom renderer? Are you drawing only the trees in the scene? How many polygons are there per tree? How many trees? There a hundreds of different variables that can cause the effect you are witnessing.

Although it is in general faster to batch your polygons when sending them to the graphics card, in some cases it might not be.

Edit: My fault that second question's answer is DirectX, I should have looked at where this thread was.

Share this post


Link to post
Share on other sites
no idea, but keep in mind as you are doing this kind of thing to check that blender hasn't been overly generous and given you double-sided faces along the way so that you are drawing double the faces that you even realised or meant to.

Share this post


Link to post
Share on other sites
Well, let's see. I'm using the debug runtime, so I'll try the retail. There are about 300 trees in the scene currently. Each tree has 20 vertices and 16 faces. There's no difference between the tree models other than one having four meshes (5 verts and 4 faces each) and the other having two meshes (5 verts/4 faces for the trunk & 15 verts/12 faces for the 3 combined leaf/branch cones).

I'm using XNA, so a fairly typical model drawing loop is used...

for (CModel m = list; m != null; m = m.next)
{
Matrix[] transforms = new Matrix[model[m.type].Bones.Count];
model[m.type].CopyAbsoluteBoneTransformsTo(transforms);

foreach (ModelMesh mesh in model[m.type].Meshes)
{
foreach (Effect effect in mesh.Effects)
{
// Set up the effect.
}
mesh.Draw(); // Should get called twice for the "optimized" model
// and four for the other. Twice is slower.
}
}

Gonna go try this all in retail mode...

~ C

Share this post


Link to post
Share on other sites
When you say to try it in retail mode I assume that means to select "Start Without Debugging" in Visual C#.

With Debugging
--------------
2 Call Trees: ~30-32 FPS depending on how much of scene I'm looking at.
4 Call Trees: ~40 FPS depending on how much of scene I'm looking at.

Without Debugging
-----------------
2 Call Trees: ~30-32 FPS depending on how much of scene I'm looking at.
4 Call Trees: ~35-47 FPS depending on how much of scene I'm looking at.

In all cases when I look up at the blackness it increases to the max 60 FPS, which is strange to me since I haven't added any optimizations that would draw any less of the scene depending on where you're looking. It always draws everything.

Also, the results vary without any reason that I can think of. Sometimes it runs faster or slower than other times, but these are the most common results. What's always true is that I get at least some increase in FPS without debugging and also always with the 4 call trees.

~ C

Share this post


Link to post
Share on other sites
Quote:
Original post by PDX_Catalyst
Also, the results vary without any reason that I can think of. Sometimes it runs faster or slower than other times, but these are the most common results. What's always true is that I get at least some increase in FPS without debugging and also always with the 4 call trees.


I think all you're bumping into here is the realization that there is no one single magic variable that controls performance of 3D applications. Many variables contribute and interact in surprising ways. This is why we are always telling people to profile actual executing code/models and optimize by way of measurements instead of "well I reduced the number of draw calls, so it should automatically increase performance". That would only be true if the number of draw calls was the limiting factor in the application.

Have you tried doing a profile of the frame time using PIX and identify where the time is spent vs. the two implementations? Using PIX or some other measurement tool is the way to optimize.

Share this post


Link to post
Share on other sites
No, where do I find this PIX that you speak of?

And thanks to everyone so far for taking the time to reply.

EDIT: Nevermind, I found PIX. It's part of the SDK.

Start

--> Microsoft DirectX SDK (April 2007)

--> DirectX Utilities

--> PIX for Windows


Gonna check that out now, thanks a ton.

[Edited by - PDX_Catalyst on October 1, 2007 5:29:23 PM]

Share this post


Link to post
Share on other sites

This topic is 3725 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this