Realtime 3D Optimization Cheat Sheet

AKA Before Handing Assets To The Engineer

Minimize The Number Of Materials

kuesa logoPerforming “draw calls” or “state changes” are the most expensive things to do in OpenGL. But, at the same time, they are necessary whenever your app does something like change a texture, material, or camera, in order to draw a bunch of objects with those settings. While you have no influence on some things, like changing the camera, you should pay special attention when creating materials in your 3D scene in Maya. Kuesa tries to minimize shaders for similar materials. However, it is most often the case that only one draw call or state change will be performed per shader program. So, use materials thriftily! Reuse them whenever possible!

Minimize Shader Complexity

Always use the simplest material that is “acceptable.” This is a list of KUESA materials, from simple to complex:

  1. Iro matte materials
  2. Iro Diffuse and Alpha materials (SEM is cheaper than ER)
  3. Iro Glass (SEM is cheaper than ER)
  4. PBR

Pay special attention when using custom shaders! Avoid throwing in all kinds of fancy features. Always keep an eye on performance.

Minimize Texture Size

You are limited in resources, sometimes very limited. There is no rule of thumb for how large textures can be. You just need to test this with your target hardware.

Try out smaller textures and compare! Smaller textures result in less data to load and, therefore, less memory to transfer between the CPU and the GPU.

Clean Up

Clean up the objects! Repair invalid meshes, freeze some transformations, and delete the history to minimize issues.

Minimize Number Of Entities

If you import a car or just build some complex object, you might easily end up with a couple of hundred objects. Managing those in real-time (which will happen in each frame) can be rather expensive.

So try to keep the number of entities to a minimum! Try to merge meshes with the same material (as long as you don’t need to animate them separately)! But don’t tradeoff tidiness just to save a couple of empty nodes.

Minimize Polygon Complexity

You can’t just import a car with a couple of million faces and run this on your target device. You are limited in resources — sometimes very limited. There is no rule of thumb for how many vertices or faces are allowed per scene. You just need to test this with your target hardware.

Optimize the mesh! One easy way of doing this is by removing edge loops manually. Don’t use automatic tools, since those will most likely leave you with a messy mesh.

Make sure your mesh is tidy and clean, preferably a quad mesh. Clean meshes can be reduced more without losing quality, as opposed to chaotic triangle meshes.

But keep an eye on reflections and test your optimized mesh with reflective materials. Reflective objects are usually less forgiving.

Smaller meshes result in less data to load and therefore less memory to transfer between the CPU and the GPU.

Minimize Fillrate (Rendered Area)

Especially when using transparent materials, some areas of the screen need to be rendered again and again. This costs performance.

Try to minimize the rendered area! Most of the time, it’s better to use a smaller mesh instead of using a huge alpha texture where only a small area is used.

Keep It Simple And Tidy And Use Proper Names

Make the life of the developer easy! Make the scene easy for others to understand, by tidying it up and giving objects proper names! The scene hierarchy and the object names are the interface between art and development.

Leave a Reply

Your email address will not be published. Required fields are marked *