Showing posts with label havok. Show all posts
Showing posts with label havok. Show all posts

Sunday, 20 June 2021

Summarising the next improvements to Firestorm Mesh Upload

In my last blog, I covered at length one of the changes I have put into the forthcoming Firestorm release. This post is a shorter summary of those changes and two other updates that I think will appeal to many mesh creators. 


1) Materials subset handling and related errors

For a full, blow by blow account read the previous blog, but in summary, the way that mesh "texture faces" are handled has been rewritten to give you more freedom in how your meshes are organised.

As best I can tell, there has been a bug in the Mesh upload parser (the thing that reads your Collada files and prepares them for upload to SL/OpenSim), so in-grained was this bug that most of us never realised it was a bug. We have all become accustomed to having to place empty triangles in every LOD model to represent the full set of material faces. Given a Mesh "house" whose High LOD model uses 5 materials, "frontwall", "roof", "door", "carpet", wallpaper", we might remove all the geometry from the interior faces for the lower LODs as you would never see those from the outside. However, creating "house_LOD2", as the medium LOD model with only the exterior materials present would result in the error, "Material of Model is not a subset". We would grumble that this was a subset, but with no way around this problem, dutifully return to Blender and add 2 stray triangles and assign one of the "missing" textures to each.  This is painful, time-consuming and frustrating but most importantly it is very confusing for new creators. It also has a further serious side-effect. the LOWEST LOD model is notoriously over-priced in SL, by which I mean that the cost of each triangle in the LOWEST LOD is so high as to make it near impossible and at best time consuming to produce a good LOWEST LOD model. For example, a small hand tool which due to its small size will rapidly be reduced to LOWEST LOD, can typically have no more than around 20 triangles before it starts to seriously drive the Land impact up. If you have to give away a number of these precious triangles just to please the grumpy uploader trolls then you have already lost a large proportion of your allocation. 

Form the next Firestorm release this will no longer be the case. With the exception of the high LOD model all the other LOD models can now have any valid subset of the High LOD materials, they do not even have to be a subset of the immediate parent LOD. 
Thus you can have the following structure
8 faces in the high LOD - A,B,C,D,E,F,G,H
4 faces in the Medium    - B, E, G, H
2 faces in the Low           - A, C
& just 1 in the LOWEST  - F

Or any permutation of these. The only requirement is that the superset of all materials used in all LODs must be present in at least one triangle in the HIGH LOD.

2) Ready-to-use physics presets


The physics shape tab on the mesh uploader is generally not well understood. This is in part because it is a technically complex thing, in part because the viewer has not helped as much as it could. I can't do too much about the former, though I've written a number of blogs that try over the years, the latter part I can do more with.

As of the next Firestorm release, creators will find 3 new options when selecting a physics shape.
1) The cube.
2) The hexagonal cylinder.
3) the user-defined mesh.

There tend to be two sorts of people when it comes to defining physics shapes, those that do and those that don't. For some items it is barely worth worrying about, for others it is essential. However, given that in SL it is often hard to predict how an item might be used once it leaves your protective custody, it does no harm to make sure it has a minimal physics shape that is broadly aligned to the volume of the mesh.

Many people will select the "lowest LOD", often some unrepresentative triangle. This will upload, but it means that once the item is rezzed inworld people cannot interact properly with it. A much better option for many items is a simple cube, and a lot of us keep a simple 8 vertex cube on our drives for just this. You no longer need to do this. The hexagonal cylinder is intended for items that are not quite so "cuboid".

I toyed with providing something vaguely spherical but came to the conclusion that any shape I came up with would fail to meet some need. So instead I added the ability to provide a "user-defined" physics mesh. This is a way to have a shortcut to that "shape you always use". It can be configured in the Settings tab on the upload floater. 




Some items require a custom physics shape, walls with doors and windows that you wish to allow passage through, for example. No defaults are going to help much there, but let me know if there are things that you feel would help. 

3) Ambient lighting in the viewport.

A couple of years ago, I changed the lighting in the preview window to make the three-point lighting work "better" but for some reason, things always remained dull and flat. Recently, it suddenly struck my partner Liz why this is. the ambient lighting is wrong. Upon investigation, it turned out that it was not just wrong it was "black". I have no exposed this setting on the "preview settings" tab so that you can change it, I have found a dark mid-grey about 33% grey works well and makes the lighting "pop" properly. It is especially useful when uploading with textures.

