Showing posts with label lag. Show all posts
Showing posts with label lag. Show all posts

Friday, January 19, 2018

Better SL Living Through Modding - CRAnQ Scrapper's Retreat

I do a LOT of modding. It's safe to say I have modded every modifiable item I've ever purchased in SL, and so I'm going to be posting a series of articles where I showcase some of the items I've modded, how I did it, and what the benefits were!



This first article features a wasteland shack in a sim I was commissioned to build. It's the Scrapper's Retreat from CRAnQ. A gorgeous looking piece, but out of the box it has a few problems. Namely, it's 241 LI cost and the fact that it uses about 360MB of VRAM in textures alone.

 Up front I want to say that none of this should be taken as a negative view of the creator's work. It's a gorgeous looking building and, sadly, these issues are not widely discussed in SL's content creator community so a lot of people simply don't realize they're issues at all. What you should instead take away from this the awesome thing CRAnQ did, selling the building with modify perms! That is what allowed me to take this great wasteland piece they put together and make it even better, and I thank them for giving me that option.

 In addition, I hope that if they see this article they are able to see what I've done, see how it improves the SL experience, and are able to work these improvements into their future creations!

Reducing Land Impact

 Now, Land Impact cost is easy to understand for anyone who owns or rents land in SL. You only have so much so you want to reduce LI wherever you can so you can fit more content and more detail in your sim. Luckily, this shack is copy/mod so I was able to do exactly that, and easily!

 First, the shack comes with an array of light sources. They're scripted and add a really great effect but a nearly identical lighting effect can be achieved by replacing the 40 light projectors with 4, and giving the side projectors a light map that mimics multiple sources. (Maybe I'll show how to di this in the future!) I went the simpler route for now and just got rid of the light projectors and did some simple local lighting, but recreating the original light effect is on my to-do list.

 Second, the lightbulbs strung along the side were each individual objects. Even worse, they're sculpted prims! If you're not aware, each sculpted prim costs 2 land impact points when linked to mesh! I replaced those with a string light mesh I bought off the marketplace. Took seconds to swap them out. Saved a bunch of LI. In addition, the wall mounted lamps on each side of the roof used a prim sphere overtop a mesh lightbulb, possibly because they didn't know how to script fullbright/glow changes to only the lightbulb part of the lamp mesh. I got rid of the prims and just set the mesh bulbs to glow manually.

 All of this means I lose the scripted lights on/off feature but I don't really need it.

 Next, I realized that by setting the entire building to "no physics" and replacing the physics with an invisible shell of box prims set to "convex hull" I was able to save yet more land impact.  This doesn't always work, but it works often enough to give it a try and here it ended up saving me a tonne of Land Impact points.


 And finally, the building was way too large so I shrunk it down to proper scale for the sim, reducing the land impact even further. Larger mesh objects cost more LI because they retain their higher LOD levels over greater distances the larger they are. Most content is made around twice the size it should be if everything is to scale with inworld measurements. Shrinking your avatar to human sizes and adjusting your camera so it doesn't need so much more space for you to see properly really helps you save a lot of space and money. If you ever thought land in SL was too expensive, this is the easiest way to cut the cost of land drastically.

 Doing these simple things I reduced to LI cost of the structure from 241 to 123. About half. Still a lot for a single structure, but given the sheer amount of detail I'm a lot more comfortable with it.

Reducing VRAM/Texture Use

 VRAM/Texture Memory is less common knowledge in SL but I'll try and summarize. Your graphics card has a set amount of memory to use rendering what you see in SL. All the textures you see have to be in that memory to be displayed, but so much more relies on that memory so you cannot max your card's memory out on textures alone or you see massive framerate losses and "texture thrashing". Texture thrashing is when you see textures going blurry and re-rezzing. You also have to download all these textures, which contributes to lag and slow rez times.

 360MB might not sound like a lot of memory, but it's only one building in an entire sim and then you throw avatars and their memory use into the mix. My videocard only has 2GB of VRAM. It's a midrange card, a few years old. Newer, more expensive cards have up to around 8GB. Onboard graphics have very little, if any, dedicated memory.

 Following so far? Ok, good!

