Guidelines for optimizing object models + test results

Anything to do with Drakan level editing and modifications, post it here! Also this is the place to tell us about your new levels and get player feedback.

Moderators: Arokhs Twin, yangez93

User avatar
Mechanist
Dragon
Posts: 303
Joined: Wed Mar 07, 2018 7:27 pm
Location: Poland

Guidelines for optimizing object models + test results

Postby Mechanist » Fri Feb 22, 2019 1:57 pm

I've done some research into optimizing objects for maximum framerates, for use in the new MP map we're currently making.

This was accomplished by setting up a "test case" level with nothing but the camera, sky, 4 ground tiles, and 4126 copies of an object model used by a "Building" class. This results in a total of ~100k polygons visible on screen at a time.

The reason for using the "Building" class is because it's representative of typical landscape objects - such as trees, bushes, nonpushable boulders, houses, etc.

Of course I did not test the influence of every possible combination of model properties... that would take far too long.
Instead, what I did was to test the effect of changing only one property at a time.

All testing has been performed first with dgVoodoo enabled, then disabled completely (DLL files renamed).
Of course whether the player actually uses dgVoodoo or not on their Drakan install is something that is completely beyond the map maker's control, but it's still useful to have a reference point to work with here.

First off, a quick summary of the results:
  • Baking all materials onto a single larger texture, and readjusting the UVs accordingly, speeds up the rendering by a lot (see note 1 below!);
  • Converting triangles to quads causes an appreciable performance improvement;
  • Using dgVoodoo results in a considerable performance gain (see note 2 below);
  • Having substantial amounts of unreferenced vertices in a model causes a minor amount of slowdown;
  • Using 2-sided polygons is somewhat slower than using single-sided polygons (see note 3 below);
  • Using transparent textures (alpha) on polygons is much slower (roughly doubles the rendering time), since these polygons need to be re-sorted by proximity on every frame.
This leads directly to recommending the following guidelines for model making:
  • Set up your materials and UV mapping to use the fewest possible materials in your models; ideally only 1 or 2 materials per model;
  • Combine/bake textures as required to minimize the amount of distinct materials, as noted above;
  • Use quads wherever possible, instead of triangles;
  • Keep all polygons single-sided, except for those where it is absolutely unavoidable;
  • Minimize the use of polygons with transparent textures on them, where at all possible;
  • Delete all unreferenced vertices;
  • Last, but not least - remember to delete any polygons which would never be visible to the player in any case - such as the underside of a tree trunk, for example.
NOTE 1: If a model uses any transparent polygons, it then requires one texture which has all the nontransparent materials on it, and a second texture which holds all the transparent materials.
Do NOT put any nontransparent materials on an alpha texture, since that causes a serious performance hit!

NOTE 2: dgVoodoo actually causes polygons with transparent textures to be rendered slightly slower instead - however, most of the time, the transparent polygons visible on screen will be no more than about half of all the polygons rendered, so the overall effect is still a net speedup.

Also, Linux users beware: on Linux systems, improperly set up dgVoodoo tends to cause a massive performance penalty instead!

NOTE 3: It seems that the per-polygon rendering time is unaffected by whether the polygons are 1- or 2-sided; however, the engine will render 2-sided polygons regardless of whether they would have been occluded by other polygons from the same model; this then causes slowdown because more polygons have to be rendered than in the 1-sided case.


For reference, here's the raw data:
Reference test case:
134448 POP
101732 POR
8.5FPS (no dgVoodoo)
10.7FPS (with dgVoodoo)
NOTE: using "sort polygons by material" caused no improvement.
The Editor appears to pre-sort the polys at model import time.

2-sided polygons test case:
134448 POP
134305 POR
6.8FPS (no dgVoodoo)
9.9FPS (with dgVoodoo)

Triangles test case:
199632 POP
134260 POR
6.8FPS (no dgVoodoo)
9.4FPS (with dgVoodoo)

Quads test case:
118152 POP
85450 POR
9.7FPS (no dgVoodoo)
11.3FPS (with dgVoodoo)

Combined materials test case (1 texture instead of 4):
134448 POP
101732 POR
10.0FPS (no dgVoodoo)
16.6FPS (with dgVoodoo)

All-alpha test case:
134448 POP
101732 POR
4.3FPS (no dgVoodoo)
3.7FPS (with dgVoodoo)
NOTE: Yes, this was actually SLOWER with dgVoodoo!

Unreferenced vertices test case:
134448 POP
101732 POR
7.8FPS (no dgVoodoo)
9.5FPS (with dgVoodoo)
NOTE: the model had roughly 8x its normal amount of vertices, with the bulk of them being unreferenced by any polygons.

Return to “Drakan Level Editing and Game Mods”

Who is online

Users browsing this forum: No registered users and 2 guests

cron