At the time of writing, there are two minor niggles that I may change before release. 
1) It still defaults to black. I considered this as a good plan but given that anyone upset by better lighting can change it to dullness again I think I will change the default to something sensible.
2) When you change the control the preview will not update until you either pan the model or reopen the uploader. I may not be able to fix this immediately.

I hope these three sets of changes improve the quality of the uploading experience for you as much as they have for me.

Take care.

Love Beq
X

Wednesday, 3 October 2018

Shedding light on Mesh uploading - Something I'm playing with...

For some, the entire Mesh upload process is wreathed in fog, a murky, mystery-filled place of confusion. Sometimes this is down to misinformation and poor tutorials out here on the web, but the Mesh uploader does nothing to help its own reputation.

With the above thought in mind, I've started to make a few tweaks to the uploader. Nothing major here but I thought I would share a little of the direction I am going in and see what the feedback is.

While I want to address a number of different problems, from the error reporting to the preview window, I've started with some additional information displays. It has been mentioned many times in the forum that the Mesh uploader is a little "random", and whilst there is a grain of truth to that, it is also in large part due to the opaque nature of the numbers we see. In particular, where is the cost derived from and why does the physics shown on the uploader bear no resemblance to that which we see inworld?



Blogger will downgrade this clip but you can peek at the original here

Very rough and ready but what this shows is some extended information that is returned when you "calculate weights & fee". So what goodies do we have here?

There are 3 sets of information I am showing, we will ignore the middle one for now as it is not useful in its present form, so that leaves...

1) The contribution to the fee

As you can see, your upload fee is derived from a number of components:-

Streaming

Streaming is a charge derived from the streamable size of the object.
Physics
Physics is a fee derived from the physics model, and you can see that it varies with the physics costs that are normally hidden from sight.

Instances

Instances is a little misleading, it is not used in the context of repeats of a mesh, as those familiar with 3D modelling might use the term, it is instead derived from the number of mesh units making up the model. It is effectively the "prim count"

Textures

I don't show this in my quick clip above but it is the 10L charge for any textures uploaded with the mesh. Uploading textures with the mesh has always been an option but to my knowledge is rarely used.

Model

I have never yet seen this as anything other than the 10L value shown in the clip. I suspect in the workflow it is effectively hardcoded.

And so on to the (arguably) more interesting information.

2) The physics costs

Here we find the hidden cost of physics. For years we've moaned about the fact that the Physics cost shown has little relation to that which we get after upload. Most of us will have made the link to the fact that the physics cost shown historically is just the "base hull" cost. That is to say, it is the cost assigned to the shape that is used when "convex hull" is selected. This is the default physics shape post-upload and is a mandatory part of the uploaded asset.

But we can also provide a custom physics model, if we choose to provide it as a mesh then a weight based on the number and area of the triangles that comprise that model is computed. While it has not been visible until now, it does influence the price we pay. For reasons we have discussed in this blog many a time in the past, there are occasions where a Mesh physics model is not suitable; in those cases we use the "analyse" function to convert the triangles into a set of hulls, or a "decomposition" in viewer-speak.

While a base hull is mandatory and always present, the mesh and hull based user supplied physics shapes are mutually exclusive, you may only have one. As such pressing analyze and then calculating weights will blank out the Mesh cost and retrieve an Analysed cost.

Will this help you?

OK, so that's it for now. How this will actually appear in a future Firestorm I'm not yet sure. There is a fine line between providing more information and causing more confusion. so while I think it will appear in some form I'll be hoping to discuss it with users and our support team as well.

Personally, while seeing the composition of the fee is interesting in passing, it is not essential and anyone tailoring their mesh to minimise the upload cost really needs to consider their motivations. However, knowing exactly what the physics cost will be in-world before you upload is a massive time saver and I believe that this will be popular with my builder friends.

I'd love to hear your thoughts on this. Am I completely off-piste here?

Friday, 27 October 2017

Blue sky thinking - Physics view explained

Introduction

I found I could say things with color and shapes that I couldn't say any other way — things I had no words for. - Georgia O'Keefe
In previous blogs and in various group conversations, I've often discussed the physics overlay renderer of the Second Life Viewers, typically found in the Developer menu under the, perhaps confusingly named, "Render Metadata" menu.
Physics view in all its glory
The Render Metadata menu is a wonderful set of tools that help debug various issues. You may recall the "LOD display" which tells you which Level Of Detail is being shown, for example. They are mostly unnecessary to the average SL user but occasionally, as builders, and educators/mentors, we find that a couple of them can help us a lot at certain times; and primary amongst these, to my mind, is the physics view.

