Sunday, 28 May 2023

Moving!

 Good news: this blog is closing (sort'a)

What's so good about that???

I've found a better place to post my tips to content creators, the Open Metaverse Research Group (OMRG) wiki. This means my guides and tutorials can be coordinated with contributions from others and the wiki format is also better suited for this kind of content than a blog is.

It also means my focus will shift more towards opensim/the hypergrid and less towards Second Life but for us content creators there's actually very little difference so that shouldn't matter much.

All the content I've already posted here will stay here, at least for now. I'm not going to waste time reformatting it to the wikis when I can simply link to the blog instead but all new content will be posted at one of the wikis or both.

Thursday, 14 January 2021

Creating LoD models, case study 2, Lesson 7

 

 Tutorials: Creating LoD models, case study 2, Lesson 7

Creating LoD models

Case study 2: Lesson 7 - Getting physical

Finally time to upload:




We got the download weight down to 1.389, that's low enough to be rounded down to 1. Yay! :D

The physics weight is 1.4 though, not high enough to make a difference to the LI but even so, is that really necessary? People may bump into the sign every now and then but they're not likely to ever try to walk all over it. A cube would make a much better physics model than whatever the uploader generates (and if you thought GLOD was horribly bad at his job, just look at what lunacies his physics generating brother can dream up!)




0.36 physics weight, that's more like it.

I think most mesh makers know this but just in case:

Make two dae files, one with a single triangle and one with a simple cube, and save them in an easy to find spot on your harddisk. Use the triangle (0.200 physics weight) as physics model for items that don't really need physics at all and the cube (0.360 physics weight) for anything avatars and/or moving physical objects are going to bump into. No need to worry about the size of these two meshes, the uploader will automatically scale them to the same size as the main model.

 

But the proof is in the pudding...

And here it is. High LoD:




Mid:




Low:




Lowest:




And a few details:



 

Finally time to upload:



We got the download weight down to 1.389, that's low enough to be rounded down to 1. Yay! :D

The physics weight is 1.4 though, not high enough to make a difference to the LI but even so, is that really necessary? People may bump into the sign every now and then but they're not likely to ever try to walk all over it. A cube would make a much better physics model than whatever the uploader generates (and if you thought GLOD was horribly bad at his job, just look at what lunacies his physics generating brother can dream up!)



0.36 physics weight, that's more like it.

I think most mesh makers know this but just in case:

Make two dae files, one with a single triangle and one with a simple cube, and save them in an easy to find spot on your harddisk. Use the triangle (0.200 physics weight) as physics model for items that don't really need physics at all and the cube (0.360 physics weight) for anything avatars and/or moving physical objects are going to bump into. No need to worry about the size of these two meshes, the uploader will automatically scale them to the same size as the main model.

 

But the proof is in the pudding...

And here it is. High LoD:




Mid:




Low:




Lowest:




And a few details:





A final word

We keep talking about keeping the LI down but this is also a way to increase the amount of fine details in the full high resolution model.

The challenge with this sign was of course the chain, the other parts are very simple. The common solution would be to reduce the curve resolution for the chain links but I really wanted to avoid that. Don't get me wrong, I have nothing against octagons and hexagons, some of my best friends are...

No, they aren't really. Anyway: there is a time and a place for everything but a rugged chain is not the place for any kind of polygons.

These efficient modelling techniques meant that I could afford properly rounded chain links. They may actually be a bit too round, perhaps I should remove a few vertices from them just to make them look more natural before I upload to the main grid.

Resource efficient modelling is not about saving for the sake of saving, it's all about getting more for less.


A final final word

After I wrote this tutorial and took all the pictures, I made a few more tweaks and got the download weight down to 0.732:


This didn't affect the land impact of course since it already was as low as it can be but every tri and vertice we can eliminate is a tri or vertice our GPUs don't have to worry about. How I did it? I can't remember but it must have been some tris in the lowest LoD model that turned out not to be neccessary. There's always room for improvement and there's always new tricks to discover. I've been making mesh for Second Life and opensim for more than seven years now and I'm still learning.


A final final final word (to keep people from suing me)

A sign like this is for virtual worlds only. In the Real World they have something called wind so heavy signs need rigid mounting, not chainlinks - at least if they are outdoors.

Creating LoD models, case study 2, Lesson 6

 

Tutorials: Creating LoD models, case study 2, Lesson 6

Creating LoD models

Case study 2: Lesson 6 - The faraway

Here's the lowest LoD model:




and yes, I could have done a little bit better...

I don't know if anybody remembers an old C&W song called "The Builder":

  Ev'ry builder knows that the secret to survival
  Is knowing what to throw away and knowing what to keep

(Kenny Rodgers rewrote the lyrics and called it "The Gambler" but that advice doesn't make any sense at all to gamblers of course.)

A common problem with the lowest LoD model - and sometimes with other LoD models too - is what we need to keep. We need to keep triangles outlining the main elements. We also need to keep at least one triangle for each face and those are not necessarily the same ones.

In this LoD model the horizontal beam at the top is very prominent and needs four triangles, two facing each direction. Texturing isn't very important there though, we just need the shape. So, assign those four triangles to four different faces and we save three tris elsewhere in the model. There isn't much more to say about this model, really. I obviously kept four triangles for the actual sign - that part is important at any distance - and then cut down as much as possible everywhere else.

Lesson 7 - Getting physical

Creating LoD models, case study 2, Lesson 5

 

Tutorials: Creating LoD models, case study 2, Lesson 5

Creating LoD models

Case study 2: Lesson 5 - Going low

I hate to make compromices but sometimes they can't be avoided. The chain of my sign isn't really noticeable at low LoD so I didn't really need it at all there. It is noticeable at the switch between low and lowest, when it suddenly pops up or vanishes, though, and because of that, I really wanted to keep it. However, simplified chain links wouldn't work since sudden shape changes between LoD models would be just as noticeable and since the low LoD model was so significant to the LI, a working chain representation would require far too many triangles. In the end I removed the whole thing and here's how the low LoD model turned out:




I couldn't remove the chain link face though and a single triangle there did more harm than good to the appearance so I hid it. Here's the bracket reduced to a single triangle:




What you don't see in this picture is that i's actually two triangles, facing in opposite directions, one assigned to the chain bracket face, the other to the chain face. Here I've moved one of them slightly upwards:





This trick has two functions, first, unlike what GLOD believes, it's usually better with no triangle at all than a single "eyesore triangle". The other function is to reduce the LI a little bit. With the vertices for the two triangles aligned perfectly with each other, the file becomes a little bit more compressable, reducing the download weight a little bit. Align your vertices consistently whenever possible and you can easily save 20-30% LI with no visible effect at all.

Here's a top view of the low LoD model:



Yes, it's hard to see what this picture illustrates but nearly all the triangles and vertices of the model are aligned with each other along the y axis. The only exceptions are the signboard face which has to be a bit away from the base plate to avoid texture flickering and the wall mount which may occasionally be seen from the edge even at low LoD. (Looking at that picture, I see where I could have done better but oh well, it's good enough to keep.)

Lesson 6 - The faraway

Creating LoD models, case study 2, Lesson 4

 

Tutorials: Creating LoD models, case study 2, Lesson 4

Creating LoD models

Case study 2: Lesson 4 - The middle ground

This is a very important lesson:

People in Second Life do not see your carefully created mesh!

They may study it every now and then and marvel at all those lovely details but what they actually see as they go about their Second Lives, is mid and low res LoD models. That is how it should be. All those details are not necessary for a scene and there is no computer in the world powerful enough to render everything in an SL scene at speed.

People do notice distortions like the ones in all the GLOD created models though. They drop you straight into the eerie Uncanny Valley where things look almost but not quite right.

For this sign I really needed the chain to look spot on even in the mid level LoD model yet I needed to get the poly count way down since it accounted for almost 7000 of the 7358 triangles in the original. Here's the solution I came up with:




Took a bit of creativity and I could probably have reduced them down even more with no visible effect but with a little bit of reduction to the chain's fastening brackets too, I got the triangle count down to 602 and the land impact down from 13.803 to:




12.859. That doesn't sound like much, does it?

Still better than what GLOD could manage though and unlike GLOD I did it with no noticeable changes at all.

There's an important lesson there: Download weight is calculated separately for each model and then the four numbers are added together. If you really want to reduce the weight, you need to know which model is the heaviest one. In this case it's very clear to see but when I'm in doubt, I do a mock upload, zeroing out the models one by one to see how much each affects the LI.

Lesson 5 - Going low

Creating LoD models, case study 2, Lesson 3

Tutorials: Creating LoD models, case study 2, Lesson 3

Creating LoD models

Case study 2: Lesson 3 - With friends like this...

Say hello to Glod. GLOD (Geometric Level Of Detail) is the little part of the uploader that generates LoD models and he's always so eager to help. And he loved my sign so much he thought it was well worth 14 LI, that's sweet of him, isn't it? ^_^

Let's see what he can produce for that.

Here's LoD level 0, the high LoD model:




LoD level 1, Mid model:




Not bad but not good either. There are some very noticeable distortions of the chain links.

Lod level 2 - low model:




and level 3, lowest:




Overall, not ideal but I could live with this. 14 LI is not acceptable though, we have to tell Glod to be a bit more economic with the tris:




1.4 LI? Yes, that's more like it. Actually it's 2 LI but that's because of the physics - we'll deal with that later.

Here's LoD 1:




LoD 2:




LoD 3:




LoD 2 is still acceptable but 1 and 3 are disastrous. I want this sign to be seen!

(ChinRey sighs)

Oh well, Glod is really trying his best to help but in the end: with friends like this, who needs enemies?

Lesson 4 - The middle ground

Creating LoD models, case study 2, Lesson 2

 Tutorials: Creating LoD models, case study 2, Lesson 2

Creating LoD models

Case study 2: Lesson 2 - Hidden faces

This is a short lesson.

Even in the simplest mesh model you often have superfluous vertices and polys, details that add to the complexity but not to the looks at all. In this case there are several polys hidden inside other elements, like these:




and these:




Get rid of them and the triangle count drops from 7358 to:




The LI - still with default automatic LoD, drops from 14.644 to 13.803:




Not bad for a few minutes of work.

Lesson 3 - With friends like this...

Creating LoD models, case study 2, Lesson 1

Tutorials: Creating LoD models, case study 2, part 1

Creating LoD models

Case study 2: Wall sign, Introduction and Lesson 1

Originally posted at the official Second Life Forum. Unfortunately the pictures got lost when Linden Labmoved the forum to another host and without them, the tutorial is rather useless. So I'm reposting it here with a few minor updates.

Introduction

This is the sign outside my Queen of Spades pub in Keswick:




It seems quite simple at first glance but it has details like miter joints for the base plate:




and most significantly a rather elaborate attachment using six toruses and six twisted tubes:




The Queen of Spades is currently used as part of the Silent Slasher game but mostly it's just a decoration in the landscape and I never bothered to do much about it. Especially not the sign because I'm really happy with how it looks and don't see any need to change it. But it was all prims and that meant 10 LI, a bit too much for a simple sign really. Eventually I decided to do some serious work on a mesh version.

Almost straight out of Mesh Studio with just a little bit of cleaning in a Blender, it's 3694 vertices and 7358 triangles. Sounds a little bit heavy to me:


Lesson 1: UV mapping

I may be wrong but I understand that the common way to UV map an SL mesh today is to use few faces and "islands" for each part on the UV map. In this case you'd probably use three faces, one for the signboard itself, one for the wooden base plate and one for all the metal parts.

If you're lazy, you'd just use the basic automatic UV mapper in Blender and end up with this:


Now, this is of course a very poor UV map, you waste more than half the pixels in the texture, the toruses are visibly distorted and so on. Contrary to what many builders seem to believe, Blender does a very poor UV mapping job so be prepared to spend a lot of time cleaning this up before you get any kind of decent result. But how many people realize that a UV map like this also affects the land impact?

If I try to upload this, using the default automatic LoD settings I get:




16.409 LI.

Here's a different way. If I split the metal parts into five separate faces:




I can get a much cleaner UV mapping:




Much cleaner and much less work, most of the parts I didn't UV map at all, I just scaled the mapping from the prim original. The map still looks a bit wasteful of texture pixels but it isn't. The vertical and the different horizontal segments are different faces and will end up using all the pixels of the texture.

The LI?


14.644. Still too high but 10 percent reduction by saving a lot of time and effort on the UV map? Yes, please!

I've heard so many times that simple texture maps and repeating textures are outdated and the only right thing to do is to use "proper" UV maps and baked textures. It's the Emperor's new Texturing. I don't know of any skilled mesh maker in SL or anywhere else who thinks that way. Quite the contrary: use simple UV maps and repeating textures wherever possible, complex UV maps and baked textures only where they really make a difference.

Lesson 2 - Hidden faces

Thursday, 3 September 2020

Second Life Mesh Physics 101

 

(Originally posted on the official Second Life forum)

Physics in a virtual world has two purposes, it defines where avatars (and objects set to be physical) can and can't move and it provides surfaces for "ray tracing" (a feature that defines which spots you can rez on and is also used for pathfinding and a few other things).

Physics engines work with two very different kinds of physical objects, surfaces and hulls. (There's a third one too, height fields but it's only used for the system ground so it isn't relevant here). HAVOK, the physics engine used by Second Life, operates with five different hulls and two different surfaces but only the two surfaces and one of the hulls are available for meshes.

When we analyze the physics, the uploader will try to convert the physics mesh we feed it into one or more hulls, if we don't analyze, it will use the input as it is and treat it as a surface. The physics engine, including the uploader's analyze function, is not LL's own, HAVOK is an Irish software copmany currently owned by Microsoft. This means there's not much LL can do about it, they have to use it as it is.

Both surface and hull physics have their pros and cons:


Hulls

A hull can be compared to ban lines in that they defines an "exclusion zone" you are not allowed to be inside.

The pros are:

  • They are always totally solid, if you are inside it, you will always be pushed out.
  • The physics weight is constant. If the hulls are all simple cubes, each of them will always add 0.360 to the physics weight. More complex hull shapes may add a bit more but it's still constant.

The cons:

  • The physics engine won't allow two hulls to touch each other, it will always leave a little bit of space between them. The uploader tries to compensate for this by shrinking the physics shape slightly but this is not a precise science so you will always hover a little bit above a mesh surface made with hulls.
  • There is no way to reduce the physics weight below the 0.360 per hull limit and the hull shapes are always farly simple. If an objects needs a complex physics shape, it'll have to be made from a lot of hulls.
  • Since a hull isn't defined by its surface and ray tracing is all based on surfaces, it can sometimes cause problems with rezzing and for pathfinding characters.

Surfaces

As I said, we have two different kinds of them:

Triangle

A single triangle has a constant physics weight of 0.200, making it the lightest of the shapes available for mesh (three of the special hulls we can't use are even lighter). It doesn't give us any useable physics of course but can still be handy for objects that can be phantom anyway.

Triangle list

Triangle list is just another name for a mesh, a surface made from several triangles streched between vertices. It is said to be heavier on the server than hull physics but that is a truth with modifcations. We often need multiple hulls or a very complex single hull to get a good physics model and in those cases triangle lists are usually considerably lighter.

One peculiar quirk HAVOK has, is that it doesn't handle triangle lists with small or very long and narrow triangles very well, the bigger the triangles are, the better. If the object size is smaller than 0.5 m on any axis, HAVOK simply gives up and handles it as a single convex hull and depending on other factros, you can get very high physics weight long before you reach that limit.

Pros:

  • Allows for very precise physics shapes
  • No ray tracing issues

Cons:

  • May cause inflated physics weight for very thin objects
  • Does not work at all with objects smaller than the 0.5 m limit
  • Is single sided so you may be able to penetrate it (with a little bit of difficulty) if you walk into it from the back side
  • If you move very fast, you may end up penetrating the surface before the physics engine has time to react. This is not a problem with normal avatar walking/running/flying speeds (unless there is a server glitch) but if you drop onto the surface from a high altitude or crash into it in a fast moving vehicle you can sometimes go right through it.

Four special points worth mentioning

For a physics model is made from a single 12 tri cube it doesn't seem to matter whether it's analyzed or not. The physics weight is always 0.360 and it doesn't seem to suffer from any of the quirks neither of the hull or surface physics. This may be because it corresponds exactly with the object's bounding box.

The bounding box is a cube surrounding the entire object. The physics engine can't keep track of the relations between every single object and avatar in a region of course so it uses the bounding boxes as a preliminary check to see if two objects are so enough to each other it'll have to do a more precise calculation.

For those who wonder, the "convex hull" option in the edit window uses HAVOK's analyzer to generate a single hull for the entire object. The physics weight depends on how complex that hull is but usually it's lower than the more detailed "prim physics".

Practically all parcels in Second Life are configured with no pushing. This means worn items are always phantom so there is no point in using elaborate physics models for clothes, hair, jewelry etc. Just upload with a single triangle as physics.

Monday, 30 March 2020

Brick walls


Brick walls

Brick sizes

Brick sizes vary depending on location and age of course but not nearly as much as we may think. The measurements here are for modern standard Norwegian bricks but they're not far off for other styles and nations:

RL 133% 150% 200%
Whole bricks per meter horizontally 5 3.75 3.33 2.5
Layers per meter vertically 14-15 10-11 9-10 7-7.5

Cement bricks

Cement bricks are generally about twice the size of redbricks:

RL 133% 150% 200%
Whole bricks per meter horizontally 2.5 1.9 1.6 1.25
Layers per meter vertically 5 3.75 3.3 2.5


Bonds

The bond is the pattern of the bricks in a wall. Let's establish some terminology first:
  • Stretcher: The regular brick with its long side facing outwards
  • Header: A brick with its short side facing outwards
  • Soldier: A brick standing vertically
  • Joint: Well, obviously - the horizontal or vertical mortar filled space between the bricks
  • Single thickness wall: A wall as thick as the header side of a brick
  • Double thickness wall: A wall as thick as the stretcher side of a brick
If we want a solid brick wall, we want it double thickness and without consecutive aligned vertical joints (don't worry, it'll all come clear when you look at the pictures). For simpler walls that don't have to carry much load, there are other options too.

Solid brick wall patterns

There are lots of different bonds used for solid, double thickness walls. Here are the most common - and two slightly unusual - ones:

 Common bond


Every sixth layer is made from headers, the rest from staggered stretchers.

English bond


Alternating stretcher and header layers. This is regarded as the strongest of the regular bonds.

Flemish bond


Each layer made from alternating stretchers and headers.

Garden bond


A pattern of two stretchers and one header in each layer.

Flemish/Common mix


I'm not sure if this has a special name, usually I've seen it referred to as "common bond". It's similar to the regualr common bond but with every sixth layer made in the Flemish alternating stretcher and header style rather than from ehaders only.

"Scandinavian garden bond"


Another bond I don't know a name for. I've only seen it twice, once in Norway and once in Denmark, so I decided to call it "Scandinavian garden". It's the same as the regular garden bond with two stretchers and one header in each layer but the layers are shifted relatively to each other (seemingly at random) so the headers aren't aligned vertially with each other.

Not so solid bonds

Stretcher bond (aka Running bond)


Stretchers only, each layer shifted a quarter, third or (usually) half brick width to avoid aligned vertical joints. This is what you'll usually see on a single thickness wall but it's not really recommended for load breaign double thickness ones.

Stack bond


Stretchers stacked nicely on top of each other. Sometimes used as decorative coverage on walls and embankments made from other materials but it is a very weak wall and you don't want to use it on its own.

Soldier crown


A layer of soldiers added to the wall, usually at the very top where it doesn't affect the structural strength very much. The illustration shows it on top of a stretcher bond wall but it can be added to any bond.