3 Tips to Optimize your 3D Scenes

Wolox Engineering
Wolox
Published in
4 min readAug 20, 2015

There comes a time when using a 3D library or engine where everything is working fine, just dandy, and then suddenly, you realize with a groan that your project’s FPS has dropped low. When I say “low”, I mean “hugging the floor low”.

Something that many people do not take into account is that 3D scenes can and should be optimized for a smoother, more enjoyable experience. Be it Three.js, Unity or Unreal Engine; any work in 3D has a fair few of tricks to achieve a fluid animation or game.

3D optimization gives you better frame rates AND better load times. What’s not to love about it!?

1) USE LOW-POLY MODELS

First things first. In any given 3D framework, you are going to have 3D models. That’s pretty much the whole point of using a 3D framework.

You want to use the models with the lowest polygon count possible without affecting their quality. So, you should set a standard for the graphics quality you’d like to have, and follow through by having all your models live up to that standard. But, it’s a given that if you can remove a few polygons without really noticing the difference, you should go with the lower poly-count.

Poly-count is a huge factor in GPU processing, so you have to make sure a model has a certain quality depending on the number of times the model will be used in a scene.

If a model appears dozens, even hundreds of times in a scene at once (a crowd or a forest), then it must be low-poly, or else your GPU will complain loudly about the workload.

On the other hand, the main character can definitely be high quality since it is usually only one instance of the model at any given time.

Blender, 3DS Max, Maya, etc. all have useful polygon reduction tools or scripts, so be sure to check them out and give them a spin.

Can you tell the difference between the first horse and the second one? Me neither! But your GPU can. The one that sets it on fire is the one on the left.

2) COMPRESSING TEXTURES AND AUDIO FILES

In a similar vein, textures and audio files are sometimes too ridiculously high-quality for their importance in the scene.

You should compress any and all textures used on your models, since the quality loss in texture compression is usually minimal. Just do it carefully and be sure that you like the resulting quality.

Audio files should be treated in a similar pattern. Check out the audio files you have, see if you can compress them without losing that much quality, and you’re all set.

A trick you should employ is using repeating loops for background music instead of long songs. That way, instead of having a 3:30 song, you can have a 30-second loop and get the same effect.

Any number of tools, both downloadable and online, can be used for audio and image compression.

3) USING OBJECT POOLS

Object pools are a clean and efficient way to handle multiple objects that must be spawned and removed from the scene repeatedly. The clearest example is any kind of projectiles in a game, such as bullets in a first-person shooter.

The use of instantiation and destruction methods is usually expensive: behind the curtains, memory is being reallocated, the language’s garbage collector (if it has one) has to be called, and the objects’ memory may have to be manually freed (given no garbage collector). This can result in sudden dips in FPS. Of course, we do not want this to happen.

All this can be avoided by using a pool. No, not the one you swim in, I mean a large amount of the same kind of object created when first loading the game. Need bullets? Spawn a few dozen of them when booting up the program.

This object pool can be floating around somewhere offscreen, motionless. All you need to do is take an object from the pool whenever you need to ‘instantiate’ the object (firing a bullet from the gun, in our example) and move it instantly towards the point of use by setting the exact position of the object. Then, feel free to use it however you want!

Once you need to destroy the object (e.g. the bullet hits a target), simply put it back in the pool, where it doesn’t bother anybody.

And ta-da! Easy performance boost!

These are a few tips to ensure you have a more efficient, easier-to-load scene in your 3D engine. Trust me, once your scenes get bigger and heavier, you’ll need to optimize them in any possible way!

Posted by Iñaki Lanusse (inaki.lanusse@wolox.com.ar)

www.wolox.com.ar

--

--