The physics view is a great example of "metadata rendering"; the use of a visual overlay (render) to convey additional information (metadata). So what does it do? Well essentially, it overlays new objects into your view to communicate non-visual aspects of the scene. in this case the physics shapes, but..what does it all mean?

Where do we find it?

Before we get too far ahead, let's take a moment to find the menu. I will, of course, use Firestorm but the feature should exist in all graphical viewers that have any relation to the Linden Lab viewer.

You will need to have access to the developer menu
The simplest way to do this is via that excellent preferences search.
Ctrl-p will bring up the preferences dialogue. Then in the search box type "developer".
Tick the highlighted option and hit OK, you should now have the developer menu.

Now, simply click on the "Developer" menu and locate the "Render Metadata" item, and pick "Physics shapes" from the resultant list.


To turn it off again, just reselect the item from the list.

Decoding the view

When you click on the option, you are immediately plunged into a strange parallel dimension; what you see will naturally depend on where you are, and what is around you but it will almost certainly take on a very blue look. It is often worth moving to an area clear of clutter when testing this feature.

New rough approximations of your objects will now have been rendered; your meshes and prims will be blue, or various shades of orange and red, some will have pencil sketched triangles across their surfaces and peculiar coloured boxes will appear. Every part of this is potentially useful information if only you know how to read it. There are two basic representations, the colours and the shapes, we'll look at each in turn.

Colours

First of all, I will correct the received wisdom of forums and blogs. For a long time most people, myself included, had considered that the colourisation represents the physics weight of the object; however, that is not actually the case. In fact, the view displays colour based on the overall object cost, i.e. the inworld LI. The below image demonstrates this clearly, and no this is not new, or a change in behaviour, it was created like this in 2010 and the assumptions have been made ever since.



With a few exceptions then, the hue of the faces shown in physics view represents the object cost of that object as a colour spectrum. Red indicating an excessively heavy load on the viewer/physics engine, through to amber, and blue.


The mechanism by which these are coloured is not entirely straightforward. Firstly the cost is normalised along a logarithmic scale. By default the threshold used is 50, anything over that value is considered high. A plot of this normalisation looks like this.

Anything with a normalised weight of <0,5 (which as we can see from the graph is an actual weight of a little under 35) will be rendered as a mix between the Low colour (blue-green) and the Medium colour (orange). For anything heavier than those the colour is a mix between the Medium and the High (Red) thresholds, giving a range between orange and angry red.

Note: For those interested in the details, the mix is a linear interpolation of the RGBA values of the two thresholds. The colours and thresholds can be changed, and I will briefly cover this at the end of this blog (if I remember), but it should be considered as an advanced use only. So these are really telling us where our heavy physics costs are, especially useful in a multipart build where an unexpected legacy prim has become linked with Mesh and resulted in an unforeseen and undesired spike in the LI.

Shapes

The shapes are where this view excels. When you are trying to understand why your Mentee's mesh wall is not allowing you to pass through the doorway, a quick flick into "Physics view" can often tell you the answer. Even those of us who use them frequently often fail to realise is that there is more information in the display of these than first meets the eye.

The representation is similar for both prim and mesh; similar but not quite the same. Unlike a mesh, a prim has no user-defined physics shape, yet the effective physics shape can be quite complex. Consider a twisted, cut spiral cylinder, used as a staircase. The users expect the physics to work accurately. As a result, there are a couple of optimisations and a default case which can if misused, be a problem.

The way that a shape is shown is linked closely to the type of physics that it represents.

Four prims a cube, sphere, cylinder and torus with various parameters affecting their physics shape


Case #1 The HAVOK Physics shape.

For the general case of a unmodified prim, it will be assigned a highly efficient physics hull that closely matches its shape. There are three possible physics shapes, Box, sphere and cylinder. These shapes are a special case of "hulls" a physics shape used by the Havok engine. These provide for extremely efficient collision detection by simplifying the mathematics required to detect collisions.

An example that seems contrary to many who are used to thinking of mesh shapes, is that the cheapest, most efficient physics shape is a sphere. This is because collision detection of a perfect sphere needs only two values, the centre and the radius, any plane that passes closer than the radius, must be intersecting with the sphere.

Note that complex prims such as the Torus shown top right, do not have an efficient representation and simply fall through to the second category.

For Mesh there is an extension of the simple form, it is known as the base hull and is the shape that you interact with when "convex hull " is enabled. A base convex hull is defined for all meshes and for the most part, appears as if a "cling film" wrapping has been stretched over the object.

These shapes are typically rendered with a semi-transparent tone and no visible edges.

