Thursday 27 December 2012

Getting Physical - Revamping a staircase

One common feature of late 19th Century middle class urban houses in Europe was the entrance staircase. In the usual manner of design, a kitchen and scullery occupied the streetside of the ground floor, the main reception rooms were therefore on the floor above the street level, the Bel √Čtage. Not one to conform, Horta took this "standard" and reinvented various aspects. Reorganising the groundfloor to give more space but also making the entry staircase a real feature piece. As one entered the building the double doors were swept open and the visitor was met with a stunning marble staircase lit from above by an ingenious light well, making it both light and welcoming, very different to the darkness often encountered inside the deep set terraced town houses.

It was always important to me to create that sense of welcome, the idea that you were entering something different. Though as in all my earlier attempts skills and tools both left me to make compromises.
This is a photo of the first version of the stairwell. This predates sculpts and is fully prim built. The brass coloured column in the middle is my low prim attempt at recreating the lovely column radiator that Horta installed to take the chill off of the stone stairwell.
The photo above shows the real life Maison Horta and gives an idea of what I am trying to achieve.

This is how it has looked for the past 3 or 4 years, the only significant change since the 2007 version was to replace the prim built stairs with sculpted ones (a real saving back then!). There are some significant missing details not least of which is the curved marble  detailing that forms the side of the staircase for the first few steps.

Today I rebuilt the stairwell using a combination of Mesh Studio and Blender. Blender was required for the curved marble that could not be produced from prims.
Here we have the 2012 version of the same stairwell. much closer in form to the original now with a proper mesh rendition of the radiator too and crucially, even with the separate meshes for the radiator and the curved marble, it still only incurs a land impact of 5 compared to around 15 for the previous version and closer to 25 for the original.

However the purpose of this blog was not simply to track progress but also talk about physics. There is a lot of confusion over physics in mesh and how to define it, but simply defining it isnot the end of the story either. By default once you import the physics is not actually enabled properly.

The default mesh physics is something akin to taking your object and stretching cling film over it. it will tend to stretch from one extremity to another and not follow the shape you have lovingly crafted. This is what is know as a convex hull. Any mesh when first imported whether you have defined a custom physics model or not appears to have its physics type set to convex hull.
Here we have the finished stair well ready to be deployed. We can use the viewer to help us see what the physics looks like for any given object. Make sure you have the debug/develop menu enabled and then select "render metadata" and tick the "Physics Shapes" option.
In the image above I have told the object to use the convex hull physics. This is selectable from within the features tab of the build menu and is labelled "Physics Shape Type". By default you may see only two options, "convex hull" and "none". As you can see the convex hull drapes itself over the mesh and is far from useful. If you select none then the object effectively becomes phantom and you can use the old fahsioned trick of invisible prims. However, there is a better way.

The better way, is to build your own physics model. Don't worry it is not scary and all you do in fact is exactly what you might have down with a sculpted prim and invisible prims. Create a model that matches the physics you wish to define. the simpler the better as each face will add to the physics cost of the mesh upload and therefore influence your overall LI.
In the photo above I am working on such a model. Note that I am only defining the surface that I want to be "physical", so ramps for the stairs are that bare minimum. I have also chosen to go crazy and define some physical presence for the columns and other decorations. Everything that would never be reasonably expected to be touched by an avatar can be made invisible. Once you have made this model drop the Mesh Studio script into it, set the settings to the lowest level and make your mesh.

The physics mesh is applied at upload time and cannot be tweaked later, it is important (and I discovered this the hard way) to ensure that the bounding box of the physics matches the bounding box of the model. If there is any disparity when the model are overlaid they will no marry up properly.

Now let's look at the results of applying a custom physics mesh using the viewer tools again.
In order to see a custom physics mesh we have to tweak the physics type setting again as before. If your mesh has a custom physics mesh included then you should now have a third option available "prim". This may seem rather obscure and I would agree, however selecting "prim" as the physics type, enables the physics map defined in the mesh model. As you can see the physics mesh perfectly matches the model I made and has been overlayed on top of the visual mesh. The result is nice sloping stair ramps and a few extra details.


I hope this helps a little, to explain the peculiarities of mesh physics.
Be careful mesh can be slippery at times.

Revisiting an earlier project - Chimney stack 2012 and some history

