Friday 22 June 2012

Less is more, more or less

In the previous post we uploaded our first mesh lamp. Up close it looks just as we wanted but stepping away even a little the lamp melts into an indeterminate jumble of mangled mesh.

This is the same issue as we had with sculpts. The randomly generated lower LOD meshes are little better than the arbitrary chops applied to the sculpt maps. But we have more power now, with mesh we do not have to accept the manufactured mesh we can submit our own objects.

The LOD generation tool has some strengths here. By manually tweeking the settings we can influence the number of triangles at each level. in the preview window and work out more or less what our target should be for each model and thus set our expectations.
Here we have the mesh upload dialogue in Firestorm. We have loaded the Collada file of our lamp, and are generating all other LODs. In the preview window I am displaying the medium level of LOD. This is the level that most people will see if standing on the other side of the room, so it is important enough to focus on. This generated LOD is not ideal but its not awful, the form is more or less intact.
But wait a minute! Look at the Land Impact noted on the left hand side at the bottom.

This object would have a land impact of 9.323 prims, this would be rounded up to 10 prims.  The download impact is the highest of the three factors, Download, Physics and Server. Download represents the streaming impact and is for the most part defined by the number of triangles in the object. As mentioned in previous blog entries, triangles in the lower LOD models have a higher cost so by tweaking those settings we can drastically alter the streaming impact and drive down the Land Impact of the model.

In the image above we have altered the Triangle limit parameters for the generator to work with when constructing the lower LODs. By reducing the limits at each level we have managed to bring down the cost to 1.704 (2) prims.

That is much more like it! But look at the quality, the generated medium LOD is OK but its really starting to look a bit shabby. Its at this point where we can take advantage of  another one of the benefits that mesh has over sculpts; the ability to define explicit models for each of the LOD levels.

So let's look at our model and start to simplify it. We should keep in mind that the Medium level of detail can be seen from relatively close (the mathematics behind the distances for each LOD level is something I can cover in another blog, but for another explanation, in nice clear terms with no maths in sight, I highly recommend Loki's excellent blog).

On the left is the high LOD model on the right is the reduced detail medium LOD model. The simplifications are quite straight forward. All of the surface details have been removed to give a plain rectangular column, I enlarged it slightly to the same volume as the external dimensions of the ribbing. The cross struts in the shade were simplified to square profiles not circular (Squares are much lower cost than circles) and that was about all. This does not seem like much of a simplification but we will also use the Mesh Studio tool to help us reduce the detail further.

When we generated the high LOD model we simply took the Mesh Studio defaults. Mesh Studio however has options to tune the way in which the prims are translated to mesh along with a number of useful presets. With the script installed in our medium model we can touch it to obtain a menu like the following

The default resolution shown above is 4/24. This tells us that straight paths (edges) will be rendered with 4 vertices whilst curves will have 24 sides. Clicking on the "Resolution" button takes us to a different dialogue where we can tune the resolution. For the medium resolution we will select the Low Poly option. This uses just two points per side to define a straight edge and 16 for a curve. The result for us will be a blockier curve to the lamp shade whilst saving over 1/3 of the vertices.

Having set the resolution we can return to the main dialogue and press the "Mesh!" button. A few seconds later a URL will be printed in to the local chat channel and opening that URL in your browaser will down load a zip file containing your collada mesh file exactly as we did for the high LOD model.

Before we upload anything we will continue to optimise.
First we will create a low LOD model. At this stage we can expect the model to be being viewed from quite a distance and as such we can take some liberties with the model.

 The bulb inside the shade has been removed completely, there is a subtle issue here, that relates to the texturing (or materials in Mesh speak), we won't examine this in detail but take care to ensure that your models always show the same number of texture faces in the hover text before you generate the mesh. SL will not allow you to combine objects that do not have the same material structure.

Apart from the bulb, we have removed the cross members on the shade and made the bulb holder itself square. The apertures in the shade itself have been closed in.

In the illustration above you will notice that the inside of the shade is transparent. This is a nother feature of Mesh Studio. All faces that are 100% transparent are assumed to be hidden and will not have mesh generated for them. I have made the assumption that our lamp, when viewed from afar is likely tobe viewed from above and so the inside of the shade will be invisible.

For the final cost savings, we go back to the resolution settings dialogue in Mesh Studio.
We could have used the low LOD preset of 2/8 which would have rendered our lamp shade as an octagon, but because of its shape we can be pretty comfortable taking this down to 6 sides (a hexagon).

This leaves just one final LOD to define. Lowest.
The Lowest LOD pays the highest price for each vertex so we need to keep this  as low as possible whilst still serving its purpose. In the case of our lamp I have arbitrarily decided that it will render as noth but a flat plane. As mentioned above I do need to have two texturable surfaces in order for Second Life to accept this model as part of the same mesh as the others.

 The image shows that I have reduce the model to a simple cube and set the four vertical faces to be transparent. the top and bottom faces (not seen here) are textured (one in brass and one in lightbulb) to represent our two materials.

We are no ready to upload.
 First step is as before, in our viewer we go to the mesh upload dialogue. For each of the four LODs we select "Load from File" and specify the appropriate model.
You may be surprised to note how many vertices we saved with the simplifications between the High and Medium levels alone. The Land Impact of our model is now down to 1.460, 2 prims still ,but we have defined an elegant set of models for each LOD now, and so we can look at the rest of the upload options.

Next we move on to the physics tab.
Another difference between mesh and sculpts is that you can specify a special physics shape, this is in the form of a mesh and adds to the overall cost of the model by affecting the "physics" weigfht shown in the dialogue above. The physics of the lamp is not very important and so I have specified the lowest LOD model as the physics. In this case it has not affected the overall cost of the object.
 Finally the "upload options" tab. This is where sundry options exist. To be honest I have played only a little with this, the key parameter here is scale. For ease of construction I was working on a large scale model. 3m high, a little on the large side for a table lamp.
Scaling is optional. Once uploaded you can scale the model inworld. The same Land Impact will be gained but by tweaking things in the dialogue we can see how the scale will affect our Land Impact before we upload and in some cases that might send us back to the modelling stage to make some additional tweaks, thus saving an upload fee.

By scaling this down by a factor of 0.5 we have a still oversized lamp but have already gained the lowest Land Impact (0.5). This means that a single lamp willcost us 1 prim, moreover two of them linked together would cost us 1 prim too!

Finally we hit the upload button and our mesh will be transferred to our inworld inventory.

In the next blog, we will look at LOD and compare our new mesh with the old sculpted lamp.

No comments:

Post a Comment