Case #2 almost all of the rest

If a prim cannot be represented by a Havok shape then it will be converted to a "simple" triangular mesh representation. The rules that dictate when a physics primitive is swapped for a mesh are a little too detailed for a blog like this. But with experimentation in Physics view, you can see that typically a cube that is hollowed will "switch" to mesh physics at about 20%. I tend to think about it in terms of "is the hole big enough for something to fall through" (though that is not the real test :-) ).

This is also the typical (not quite a default) case for Mesh physics. A Mesh object must have a physics decomposition provided. There are 3 types, the base hull discussed above which is the actual default. If nothing else is provided then the base convex hull will be used. The second type is a triangular mesh derived from one of the visible mesh models or uploaded as a dedicated mesh (I highly recommend the latter). The third is an analysed mesh, which we will cover later.

A triangular mesh physics shape can be very efficient it allows you to fully represent the shape, with any holes and other shapes. It is important however to be very economical with the mesh used, keep the resolution of the physics as coarse as possible, to improve performance and lower cost.

It is worth bearing in mind that it is a side-effect of the triangular mesh physics and the physics cost calculation that gives rise to the super-heavyweight prims in certain circumstances.

These shapes are typically rendered with a darker outline showing the mesh triangle edges. 

Case #3 rare and getting rarer

From time to time you may see a magenta wire-frame cube 50% the size of the prim. This is effectively an error report. It means that for one of a number of reasons the viewer cannot display the physics shape. With Prims there is typically only one reason for this, the prim has been forced to use Convex Hull and the user is running a viewer that does not have the capability to decode that hull into a visible object. At the time of writing it is quite common in 64-bit third-party viewers such as Firestorm to show all convex hulls (both for prim and mesh) as magenta boxes. 

Why does this affect 64-bit viewers?

The reason behind the limitation is straightforward once you know about it, the Havok physics engine used by second life is a commercial product, Linden Lab kindly provide a special library that supports a limited subset of Havok capabilities but until very recently, the Lab did not have a 64 bit version of their viewer and did not supply a 64-bit compatible version of the Havok Library. Almost all physics functions in Second Life are handled on the server, however, there are a handful of services required by the viewer and the library provides these. The one that most builders notice is the lack of options in the "analyse" menu on Mesh uploads, but another is the ability to convert a "convex hull" into a mesh shape that can then be rendered in physics view. Thus, to keep this short(ish) when you ask a 64-bit viewer to show a convex hull it says "I can't" by showing you a magenta wire-frame.

The next version of Firestorm will be fully Havok enabled and the vast majority of instances when the Magenta boxes appear will be banished to history.

Case #4 The very small object

This case is a safety net. As we observed in case #3, the equation for calculating the physics cost has an often unexpected side-effect for the uninitiated. The logic behind the calculation is clear enough, the Havok physics engine needs to do less work when it hs handling fewer shapes as is shown in this simple animation from a previous blog.
Smaller triangles more work. Which triangle did the sphere hit?

The earlier blog post gives more details on this and describes the conditions under which the Lab implement a cut-off to prevent the asymptotic behaviour. The mechanics we can leave aside, the result though, for our purposes is a simple box physics that wraps around the small objects, removing holes and details completely. For completeness here, I will repeat the conditions (but keep in mind that at the time of writing physics view will lie.)
IF object is a prim AND has more than 2 dimensions less than 0.2mTHEN force the shape to a convex box.ELSIF object is a mesh AND has one dimension less than 0.5mTHEN force the shape to a convex box   
These are shown without edges and are in some ways indistinguishable from (deliberate) hulls 

Case #5 Hulls analysis and fixed cost physics (not shown in image)

The fifth type of physics is an analysed hull based physics. To produce this the viewer takes a user-specified mesh physics shape and applies an algorithm to it to construct a series of 3d "capsules" called hulls. These are Havok primitives, optimised for the engine to process and can in some cases be more efficient than the equivalent triangular mesh. For reasons I have never fully investigated, the cost of an analysed mesh is frequently higher than the equivalent triangle based mesh, a problem exacerbated by the lack of Havok in 64-bit viewers. For this reason, alone people often avoid it and yet it has some very specific benefits. An analysed mesh has a fixed cost, it does not suffer from the increased physics cost when scaled down and it does not have the dimension based cap imposed so is immune to the "thin wall" problem.

These are deliberate hulls and are shown the same as #1 above (and #4)
There's some good news to come on physics views but for now, I've written more than enough.

See you soon

Love 

Beq

x