Monday, June 21, 2004

[Ant Attack] Optimizing

Well here's a screen shot...


1024x768 23kb gif


...and here's another...


1024x768 19kb gif


...spot the difference?

Yeah, there are less polygons in the second shot!

I decided that I really should reduce the poly-count. Antescher runs fine on my machine, but I've been playing with more complex maps, some of which really slowed the whole thing down. Something had to be done.

In the murky past I'd written a Quake level builder that converted NetHack style ASCII map to quake levels. This found the most efficient way of grouping tiles into bigger tiles using all sorts of cunning tricks. However the payoff for getting maximum efficiency was that it'd take a short while to figure it out. This isn't a problem for Quake levels, as once you've done it, the level is "compiled" and you don't need to do it again. I want the levels in Ant Attack to be loaded in on the fly each time, so it's got to be fairly quick.

This means that I opted for a just good enough solution. At the simplest level, if you could join up each tile with the one next to it, you've cut the number of faces in half right away. It's possible to do slightly better than that. But the most I've gone for is merging 3x3 tiles, then 2x3, 3x2, 2x2, 2x1, 4x1, 3x1, 2x1 and finaly 1x1.

You can see the effect that has in the shot below...


1024x768 11kb gif


There's another good reason for not going over the top and merging as many as possible. The base of the wall along the side could be made up of a really long single tile, but then you start running into tiles that start a long way infront of you and finish somewhere behind you. Computing wise it's slightly easier to break this down into smaller units so those behind you can be ignored.

Figures!

For Antescher
Before Optimizing: 33,972 polys
After Optimizing: 13,612 polys

So number of polys was reduced by about 60% The effects on frames per second is an average of 15% speed increase, which is really 0% increse in places where the frame rate was high anyway, and increases of about 30% when the scene is complex.

0 Comments:

Post a Comment

<< Home