I wrote about getting 64 boxes from a single sculpt, for a row of dentils. The boxes end up being connected by unwanted strips, which can be hidden in the beams that the dentils are attached to. But to make separate boxes with no visible connections, you need to make sure that the interface between them in the sculpt map consists entirely of quadrilaterals that collapse to a single line or point.
Here's the layout of a single box in a 4 by 4 sculpt map. Cylindrical stitching provides the 6th face.
Two of these directly adjoining won't work:
In the middle column, the top and bottom squares collapse to invisible single edges, but the middle one has four distinct vertexes and will show up.
Adding two buffer strips of vertexes solves the problem:
Now all the squares that aren't part of the boxes collapse. Each box takes up six columns, except that there's no need for buffering at the beginning and the end of the map. So K boxes need 6K-2 columns. With 256 columns available, that allows up to 258/6 = 43 boxes. Their vertexes in 3D space can be anywhere you like, subject to the available resolution of 255 possible values for each coordinate.
Sculpt maps can be any size, provided the total number of pixels is exactly 1024: 32x32, 16x64, 8x128, or 4x256. (2x512 does not work very well and may even crash things.) In the early days, they could only be 32x32, and the largest number of separated boxes you could make in a single sculpt was 12. I forget who it was who first did that, but here's how it can be done. The general technique is still useful for making multi-object sculpts. First make a single box in the middle of a sculpt map (where you can't depend on the stitching for any of the sides):
All of the vertexes on the border are the same 3D point, which can be placed anywhere inside the cube. This occupies 6 by 7 pixels of the sculpt map, but you can't just fill it with 5 by 4 of these, making 30 by 28, because you'll end up with visible polygons connecting the centres of some of the boxes. You have to add some extra layers of wrapping. Here's how to lay out four boxes in the sculpt map, two by two, so that all unwanted quads collapse. Except for the outline of the cube template, the lines in this diagram join vertexes with the same 3D position.
To lay out two rows of four boxes, you need a second layer of wrapping:
Adding a third row and trimming off the unneeded buffering at the edges of the map will fit 12 boxes into a 32 by 32 sculpt map.
If you just want boxes, the need for that much wrapping is history. Choosing the dimensions of the sculpt map to fit the build saves a lot of pixels, leaving more for the build itself. But the wrapping technique is still useful at times. It's how tools like Prim Generator manage to put multiple prims into a sculpt map.
For all of the snowglobe scenes except the castle and the single Christmas tree, I used 4*256 maps. The toy trees come in three levels of complexity, using 5, 7, or 9 columns each.
The first and last columns are already single-point quadrilaterals, so there's no need for extra buffering, and you can fill the whole sculpt map with these, one after another, with no unused pixels.
The village church and the houses are a little more complex, but are still built from quadrilaterals.
The castle was a lot more complex. This is not built from quads, but from a 16 by 64 map. The 16-pixel axis runs up the wall. The 64-pixel axis runs around the outside, then back around the inside, using all of those 64 pixels. Here's a schematic layout from overhead.
More than half of all those pixels are in the middle of the sides of the castle. This is to allow making a doorway in each side, by pulling the middle pixels outwards and upwards. A similar technique pulls the top section of the wall down from the top of the turrets. After getting that to work, I had just enough pixels left in the vertical axis to hollow out the turrets.
Texturing the castle was easy: a free seamless snow-and-grass ground texture was suitably wintery. For the trees and the village, it was a matter of deciding the appropriate colour for each pixel of the sculpt map, and generating a texture image accordingly, upsampled to a suitable size and applied to the sculpt at 1 repetition each way. The automatic interpolation that the viewer does when stretching a texture map over a surface gave quite a pleasing interpolation between green and snow-covered branches even though the texture itself consists entirely of sharp bands of colour.
Texturing the 42 gift-wrapped boxes was conceptually straightforward. Lay out a suitable giftwrap texture for a single box and apply at approximately 1 by 42 repetitions. In practice, I'm a little hazy on the exact correspondence between a texture map and a sculpt map that it's applied to, and it took a lot of trial and error to get the texture properly sized, oriented, and lined up with the individual boxes. Once I'd hit on the right settings, I decided to make the boxes have two different colours. So stitch two differently coloured copies of the giftwrap texture together, halve the number of repetitions, and tweak the offsets.
A downside of packing so much detail into a single sculpt is that is doesn't LOD well. You need to either cam right in or turn RenderVolumeLODFactor up to 4.
I'm not doing any of this by hand, of course. I'm writing software to generate the sculpts and the textures, but showing the code wouldn't help. I'm using Matlab, because it's convenient and I have access to it through my work, but it's commercial software costing something like a thousand pounds a year, so there probably aren't many Matlab users in SL.
No comments:
Post a Comment