Object Baker - WIP

Unity Editor Tool

Overview

Object Baker is a Unity editor tool designed to reduce draw calls by combining collections of objects with simple colored materials into a single object with one submesh, one material, and one minimal resolution texture.

The tool works by combining submeshes into a single mesh, generating a texture from all their material colors, and mapping the UVs of the new mesh to this texture. This results in an identical looking combined version of the original subobjects, decreasing the number of resource swaps required for rendering.

Current Features

Object Baker is distributed as a Unity asset package compatible with Unity 2018 and 2019, and runs in an editor window. The interface is shown to the right. It allows you to specify which objects to combine and what name, parent and shader to assign to the new combined object. Adding an object also automatically includes its children in the bake.

The user can also set the maximum texture resolution for the outputted color map (clamped to a power of 2), from which Object Baker chooses the lowest possible resolution below that limit to use. The tool currently only works with solid colored materials, so materials with textures are interpreted as their main albedo color.

Baking outputs a combined mesh, material, texture, and prefab object saved as assets in the Unity project. The video below shows an example run of Object Baker, combining 212 objects with 8 different materials into one.

Planned Features

Based on user feedback, there are a few more modifications to make before releasing this tool to the Unity Asset Store. After they are implemented I plan to put it through another round of user testing and then release it. I'm also looking into getting it working with textured objects, which would turn it into a handy texture atlasing tool. In the meantime though here is a list of modifications currently in the queue (being updated periodically):

  • Add support for meshes where the combined number of vertices exceeds the 65,536 index limit.

  • Copy colliders and other essential components from the original to the combined prefab.

  • Preserve original UVs.

  • Look in to other texture scaling algorithms.

If you have a particular interest in any part of this project or suggestions for features that you think should be included, feel free to reach out. I'll continue to update this post as I make more progress, and hopefully have the first version ready for release in the near future.