Those who know me inworld will know that my home "Maison Horta" has been around for over 5 years now in some form or other. Over on my flickr account you can find various images from the original construction phase. It was a tough project, I'd never used Photoshop and barely had I joined more than a handful of prims together.

One of the external features that vexed me at the start was the chimney stack. Through limited photographic evidence and drawings I had a good idea what was needed but on a tight prim budget (I had only about 400 prims for the entire build back then) with no sculpties it was going to be ugly. A complex arrangement of varying heights made it costly to reproduce and so I compromised with a two prim construct each textured, and it *was* ugly.

2 years later I gave in to my general concerns about LOD in exteriors. Babbage is often shot as a series of long sweeping rooftop views, I did not wnt to be the one with the large egg on the side of her house but when the use of RenderVolumeLOD debug setting became more common knowledge and practice amongst photographers and visitors this was less of a concern. I built the basic stack from prims using SculptCrafter, the result was a definite improvement but far from ideal, as it always looked a little awkward, catching the light in peculiar ways...

And so it was that the chimney was one of my first ever Mesh projects using the wonderful Mesh Studio. Even before I had a play with the Roycroft lamp featured in earlier blogs I took the SculptCrafter prim buil;t model, ripped the SC scripts out and dropped in the Mesh Studio one. The result was much better, a far neater looking object, with better LOD behaviour and lighting. Being the first project I had undertaken I knew little to nothing about levels of detail, about hidden geometry and about a number of the Mesh specific nuances that I take for granted now. The result was a very acceptable but overly costly (2 LI) and somewhat plain.

Not feeling much like undertaking a large task I decided to re-examine the chimney and see if I could reduce the LI, improve the LOD and add some depth by using fake shadow prims inside the openings.

The first task was to dig out the old model and update it. The purple material here will represent the sootier inside faces of the chimneys. You can also see a hint of a black material too. This is a the material that will form the shadow layers.
Shadow layering is an effect I sused in the 2011 RFLSL New Babbage winter city build to add the perception of depth and shadows to the viaduct and other tunnels. The effect is simple to achieve and remarkably effective.
The image above shows the effect a little more. I am experimenting a little here with an angled shadow.
The shadow prim is a stack of semi transparent (I typically use a dark smokey texture) texture faces. In the past I used planar sculpts with each set of four vertices forming one layer of shadow, if each layer is 4% opaque then by the time you stack 10 layers you have a fairly dark (~40%) shadow. In a tunnel, having these layers through the entire length allows you to control how far ahead the user can perceive things making the darkness seem all the more real.

In mesh the same can be achieved in much the same manner. For the sake of experimentation I decided to make it possible to cam down the dark chimney, without the shadows, SL would simply display large empty holes.

Back to the chimney...

One of the issues before was that I had left a lot of hidden geometry in the mesh. Hidden geometry is mesh vertices and surfaces that do not really exist but are a by product of using Mesh Studio and building form prims. Mesh Studio will not create Mesh for points that the fully transparent. therefore, it is a good habit to remove all the hidden mesh faces by making them transparent.

By far the easiest way to do this is to highlight the entire object and make it completely invisible.
The image above demonstrates this. If you look closely (or check the full size image on my flickr) you can see that the Mesh Studio script is tracking my progress and tells me that there are 310 prim faces of which 310 are hidden.
Now, using whatever method you prefer, select visible faces and set their opacity back to normal.
As you can see, just because I am building it does not stop me from dressing festively. I just take extra care not to catch my dress on sharp edges, or spill texture paint on me.

The process can take a while, especially on a complex object. I use ctrl-alt-t to reveal hidden, and then using select face slect a bunch, set them to visible and repeat until I can see no unwanted red.
Here I am part way through the process and the Mesh Studio script is telling us that we still have 248 faces hidden. The more the better, the idea is to only reveal those that absolutely need to be seen.
Once we are finished we can create our mesh and install it.
And here we have the Maison Horta chimney stack 2012. It is now reduced to 1 LI and has the improved texturing to the inner surfaces and proper holes you can cam down. Beware of urchins.
There is a 2013 project evident though. the external texture is rather lacklustre, either some more materials to add some variation to the texturing or a fully baked texture are in order...

Have a good New Year everyone.