pixel.gif (45 octets)   The Virtools Garage
--> My place for experimental Virtools files
  pixel.gif (45 octets)  
    pixel.gif (45 octets)       pixel.gif (45 octets)    

Features
Home
Virtools Files
Useful Tips

Links
Virtools Website
Swap-Meet

  pixel.gif (45 octets)  

Here you will find tips about how to optimize performance and filesize for your Virtools projects. The first ones may seem obvious, but are often overlooked. Hope you'll find this useful. Feedback is appreciated...

PS: clicking on the links opens the Virtools files. To download them, right click on the links and save them on your drive.


#1 - File Compression

Before posting files on the web, make sure you activate the file compression. In the pulldown menu Options/Preferences/Misc Controls, check the 'Compress files' checkbox and set the compression level to at least 5. This is a non destructive compression. It just takes a bit more time to start due to decompression, but download is much faster. Also, texture compression doesn't hurt in most cases (the checkbox right below). A quality of 80 often works fine.

Filesize can be DRAMATICALLY recuded. Check out the compressed (21kb) and uncompressed (93kb) version of the same content and compare if you're not convinced (it's a simple rotating torus with environment mapping).


#2 - Sharing Meshes Instead Of Copying Them

When copying objects in Virtools, don't copy the associated mesh, materials and textures unless necessary (that is pfor instance, if you want to have different textures on your two objects). Sharing the media (mesh, material and textures) reduces the filesize (media is stored only once) and can increase performance (less textures need to be loaded on the 3D card).

Check out the following examples. In one case, media are shared between all the objects (shared media, 29kb), in the other they are not (copied media, 156kb). The result is the same, but the filesize is not...


#3 -
Turning 'Copies' Into 'Instances'

As seen in Tip #2, it's often better to share media between objects instead of copying them. It is especially the case with meshes and textures. Sometimes, you'll want to "clean" your app by turning 'copies' into 'instances' (several objects sharing the same media). For instance, if you import a model of a city from 3DS Max, with lots of traffic lights, you'll retrieve them in Virtools with a separate copie of the mesh for each of them. To share the same mesh for all traffic lights, simply remove all the copies expect one (in the mesh folder in the level view), and then attach the remaining mesh to each traffic light 3D entity (in their mesh setup).

If you have too many objects, attaching the remaining mesh might become a tedious process. In that case, you can batch it using a script. Look at a batch script in this example. It automatically attaches the same mesh to every object in a given group. You can reuse this script in your own project.


#4 -
Single mesh vs split mesh

Object size is a important consideration if you want to render your scenes fast with Virtools. Here is why: for rendering, Virtools checks if the bounding box of an object is in the view frustum. If not, then it is left aside. Otherwise, Virtools transforms all the polygons of the object, in order to render them. This is a CPU consuming task. So assume you have a huge landscape, made of only one object, with 100k polygons. Although your camera might only actually 'see' a tenth of it, since the object is in the view frustum all its polygons will be transformed (wasting CPU time).

If you cut your 100k poly landscape into 20 smaller 'sub-landscapes', each with 5k polygons, you can greatly improve the framerate, as only the sub-landscapes which bounding boxes are in the view frustum will be taken into account. You will often end up processing say 3 sub-landscape (3 times 5k polygons), instead of one big mesh (100k polygons).

Check out this landscape example. Use the mouse to look around, numpad to move. Press spacebar to switch between a single big 8192-polygon mesh and the same landscape divided in 16 512-polygon meshes. Depending on your hardware, the framerate improvement will range from "worthwhile" to "impressive" :) I suggest that you take a look at this file in Virtools, with the profiler, to see how many faces are processed at a given time. Also interesting is the use of fog with an adequate camera far clipping plane.

 

 

  pixel.gif (45 octets)   Feedback
E-mail me
Swap-Meet Forums