Mesh Baker by Digital Opus [RELEASED]

If you care about performance… combine meshes, combine meshes, combine meshes!
Mesh Baker is the ultimate mesh-combine tool, combining many meshes into one big mesh, as well as combining the textures on those objects into texture atlases and texture arrays. Mesh Baker is a powerful toolkit of flexible non-destructive workflows for optimizing props and scenes.

Objects to be combined do not need the same material or even the same shader:

  • Works with built-in and custom shaders
  • Texture atlases are automatically generated
  • Supports URP, HDRP, Standard pipelines

  • Generate either Texture Atlases or Texture Arrays

  • UVs, Normals & Tangents automatically adjusted

  • Tiled textures can have tiling baked

  • Only parts of source textures (atlases) used by source meshes are copied to the target atlas

  • Can map multiple materials to a combined mesh with multiple materials

  • Create atlases for materials that use color tints

  • Can modify prop prefabs to use atlas materials or combine scene meshes and modify them to use atlases

  • Can create and swap parts of skinned meshes at runtime. Change clothing, add wounds, add armor.

  • Can combine many SkinnedMeshRenderers and MeshRenderers into a single SkinnedMeshRenderer

  • Can bake blend shapes of skinned meshes

  • Animations on bones remain intact

  • Can customize SkinnedMeshRenerers by adding MeshRenderer objects (hats, glasses, weapons)

  • Can generate lightmapping UVs so the combined mesh can be lightmapped

  • Control over which channels in the combined mesh are generated

  • Non-destructrive workflow. Does not touch source assets (creates new combined mesh and texture atlases)

  • Can bake into multiple combined meshes if the combined mesh would be very large.

  • Choose between five different texture packers

  • No scripting required

  • Easy to integrate into existing workflow

  • Adjust meshes and prefabs so they can share a material (take advantage of static/dynamic batching)

  • Clustering tools to easily group meshes that are close in a large scene

  • Robust, fast, mature, documented API with examples:

  • Bake materials and meshes at runtime

  • Runtime add, delete and update update objects in a combined mesh

  • Use the API in the editor to integrate meshbaker into your workflow

Use MeshBaker To:

  • Combine meshes in your scene into one big mesh (meshes can be imported from any modeling program)
  • Easily create materials that can be shared by multiple meshes.
  • Easily create Texture Arrays and modify meshes to use them.
  • Fix models and prop prefabs so they can share a material and take advantage of static/dynamic batching
  • Customize SkinnedMeshRenderer characters (add weapons, hats, armor, clothes)
  • Combine several SkinnedMeshRenderers into one
  • Combine many dynamic low poly regular meshes into a single skinned mesh
  • Fix or adjust scaling, rotation and translation in imported meshes
  • Create a color-pallet-atlas for a groups of different props that use only color tints so that they share a single material

Limitations:

  • Texture properties in the result material will be combined into atlases, but the other properties can't be combined. There will only be one master set of non-texture properties that applies to the whole combined mesh.
  • Baking tiling can produce large atlases or exceed the maximum size of the atlas.
  • Some meshes are difficult or impossible to combine:

  • If meshes have channels (colors, or tangents) which others do not.

  • Submeshes that share vertices and have UVs outside the range 0,0..1,1

  • If you want to combine meshes and preserve existing lightmapping, then source meshes must use the same lightmap.

  • Mesh Baker cannot combine Skinned Meshes that have "Optimize Game Object" checked in the import settings (Rig tab). This is because the bones on these objects are not exposed to be combined.

Links

How To Use Mesh Baker
Basic usage:

  • Create a new MeshBaker object in your scene under the Game.
  • GameObject -> Create Other -> Mesh Baker -> Material And Mesh Baker
  • Create empty assets for result material.
  • Select shader on result material. Meshbaker will build a texture atlas for each texture property in this shader.
  • Add objects to combine. For best results, these should use the same shader as result material, but they don’t have to. Use the provided tools to make this fast and easy.
  • Bake combined material.
  • Bake meshes.
  • Look at warnings / errors in the console. Decide if action needs to be taken.
  • (optional) Disable renderers in source objects.

Once this has been done you can remove the MeshBaker object from the scene or keep it around for easy re-baking. If anything changes in any of your source models or textures just bake again to regenerate the combined mesh and texture atlases.

Video Tutorials

1 Like

So, what's the benefit if I already have Unity Pro? How does it compare to Unity's own Static/Dynamic Batching?

Unity's static/dynamic batching has a significant limitation: all objects to be combined need to use the same material. If you want to combine objects with different materials (even if they use the same shader), you need to build atlases and adjust UVs in the meshes. This is labor intensive, tedious and difficult. Mesh Baker can combine many materials into one (including combining all necessary textures into multiple atlases and adjusting UVs) in seconds.

Unity's dynamic batching is limited to meshes with less than 300 vertices. Mesh Baker runtime API has no such limit, although at some point it becomes more efficient to render separate objects rather than to rebuild a mesh every frame.

