Sculpt animation and CPU usage

Tips and discussions about using OpenSim
Post Reply
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

Sculpt animation and CPU usage

Post by Kayaker Magic »

My world Panthalassa has an unusually high CPU usage and I just did an experiment to try and identify another source of this.

I hypothesized that one source was the "sculpt animation" that I use to move the legs and heads of many of the creatures wandering around.

In sculpt animation, the head and legs (some critters have 6) are a single sculpt prim. As the critter looks around and walks, the script changes the sculpt map to a different shape for each position. I made sculpts of the legs in 6 different positions and the script switches between these in a cycle as the critter walks. (If you re not careful, the viewer throws the sculpt maps out of the cache and the legs turn into blobs while bandwidth is wasted downloading them again and again).

This looks very nice, but there are several problems. One is that the server does a "full update" of the prim each time I change the sculpt, which uses up a lot of bandwidth that may slow down the viewer. The other potential problem is that the physics engine wants to re-generate the "physics capsule" for the prim every time the shape changes. (I have to keep at least the body of the critters non-phantom so they can be detected by guns and hunted). So I may be using up a lot of CPU time by changing the shape on 6 legs (plus the head) on a dozen critters twice a second. (When I tell this to Ilan or other grid managers, their eyes bug out, their bow-ties spin around and steam comes out their ears. At least that is the impression I get when I read the email response). So is it really true that sculpt animation is a significant source of CPU over-usage?

To test this hypothesis, I loaded an OAR copy of my world Panthalassa into a new temporary world. I watched the CPU statistics for a while and eyeballed the running average at around 40%. Then I ran around and deleted everything that crawled, walked, flew or swam using sculpt animation. I eyeballed the CPU usage at 25% afterwards. Not the magic cure I thought it would be, but significant.

So it would be nice to move away from sculpt animation, but what are the alternatives?

1) Puppeteer style animation. The script moves and rotates the legs. This is nice because moving a child prim is a "partial update" and uses less bandwidth. There is no CPU hit for re-calculating the physics capsules. HOWEVER, if you want your critters legs to bend at the joints you have to make each leg out of 3 or four separate prims. You have the complexity of keeping track of where each prim is. You have to send position updates to all these new parts, which drives the bandwidth back up again. And there is the problem that when you move and rotate a prim at the same time, the viewer often shows it going through some unnatural positions on the way from one position to another. You can fix that by making each prim a mesh that has an invisible extra material part sticking out that makes them rotate around the joint. A tremendous amount of work to take something that works fine and make it work about the same again. For a 15% decrease in CPU time on the server if I am lucky. I'll give this a try in my spare time. (I think I have some spare time scheduled for 2020).

2) Alpha animation. You make your critters out of one giant mesh with each leg duplicated 6 times in 6 different positions. You use llSetAlpha() to make all but one leg at a time transparent. This sounds nice, since llSetAlpha is a partial update, but IT DOES NOT WORK. It does not work because the server and the viewer conspire to try and save bandwith. If you make something transparent with llSetAlpha and then make it opaque again, the viewer notices this and skips the inbetween step to save time. The leg stays transparent all the time, or several of them appear at the same time. Even if it worked your critter has thousands of extra vertexes for all those parts that are invisible most of the time. This increases your land impact and load times.

3) Transparent animation. Same as 2) but you change the texture map of all the legs to TEXTURE TRANSPARENT accept for one of them which you re-load with your correct texture map. Every single step, 6 times a step, two times a second on 6 (or only 4 for a Terran horse). Changing the texture map on a prim is a full update and uses more bandwidth than llSetAlpha, too bad. (If you are not careful the viewer will throw the texture maps out of the cache and the visible legs will look fuzzy while the texture map is downloaded again and again, wasting more bandwidth).

4) Design a skeleton for your critter in Blender, rig the critter's mesh to that and download small animation files to move them. Oops, that is not an implemented or even talked about future feature of OpenSim.
User avatar
Ilan Tochner
Posts: 6504
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4943 times
Been thanked: 4455 times
Contact:

Re: Sculpt animation and CPU usage

Post by Ilan Tochner »

Hi Kayaker,

In general, if it constantly moves (or moves often) then make it phantom. If it constantly changes shape (or changes shape often) then make it phantom. Your creatures both move and change shape so it's not surprising that they create both a lot of load on the physics engine and a lot of network load.
Post Reply