Optimization
Mission Statement ] What's a World Builder? ] Guild Goals ] Vision ] Suburbs Model ] Promotions ] Guidelines ] Good World? ] [ Optimization ] Share My World? ] Join egroup ] Join the Guild ] Submit Your World ] Units of Measure ] URNs in URLs ]

 

What does file optimization mean and how can I do it?

World Builders frequently talk about optimizing their worlds, sometimes the meaning of this is not absolutely clear. The point is that smaller files download faster and this allows people to see your creation quicker (like before they run out of patience).

The first trick that we employ is probably one you have probably already seen. We compress the ASCII file with a utility called gzip. This converts a human readable text format into a binary compressed format. All VRML plug-ins know to gunzip these files automatically when they see a special code in the compressed file's header. Typically we gzip the WRL file only, thought you can gzip HTML files, it only makes sense when you have a very long page. It makes less sense to gzip files which are already binary and already compressed such as GIF or JPG image files. Gzip started out on UNIX operating systems but has been ported to other systems such as windows. It is a free utility. You may find it a http://www.gzip.org and it is already built into many applications such as Flux Studio© and VRMLpad©. Our friend the Rev. Bob Crispen has added a windows style graphical user interface called WinGZ© that is free and easy to use for single files. All your VRML files served from the Internet should be gzipped (an exception may be for files that are 1 or 2KB, then it is more work to gunzip them that it is to download them).

A second trick we often employ is to use a tool called Chisel (by Trapezium). Chisel first checks your files for correctness with a subprogram called Vorlon. This keeps you from publishing files with structural or syntax errors. After Vorlon is done, you can then "thin down" your files with several of the programs options (called chisels). Chisel should be used with caution and I recommend making a backup copy of your file or saving each step as a new file name as you go along. Chisel is sold as a stand-alone application, but there is also a free web based version available.

The first Chisel is to Format the file by stripping out blanks at the ends of lines and wrapping continuous fields of data onto one line where permissible. Surprisingly, this simple step may knock 10% off the overall file size.

The next Chisel, Clean allows you to remove needless code that some modeling applications create. It doesn't tend to have a large impact of file size, but makes for cleaner code.

The next option is Condense. The selection that has the most impact is Adjust Numeric Resolution. Some modeling tools output more precision than is typically needed in VRML. A number such as 0.012345678 may be converted to 0.012 without affecting the scene, but dramatically affecting download time. If 1.0 is a meter, then 0.1 is a decimeter, 0.01 is a centimeter, and 0.001 is a millimeter. Typically we do not have a need for sub-millimeter accuracy in a multi-user environment. This Chisel has the most dramatic effect on large files with many Indexed Face Sets or other complicated geometry. You should always use this Chisel on your final product. You can use the other Condense options if Chisel indicates that you have issues in any of those areas.

Three decimal place precision is usually fine for our purposes. Many authoring applications out put 5 to 7 significant digits.


1.0 = one meter
0.1 = one tenth of a meter (decimeter)
0.01 = one hundredth of a meter (centimeter)
0.001 = one thousandth of a meter (millimeter)


If you look at a meter stick, you will understand why real world scaled objects do not need more precision than that. IF you are modeling molecules, galaxies or nuclear reactors; then you may need greater or less precision, but for a couch....

Selecting create DEF/USE will allow Chisel to examine the code and if it finds duplicated geometry (two identical IFS's) it will DEFine the first one and replace the geometry with a USE statement (use the 1st geometry in this other place). This makes the code more compact, but also may tend to make it less readable by humans. I recommend this as a last step on a file that you are pretty certain you won't have to hand edit again (or keep a copy of the original).

Remove unused DEF and Shorten DEF names will knock 2-3% off the file but will also make it much harder for a human to interpret the file by hand editing later. I would use this with caution and when it is really needed.

I do not tend to use the Reorganize options unless I am doing something special. The un-inline files can be handy if you are assembling many little worlds through a "master" file. If I recall, it resolves problems of using the same name for something different in several of the "imported" files.

The Reduce chisel can be handy to knock excess faces out of overly complex geometry. There are better polygon reduction tools on the market, but these in chisel do a fairly good job of reducing excess baggage from files. Use with caution, use lightly, and make backups.

The Mutate options are interesting, but also just used for special effects. The Pointcloud option is useful for reducing a bunch of planes (IFS) into a series of points. The ElevationGrid to IFS can be handy when trying to use a complicated "land surface" in an application that does not support Elevation Grids (e.g. Flux Studio). This option may not be available in WebChisel. I use the IFS in Flux Studio while locating objects on the ground, then switch back to the Elevation Grid on my final product (Elevation Grids are much smaller that IFSs).

 

VRMLpad by Parallelgraphics will also format, and reduce numeric precision, and remove unused DEF names when you use it to publish files.

The third and the best trick is, of course, hand coding optimized files from scratch. People do not tend to type unneeded "fat" into their files.  Some tools employ scripts that may be more efficiently coded by hand also, so even the scripts can be optimized for efficiency.

So, if you are not "hand-coding" or typing your worlds from scratch, it is best to know that there are tools available which may be used that will help to improve downloading and rendering time. Optimization is not required, but everyone will thank you for it.

 

Back ] Home ] Up ] Next ]