Sculpts

From Open Metaverse Wiki

Opensimulator: Documentation: Asset types: Sculpts

Sculpts are very much the neglected child of Second Life and opensim. The idea, a compact file format for complex meshes, is brilliant but the way it was implemented caused countless problems. Sculpts as they are currently used in Second Life and opensim doesn't have much of a future and should usually be avoided but a revamped take on the basic concept may become a very valuable asset class for an online virtual reality where streaming cost always will be a major concern.

Basic description

A sculpt is perhaps best described as a mesh grid:

The number of vertices along each axis is determined by the resolution of the sculpt map and it is always 2n+1 with a minimum of five and a maximum of 257. The maximum number of vertices is 1280 – 1024 mapped vertices plus the stitching vertices. The illustration shows the smallest possible grid with four mapped and one stitching vertice along each axis – the stitching vertices are marked in yellow.

The xyz coordinates for the mapped vertices are determined by the RGB values of specific pixels in the sculpt map. The stitching vertices are always co-located with some of the mapped ones, which ones depend on the stitching type. On the UV map, the vertices are spaced evenly as shown in the illustration.

Practical use

Sculpts as they are today have very limited use and are mainly supported because of the large number of old ones still in use. There are still a few situations where they can still be relevant though:

  • Large objects (SL only): Sculpt maps can be applied to megaprims which means they can be made much bigger than meshes in SL. Because of this, they are still the only realistic option for surround landscapes among other things.
  • Land impact reduction (SL only): The land impact of a sculpt is capped at 2 which often is much lower than the same build would end up with as prims or mesh.
  • Streaming cost reduction: When used efficiently, sculpts will have considerably lower streaming cost than similar meshes. Unfortunately that doesn't necessarily mean they load faster since the parsing code is so inefficient but it can still sometimes be a relevant consideration.
  • Morphing: It is possible to change the shape of a sculpt with scripted map switches. This is generally not a good idea since it's rather heavy both on server and client but it's still an option worth keeping in mind.
  • SL-opensim compatibility (opensim only): Usually it's better to convert to mesh if a sculpt is transferred from SL to opensim since hardly any of the sculpt's advantages apply to opensim. This can be a rather cumbersome process though and if it's a well made and well optimized sculpt map, there isn't always that much to gain so converting may not be worth the time and effort.

The sculpt map

The sculpt map is a texture. For some reason that has never been fully explained, the parser doesn't use all pixels in the map. If the map has 4096 pixels or less, it will use the values from every other pixel. If the map has more than 4096 pixels, only every 4th, 8th, 16th or 32nd will be used. This is to keep the total number of mapped vertices down to the 1024 max.

Prim parameters

Stitching

The stitching vertices are always co-located with some of the mapped ones. There are four different stitching types:

  • Sphere: All stitching vertices have the same coordinates as the first mapped vertice (lower left corner in the illustration)
  • Torus: The upper row of vertices in the illustration are co-located with the ones in the lowest row. The right column are co-located with the leftmost vertices.
  • Plane/none: Each stitching vertice is co-located with the nearest mapped one.
  • Cylinder: The right column are co-located with the leftmost vertices, the top row of vertices are co-located with the next-to-highest row. In other words: The top row in the illustration is treated the same way as with plane/none, the right column the same way as torus (or maybe it's the other way round – need to check this).

The Mirror parameter

The mirror function does exactly what the name says: mirrors the shape along the x axis.

Normals and the Inside-out parameter

All normals are smooth, however it's important to note that although the stitching vertices are co-located with mapped ones, they are not joined and will have their own normals. The inside-out parameter flips all normals.

Bounding box

The bounding box covers the entire range of possible vertice coordinates from <0,0,0> to <255,255,255> so the nominal size of a sculpt can be considerably larger then the actual size of the visual model and the two don't necessarily have the same This is sometimes used as a feature by sculpt creators in four different ways:

  • LoD strengthening: An oversized bounding box will increase the LoD swap distances
  • Offsim installations: Keep the bounding box center on the region but the entire visual model outside the region borders
  • Off center rotation: For doors etc.
  • Invisible barriers: A physics shape extending well outside the visual model. This was used creatively in the original Linden Realm.

Physics

Sculpts are usually set to phantom because the physics are rarely useful, in SL because the physics shape doesn't match the visual shape, on opensim because it can be rather heavy on the server. In SL the physics is the convex hull of a torus with curve resolution 9 and the size of the bounding box. On opensim the physics is a triangle list matching the visual model fairly precisely.

LOD

Sculpts use a very crude simplification method for LoD models and this is one of their major flaws. For every LoD level every fourth vertice is eliminated. The formula for LoD swap distances is the same as the one for polylist meshes and prims with curved surfaces.

Multiface sculpts

This is a hack and not in any way officially supported.

A sculpt is basically a modified torus prim with the vertices relocated according to the map. An untwisted torus only has a single face of course but is possible to tweak other prim types to accept sculpt maps giving sculpts with multiple faces. The result can be rather unpredictable though, with some vertices way out of position (sometimes even outside the bounding box) and other vertices completely missing.

Possible upgrades

Although the current sculpt system is seriously flawed, the concept is very sound, potentially offering significantly reduced streaming cost for moderately complex meshes. Unfortunately there is not much chance Linden Lab will will be willing to invest development resources on this so a Sculpt 2.0 project will have to be opensim only.

Simple upgrades

  • A faster parser: based on a polylist mesh rather than a prim template.
  • Basic decimation, step 1: Remove all collapsed tris and the resulting loose vertices.
  • Basic decimation, step 2: Remove all "zero angle" vertices. This may be a bit more complex than the upgrades listed above and there may be some cases where it causes unwanted changes in the normals. But it's still worth considering.

Advanced upgrades

File format

The sculpt map file format is one of the sculpt system's weakest points, second only to the crude intepreter. A binary or even xml format would be far more suitable than an image file.