This scrap house is covered in various unique corrugated metal panels. They're not identical. Out of the box there's like 6-12 different panels each with it's own texture, spec map and normal map. All of which are 1024x1024.  Each texture uses 4MB of memory on its own and it's simple arithmetic to see how that adds up.

 What I did was remove every type of panel except 2. Then I copied the remaining 2 panels to replace each of the panels I removed. Not difficult, but a little tedious and time consuming. But worth it! I was able to reduce the memory load of the house from 360MB down to 207MB. Here's a screenshot from the marketplace listing showing the original texture variety so you can compare. Yes, it's a little more detailed, but that detail comes at a cost in framerates, lag, and texture thrashing. What's more, are people going to notice the difference? Those who saw this building in my sim before and after did not notice the change until I pointed it out to them myself.



 You might be able to do the same if you notice items in your sim are similar, yet use different textures! Many SL buildings, for example, will have nearly identical textures for walls, floors, etcetera, where the only differences are slight variations in shading or colour that most people will never even notice! You can compare textures in the preview window of the texture chooser tab of the SL editing panel and see if this is the case, then it's a simple matter of unlinking pieces, and copying the one instance to replace the pieces with the redundant textures! In some buildings this is easy, in some buildings all of the walls may be a single mesh object which means you'll have to look for an alternative solution, such as replacing the textures entirely with one of your own.

 I also noticed that this house used the same stair kit as another building I have in the sim, but different textures. I swapped out the stairs with the identical stairs from the other house to reduce the sim's VRAM load further! And other buildings in the sim also use corrugated metal panels, I replaced them all with one of the two metal panels from this house and probably cut another 100-200MB of memory out of the sim. All of this means visitors to the sim get to experience higher framerates, less lag, little if any texture thrashing and fast rez times!

 And I hope the rest of you are able to implement these ideas into your own homes, clubs, RP sims, and other environments and improve your own SL experience! I'll be posting more articles like this, showcasing modifiable content that I've purchased and found ways to improve. Until then, take care and keep fighting the good fight!

Tuesday, July 19, 2011

A Brief Thought About Script Memory

 I have seen  a growing number of people in Second Life lately claiming that excessive script memory use does not create lag.

 I understand the argument. Theoretically, when script memory use exceeds a sim's allotted 300MB of memory (I've also heard 100MB, not sure which is the case), scripts simply cease to function, going into a queue until it's their turn to get some of the sim's limited resources. A step LL took deliberately to reduce sim lag.

 It makes sense, and yet experience tells me it's not entirely true.

Just today I was at the Island of Milk & Cream, a sim I did the majority of the building and design for, when the lag spiked terribly. With 10 people in the sim, at one point four of whom were using around 20-26MB of script memory. One of them quickly left but three remained. The avatars in range of my script memory HUD were totaling 120MB of script memory, in addition to whatever the various builds in the sim take up and the avatars not close enough for me to see.

 As the worst offenders dwindled to only one. the sim performance improved substantially. At the moment there are still 8 people in the sim totally only 38MB and the lag is pretty much gone. 

 Another sim I frequent, Doomed Ship, regularly has 10-20 people or more and yet never has lag as bad as Milk&Cream regularly experiences. Neither sim is a Homestead, they're both full sims. The difference is that Doomed Ship does not allow individual avatars to exceed 7MB of script use and runs a campaign to encourage as little individual script impact by avatars as possible. They're quite friendly and helpful about it with staff members willing to take the time to actually sit down with visitors and help them reduce scripts without losing their favourite features.

 Admittedly,  this is all based off my experiences, not hard technical knowledge of how script memory impacts sim performance. However I work closely with a number of SL's top scripting talent and they all agree that script memory use does have an effect.

 When Linden Lab first introduced the feature to see script memory use among avatars many people worried it would turn into some sort of witch hunt. In some places in SL maybe it did, but I never experienced it. Most places I have seen which even have public "script use boards" displaying avatar memory use still have no actual rules against excessive script use, but encourage people to understand that such excessive script use is a primary cause of lag.

 I think that is a good first step that should see wider use. Rather than immediately clamping down, popular areas should merely point out avatar script use and explain how it impacts the performance of the sim for everyone. Explaining how to avoid excessive script use while still enjoying the range of features people are accustomed to (lower script memory use does not mean sacrificing features, many scripted items in SL are simply scripted poorly and there are better scripted alternatives).

 LL should also make it easier for the average SL resident to check their own script memory use and what attachments contribute the most to their impact on sim performance.

 I'd go so far as to say LL should make some of the better shopping habits a part of their own suggestions to new residents.

 1. Avoid no-mod scripted items. 

 2. Look for script memory use to be listed on vendors. If script memory use is not listed, ask the creator how much memory the attachment (and any accompanying HUDs) uses.

3. Remove scripted items that you do not actually use, such as combat or role-play HUDs in areas where they serve no purpose. Or hidden attachments that you're not currently using.

4. Remove unused scripts from attachments. If you have a favourite gun you wear on your intergalactic bounty hunter avatar, but you don't actually use it's scripted features it's just for looks, make a copy and remove the scripts! Have some heavy armour filled with colour change scripts you never use? Remove those scripts! Resizable hair? After it's fitted, make a copy and remove the scripts from the copy you wear.

4. Try and keep your overall script memory use under 2,000kb.  Most places generally suggest 5,000kb but you really should be able to have all the features you enjoy and stay well under 2,000kb. Aiming for 2,000kb and lower (I'm usually around 400kb-500kb and my avatar is heavily scripted with features) will put more demand on content creators for efficiently scripted attachments and HUDs.

 Content creators themselves should remember to try and make script efficiency a feature. Advertise how little script memory your attachments eat up. Work towards reducing the number of scripts in your creations whenever possible.

 Linden Lab should take this a step further by making script memory a part of marketplace listings just like perms and prim count.

 The onus is on LL and content creators if we want people to reduce their script use. The average user just knows that they want their features, and reducing script use by sacrificing those features is not what they want. However, once low-memory alternatives are available, it becomes much easier for them. There's really no reason why having a well scripted avatar shouldn't be that easy.