Mesh Baker can also bake translations, rotations and scaling into meshes.

  • When importing models from Blender, the importer applies some rotations to the model to make it line up with Unity's preferred coordinate system (y-up, z-forward, x-right). Other scripts applied to the model can be confused by these rotations. Mesh Baker can bake a perfect copy of the model that lines up with Unity's coordinate system.
  • Some models have their pivot point in an inconvenient location, such as their center instead of their base. This makes them hard to place. Mesh Baker can bake a translated copy.
  • Non-uniform scaling of meshes can mess with physics calculations. Mesh Baker can bake the scaling into a copy of the mesh which can then be used without the need for scaling.

Some models import from 3D Modeling packages as multiple separate objects (For example a chair consists of several planes and many cylinders). Mesh Baker can combine these into a single mesh, which is much easier to work with.

I see, thanks for the explanation. I will put it on my to-buy list. :)

Is 100% compatible (without exceptions or warnings) with Unity 4?

Yes, Mesh Baker works with Unity 4

Thanks for the info, pal. Maybe I will buy this soon once the fix is updated.

This looks very beneficial to my project. I will also be purchasing this once you have updated it to support 4.0

The update has been submitted to the asset store. It generally takes 1-3 days to be approved.

can work with Mega-fiers?

[quote=“jerryholand”, post:10, topic: 490738]
can work with Mega-fiers?
[/quote]

I don’t have mega-fires so I can’t be certain everything would work. It all depends on whether Mega-fiers edits the sharedMesh in the editor or not. I can think of a few scenarios that would work for sure:

Things that would work for sure:

  • Runtime combining of meshes. The meshes would be combined in whatever state they are in.
  • Runtime updating a combined mesh every frame from a mega-fiers object that is being deformed every frame.
  • Editor - Using mega-fiers to deform a mesh then deleting the mega-fiers modifier component (leaving a deformed mesh). This mesh could definitely be baked in Mesh Baker.
  • Editor - Using Meshbaker to “bake meshes in place”. This creates modified copies of meshes that are all capable of sharing the same material. Then you could deform these new meshes all you want with mega-fiers. After deforming you could bake these meshes together again or, if you have pro, let Unity static batching combine them.

Things that might work:

  • Using Mega-fiers to deform an object, then baking that object while the Mega-fiers modify object component is still attached. (if this does not work it might be easy to modify Mesh Baker code so it does.)

Things that probably do not work:

  • Using Mega-fiers UV deformation on a combined mesh or on a mesh that has been “baked in place”

i need something like that for 3ds Max.

[quote=“Jum”, post:12, topic: 490738]
i need something like that for 3ds Max.
[/quote]
Mesh Baker will work with models imported from any modeling program.

Great to see it released so fast!

I wonder if it makes sense with animated meshes too, lets say I create 100 animated butterflies with skinned meshes. And they already share the same shader and texture, would it still make sense to combine the animated mesh?

And one more question, I have a castle model from the big environment pack, it uses a few submeshes and and some of the textures of the wall are tiled, is there a way to create one mesh with 2 uv sets, one for the overall texture and another for the tiled textures?
And optional to bake down the tiled textures into the main texture, this would cause inefficent use of texture space but might improve performance.

Hi Lars,

I am planning to add support for skinned meshes soon. For skinned meshes it would make more sense to bake them all into one huge skinned mesh instead of baking into a MeshRenderer. I also hope to make it possible to bake other meshes onto a bone of the skinned mesh. This would make it possible to add an axe, sword, gun, armor, hat, glasses etc.. to a skinned mesh without extra draw calls.

Currently I am working on better support for multiple-materials/submeshes. This allows mapping multiple input materials to multiple output materials. For example if combing many trees, you could map all the bark materials to a submesh with a combined bark material and all the leaf materials to a submesh with another leaf material.

This new version can also bake tiling textures as you suggest. Unfortunately it can lead to large atlases. Sometimes it is better to bake:

  • All buttresses together
  • All wall sections together
  • All towers together

This way you can keep the tiling on each one and have tiny atlases.

Really nice to hear that baking trees will be supported soon! This would allow for some nice performance boost on mobile as currently unity trees are just very slow on mobile.

Mesh Baker Version 1.6 has just been released. This major update includes:

New features:

  • Support for multiple materials (can map multiple materials on source objects to multiple materials on a combined mesh)
  • Separate atlases are generated for each combined mesh material
  • Can bake tiling materials
  • Can fix models with UVs outside the range 0,1 so their UVs are in-bounds and bake tiling accordingly

Improvements:

  • More tooltips and documentation
  • More messages describing what is going on
  • Better analysis of your scene

The new version of Mesh Baker (compatible with Unity 4) is now available in the asset store. Enjoy!

[quote=“TopThreat”, post:8, topic: 490738]
This looks very beneficial to my project. I will also be purchasing this once you have updated it to support 4.0
[/quote]

Mesh Baker now supports 4.0. I hope it works out well for you!

New Features 2.0:

  • Combine skinned meshes.
  • Customize skinned meshes by combining regular meshes (swords, hats, clothes)
  • Animations remain intact after combining
  • Combined materials can be re-used in different scenes