When you create a Box, Plane3D, Cylinder, or Sphere in Sandy, the constructor takes a “quality” parameter.
Generally, the higher the quality setting, the better the appearance of the item (the smoother the sphere, for example). But there are limits at which point the trade-off in performance isn't worth any marginal improvement in quality. Furthermore, you won't notice any quality improvement for certain skins. That is, a red box will still be a red box at different qualities. You'll see the improvement however, when mapping a TextureSkin to a box surface, as the graphic should be less distorted at higher quality settings.
There are other things that affect quality (such as text smoothing for bitmaps?) and the quality of the original bitmap or video being used for skinning. Of course, the amount of distortion also depends on how close the camera is to the object, the field of view, etc.
Here we tally the number of polygons per object at different quality settings. Generally, the higher the polygon count, the higher the quality and the slower the performance. Tri mode is recommended over quad mode when using MovieSkins or TextureSkins, but won't improve quality with SimpleColor skins, for example.
These numbers assume that backface culling is enabled (i.e., the back face is not being rendered). Although each polygon face has a front and a back, the number of polygons stored by Sandy is the same regardless of whether backface culling is enabled. However, the number of polygons rendered is double if backface culling is disabled.
Although the results are the same in Sandy 1.1 and 1.2, the way to access polygon faces differs in the two versions. For more information see Object3D.getFaces() in Sandy 1.1 or Object3D.aFaces in Sandy 1.2.
Here are the results for a Box primitive.
| Primitive | Quality | Polygons per side (Quad) | Polygons per side (Tri) | Polygons total (Quad) | Polygons total (Tri) |
|---|---|---|---|---|---|
| Box | 1 | 1 | 2 | 6 | 12 |
| Box | 2 | 4 | 8 | 24 | 48 |
| Box | 3 | 16 | 32 | 96 | 192 |
| Box | 4 | 64 | 128 | 384 | 768 |
| Box | 5 | 256 | 512 | 1.536 | 3.072 |
| Box | 6 | 1024 | 2048 | 6,144 | 12,188 |
Therefore, for a Box primitive, if q is the quality:
The number of polys per box side in quad mode is = Math.pow(2, 2*q) /4;
Double that number for tri mode, and multiply it by six to account for the 6 sides of a box.
Double it again to include the inside of a box if backface culling is off.
Conclusion: Creating a box with quality greater than 3 is ridiculously processor-intensive and should be avoided. Setting it to 6 or higher will hang many machines.
Here are the results for a Plane3D primitive
| Primitive | Quality | Polygons per plane (Quad) | Polygons per plane (Tri) |
|---|---|---|---|
| Plane3D | 1 | 1 | 2 |
| Plane3D | 2 | 4 | 8 |
| Plane3D | 3 | 9 | 18 |
| Plane3D | 4 | 16 | 32 |
| Plane3D | 5 | 25 | 50 |
| Plane3D | 6 | 36 | 72 |
| Plane3D | 7 | 49 | 98 |
| Plane3D | 8 | 64 | 128 |
| Plane3D | 9 | 81 | 162 |
| Plane3D | 10 | 100 | 200 |
The maximum quality allowed is 10.
The formula for a Plane3D primitive is therefore:
number of polygons per plane = (q*q)
Again, double it for tri mode, and double it again if backface culling is disabled.
You should see significantly less distortion at a quality setting or 2 or 3. Experiment to see if it is worth going higher than that.
Here it is for a sphere in Sandy 1.1. Note that tri mode uses more polygons than quad mode, but not twice as many. And note that the quality maxes out at 5.
| Primitive | Quality | Polygons total (Quad) | Polygons total (Tri) |
|---|---|---|---|
| Sphere | 1 | 21 | 28 |
| Sphere | 2 | 32 | 48 |
| Sphere | 3 | 50 | 80 |
| Sphere | 4 | 72 | 120 |
| Sphere | 5 | 98 | 168 |
| Sphere | 6 | 98 | 168 |
In Sandy 1.2, note that the numbers are the same until you get to quality 6 or higher, because I've tweaked the max quality to allow it to go as high as 10.
| Primitive | Quality | Polygons total (Quad) | Polygons total (Tri) |
|---|---|---|---|
| Sphere | 1 | 21 | 28 |
| Sphere | 2 | 32 | 48 |
| Sphere | 3 | 50 | 80 |
| Sphere | 4 | 72 | 120 |
| Sphere | 5 | 98 | 168 |
| Sphere | 6 | 128 | 224 |
| Sphere | 7 | 152 | 266 |
| Sphere | 8 | 200 | 360 |
| Sphere | 9 | 230 | 414 |
| Sphere | 10 | 300 | 550 |
I don't see any clear pattern/formula that relates q to the number of polygons (the maximum allowed quality for spheres in Sandy 1.1 is 5). Double the numbers above if backface culling is disabled.
Conclusion: Even at its highest quality, the number of polygons is not prohibitive, but spheres tend to be much more processor-intensive than other primitives because they look lousy at very low quality settings, so you tend to use a quality of 5 to achieve smoothness.
Here are the numbers for a Cylinder (in Sandy 1.2, these also apply to the Cone and Conic classes, as a Cylinder is just a special type of conic section). In quad mode, the formula for the number of polygons is usually q + 2 (except for a quality of 6).
For a Cylinder in tri mode the number of polygons is usually 4*q (half for sides and half for endcaps). Again, a quality of 6 is an exception.
| Primitive | Quality | Polygons total (Quad) | Polygons total (Tri) |
|---|---|---|---|
| Cylinder | 1 | 3 | 4 |
| Cylinder | 2 | 4 | 8 |
| Cylinder | 3 | 5 | 12 |
| Cylinder | 4 | 6 | 16 |
| Cylinder | 5 | 7 | 20 |
| Cylinder | 6 | 9 | 28 |
| Cylinder | 7 | 9 | 28 |
| Cylinder | 8 | 10 | 32 |
| Cylinder | 9 | 11 | 36 |
| Cylinder | 10 | 12 | 40 |
In Sandy 1.2, you can disable the top and bottom endcaps, in which case the number of polygons in quad mode is equal to the quality setting, q. Double those numbers for tri mode.
I've gone up to quality 40 for a cylinder with no problems. You can probably go higher. For example, a quality of 50 in tri mode would require 200 polygons.
In Sandy 1.2, I've capped the quality limit at 200, but there is no real reason to go that high, as the improvement in quality isn't worth the performance hit.
The trouble with cylinders is that no matter how big you make the cylinder height, there are still only one or two polygons vertically (depending on whether you are in quad more or tri mode. The polygon increase is only on the endcaps and around the perimiter. (The new Conic class in Sandy 1.2 allows you to suppress the endcaps, and Petit is working on a cylindrical surface class that lets you set the vertical quality as well.)
You can't set the quality for Line3D, Sprite3D, Sprite3D, Pyramid, and Hedra primitives. External models, such as ASE files can have many polygons, so check the complexity before using them.
Planes max out at a quality 10, which is 200 polygons in tri mode. That's quite a few but not ridiculous.
Cube quality doesn't max out in theory, but in practice a quality higher than 4 is astronomically processor-intensive and ill-advised.
Cylinders don't max out until at least 50 or more.
Sphere max out at quality 5. Below 3, they look rather like footballs.
To find out what other features affect the performance , such as the alpha setting, see here.
Cheers,
Bruce