Optimizing. The art of reducing the load whatever device or human has to do in order to achieve its goal. (It's the thing this Viewer is completely missing and thus running so awesome \s)
So first things first. Why would i want to optimize my Avatar? There are multiple reasons you would want to do so, for example: peeps actually being able to see the random assembled pile of attachments you call your avatar. I mean let's be honest, what is the Avatar's most important purpose? Of course its showing it to others, otherwise you could just run around as cloud and smack a texture onto your HUD that looks like your Avatar would so you can see it at all times. Another reason would obviously being saving your own hardware the extra work of rendering more than it should, this goes for both you and everyone around you. If everyone did this, Second Life would run so much better.
So let's start with some basic information to measure our optimization later on.
This is the original (pre optimization) picture. The avatar used 92mb texture memory, most if not almost everything consists of 1024x1024 textures, each of them 4mb or 5mb if an alpha channel is included, which quite a few had. It used 92000 polygons. 320kb script memory.
First thing we want to optimize is the huge amount of texture memory this avatar is using. 92mb is way too much. This is still tame compared to most other avatars (especially human ones) i see with upwards of 200mb usage, some even go beyond 400mb. How do we go about this?
Lets go through all the attachments and check the textures, check which ones have which sizes and which ones use unnecessary extra textures and alpha channels.
Going through the attachments i found the following:
- Sockings used 1024x1024, we can potentially reduce those to 512x512, that alone would quarter the memory usage of those.
- Jacket used multiple 1024x1024 as the main texture (diffuse), specular and normal maps, some parts have different variations of the same texture, the metal parts did so because i chose to use bronze ones rather than the same texture for everything. Depending on how you mix and match the textures of multiple colors you incur another 1024x1024 texture (4mb) memory usage. I got an idea how to reduce this, more on this later.
- Ears use multiple 1024x1024 textures, this is definitely too much, we'll try to cut down on these.
- Horns use the same 1024x1024 textures but in a different color, we can cut down on this.
- Mane and ear fluff use 256x256, this is pretty small but we can potentially reduce it further since its just a very simple hair texture.
- Cheek fluff uses 1024x1024 textures too, these look very simple too and could easily be reduced.
So... how do we go about reducing them? I do what all modders have been doing for a long time. I downloaded GLIntercept (64bit) from google and put it into the Viewer's folder, configured the ini file to take only one frame on pressing the shortcut rather than constantly dumping all textures causing the Viewer to crash. (Only enable those shown in the pictures, make sure all other features are set to False, if you did everything right you'll get a massive freeze for up to a minute when hitting the shortcut Ctrl + Shift + F here while all textures are being dumped)
Starting the Viewer and hitting the shortcut after all my textures have loaded will dump all of them as configured in the file as TGA files in the Viewer's folder. I went into the folder, selected all textures i needed and copied them out of the folder so i can find them easier.
In the Viewer i go through all attachments, selecting the local textures i just saved as texture to be used after i added them via the Local Textures tab. Now that all textures are replaced with the local ones i'm going to edit i can immediately see the changes, we need this to see whether our optimization has any visual quality loss.
- I started with the sockings, reducing their size from 1024x1024 to 512x512, this quarters its memory usage and looks quality wise almost exactly the same.
- The jacked i cut out the bronze metal parts and pasted them into the main texture combining them and removing the metal screws so i can get rid of the arm pouches too. I couldn't reduce the size as it would lower the visual quality massively but combining two 1024x1024 to one already saves us 4mb here.
- The ears i couldn't reduce in size either without clearly impacting the visual quality a lot so i kept it at 1024x1024 but i removed the alpha channel and replaced all textures with mine, saving me 1mb for both the diffuse and the specular map.
- The horns used the same texture but in a different color, i simply used the texture i made for the ears (but i'm thinking of combining the black horns with the blue ears) since both use the same UV to save another 5mb each for diffuse and specular.
- The mane and ear fluff i reduced to 128x128 down from 256x256 because it doesn't matter as it was just a simple solid hair texture without much detail saving us a few KB.
- The cheek fluff was a whopping 1024x1024 again which i quickly reduced to 256x256 and removed the alpha channel saving us a whopping ~4.75mb again.
After being done and happy with the changes i saved all textures and uploaded them, applying them where necessary and making another pass to remove any textures not necessary such as those on invisible parts of clothing.
After applying all the textures i put down my body and removed the Cobra hood that i alpha'd because it is not used for this mod, saving me another 12mb textures (diffuse, normal and spec) and reducing my polygon count by another ~1000 polygons.
Now that we're done it's time to measure our stats again. The Avatar now uses 35mb texture memory or 25mb if you don't count doubles (they are being counted towards the memory usage if they are on different attachments), most textures have been reduced at least one notch and almost all alpha channels except that of the jacket since we use it, were removed and since we set the jacket to be Alpha Masking its properly shaded and has no measurable bigger impact than that of Alpha Sorting. Our polygon count is now down to 91000 and script memory is still 320kb.
This leaves us with only two more options to optimize. The polycount and the script memory usage. The easiest being the script memory usage. 320kb really isn't much but we can still cut down on it by removing all unnecessary scripts we don't need, such as the texture changer scripts. All the new attachments are scripted and removing their texture changer scripts cuts us down to measly 234kb script memory uage, ~27% saved.
Last but not least, polycount. 91000 isn't much but it's still too much when compared to any game. We can't go down to the magical 40000 and sadly the jacket is not made out of several linked parts so i cannot remove those either, the only thing left for me to optimize here is the double crotch i got because i fucked up when i uploaded the modded avatar and didn't include the skeleton deformations so i need an original part that contains them to make sure my Avatar is properly deformed, i could remove it and reupload the mod with skeleton deforms to save another 2500 polygons but that's about it.
Here's the final result as comparison.
You don't see any difference? besides the now properly hidden arm pouches that is... i don't see one either. Mission Successful we reduced the texture memory usage by roughly 70% and the script memory usage by 27% as well as the polygon count by 1000 polygons. We are now ready to go into the world and present everyone this cute Avatar.