Model Optimization


Laugexd's Guide to optimizing Custom Models for Beat Saber

Introduction


This guide is made for people who want their file sizes even lower, this might not seem that important but if you were to also make your model available on a mobile headset, you will be better off doing the optimizations.

In this guide, I will be going through how to optimize images, how to optimize 3D models, and how to optimize your workflow.

Disclaimer: This guide is recommended to be followed, but it is not required.

Optimizing Images: Bringing down the bulk of the file size


Images can be a big cause of filesize bloating, to the point that a single image may even take up half of the file, take these 2 models as an example.

filesize comparison

The top model's icon has been optimized, the lower model's icon hasn't, other than that they are mostly the same.

So, what went wrong with the lower one? Well, the original icon's resolution on both of them is 1024x1024, but the top one had the image used in the exported model as 256x256 and optimized it with the help of OptiPNG.

You might be thinking: "Is it really that easy?" and the answer is yes, yes it is, and then again, not really.

The only reason I am using PNG in the first place is because the icon has transparency, normally I would go with JPG if the file size ends up being lower, but JPG doesn't support transparency.

Now, OptiPNG is, in fact, a program used to losslessly compress PNG files, but I've taken the time to include a few links to plugins for different image editing programs allowing you to export an image with OptiPNG.

If you were to export a plugin as a JPG, you would be better off using a lossless JPG compression tool, like jpgtran, here are a few links for plugins using it:

Now, what if you were to upload the model to ModelSaber? Do you still need to optimize the images for that? At the time of writing this, yes, but automatic image optimization will be implemented in ModelSaber v2, it will ONLY take care of actual lossless compression, you still have to think of the resolution.

ModelSaber v2 will also have a minimum upload image size of 512x512 so keep that in mind! I also personally recommend uploading an image with the resolution of 1024x1024 to ModelSaber, it has a good resolution and a small filesize.

Now, on to MipMaps.

I am not the most knowledgeable on mipmaps, but I do know what they are and what they do, if you don't know already, think of LODs but for images.

If you don't know what LODs are either, it's a way of switching out a 3d model with a lower quality one when it's so far away that you can't notice the difference.

Now, read that sentence again but switch out "LODs" with "MipMaps" and "3d model" with "image" and you have the description of what a mipmap is. albeit with broken grammar

ALWAYS have mipmaps on if the asset is to be used in a game, there are close to no exceptions to this. It increases filesize BUT it also brings vast performance increases, if you want to know more about mipmaps I recommend reading unity's guide on them.

So, in short:

  • Save the original icon to your device with the native resolution of 1024x1024.
  • Save the icon used for the export with the downscaled resolution of 256x256.
  • Run the icon for the export through a lossless compression tool.
  • Do the same for any other texture asset you use in the model, except for resolution, the resolution depends on the use of the texture, experiment in these cases.
  • Use mipmaps.

Optimizing Models: So people can handle your stuff


Models are not my strong side (shocking) so I might not be the best at writing this section, I can give a few pointers though:

  • Don't add unnecessary polygons, if you assume that "this will do" you're wrong, take the time to figure out exactly how many you need before there is a noticeable change, and then go just below that. Am I responsible for doing this? Yes, on countless occasions, but I never said I was a good role-model
  • If something isn't used, delete it, even if it is disabled in unity it is still there in-game, so if it's never used, just get rid of it.
  • ALWAYS prefab your models, turning models into prefabs and turning on Batching for the model will let your GPU use the same calculations for everything in the prefab instead of redoing it every time, this increases performance immensely and is strongly recommended.
Note: Knowledge of unity batching is based on prior knowledge, I have not tested its performance impact in Beat Saber.

Optimizing your Workflow: Running through unity at the speed of sound


You might think "how does optimizing my workflow help with my models?" and it's very simple, I can give you an example in fact.

Before I optimized my workflow it could take me up to 30 minutes to make a simple model in unity, after optimizing it, it was down to 5 minutes, this was including an edited model AND the creation of the icon.

So what did I do? well, I don't have images from before my optimization but I can give you an example from after I optimized it.

folder example

as you can see, I have a very organized folder structure, everything is organized compared to before.

Every single bloq has its own folder and scene, this is to eliminate as many dependencies as possible so if I were to make a unity package for the bloq, I would easily be able to.

You can find the unity package for this model by clicking here.

So in short:

  • Be consistent.
  • Place things so you know where they are.
  • Be organized.
  • And most importantly: Have fun :)