Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Mesh Baker by Digital Opus [RELEASED]

Discussion in 'Assets and Asset Store' started by Phong, Nov 20, 2012.

  1. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Is there a file MeshBaker/Scripts/Editor/MB2_TextureCombinerEditorFunctions.cs? The missing class should be in there. Did you upgrade to a new version? Which version is it? Try reimporting the package. The best way to upgrade is to delete the MeshBaker folder from inside Unity and import the newer package.
     
  2. Jason-King

    Jason-King

    Joined:
    Oct 28, 2010
    Posts:
    56
    If some of the face normals of a mesh appears to be inverted after having combined them using Mesh Baker, then you likely have a negative scale for (parts) the original mesh. This isn't a completely uncommon occurrence as it appears to be a practice when duplicating a mesh from one side of a model's body to another (ie. converting a right hand to a left hand).

    @Phong, can this be fixed within MeshBaker?
     
  3. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    I had a look at this a few days ago when I ran into it for the first time. I too originally thought it would be an easy fix. It turns out to be very messy. In a hierarchy of transforms the scaling components become entangled with the rotation components and it becomes impossible to determine if a normal/tangent is being moved based on its rotation or scale. The other problem is that sometimes we want the normals to flip. For example if you want to create a mirror image of an object then you set one of the scale components to -1. I don't think I can write a general solution that can distinguish when we want normals to flip and when we don't.

    It would be very easy to write a script that would flip the normals and tangents before baking. It could be used to prepare the mesh for baking. I will try to write one and post it here.
     
  4. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    @Phong,

    Happy Holidays.

    I've been a very happy MeshBaker user this past year and wanted to thank you for the amazing work you've put into the project. MeshBaker is now an integral part of my toolkit.

    Recently in a project I'm working on I really needed to bake textures during runtime on mobile platforms. As you know, this is quite a time consuming process in MeshBaker. I would really like to continue using MeshBaker in the project because it's so integrated and is doing a wonderful job. While researching for a faster way to bake textures, I found a Free project that Unity has just released. It's called UMA and is now on the asset store. In UMA's documentation.

    "UMA results on PRO and Free licenses are meant to be as similar as possible, however calculating a UMA atlas can be handled differently. For PRO it ´s possible to create the atlas using RenderTextures, so texture calculation is very fast. For Free license, it requires processing each pixel individually, so it takes considerably more time and processing power."

    In UMA, atlases are created on the fly for all platforms including Mobile. It seems that the problem of Atlas Creation during run-time can be solved using Unity Pro Render Textures. I know that you have targeted MeshBaker to be Unity Free, however, there are many users of MeshBaker that are probably Pro users. Would it be possible for you to add support Render Textures for pro users. This way, those that have Pro can make the most of the Power and Flexibility that both UnityPro and MeshBaker provides. Enabling MeshBaker to realistically bake atlases at runtime will enable us to use MeshBaker in many more creative ways. At the moment, the lack of this functionality really limits the potential of MeshBaker.

    Cheers.
     
  5. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    You've gotta check out UMA.

    It's really an incredibly innovative system. They really are masters of Mesh and Textures in many ways.

    Question:
    Will MeshBaker and MeshBaker LOD work with UMA character system?
     
  6. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Thanks for the information Rocki, I will definitely look into this. I can't promise anything but if it looks reasonable I will try to add this.
     
  7. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Fantastic,

    Please keep us updated with your findings.. Whether it's possible to add some features or not. This way we can plan appropriately.

    Cheers.
     
  8. Bill-C3

    Bill-C3

    Joined:
    Feb 7, 2013
    Posts:
    5
    I have about a dozen "source" character prefabs that at runtime are cloned and instantiated (e.g. "man1" is a skinned mesh prefab and the game instantiates 10 copies of "man1" each doing something different). Each character has 1 material and 2k-4k triangles. I'm pretty clear that I can combine the materials for each of these characters into one material. What I'm fuzzy on is combining the skinned mesh for each character into one shared skinned mesh.

    1. Basic question first -- if I combined my dozen "source" character meshes into one skinned mesh, would it work in the described scenario (e.g. creating multiple copies of a character that's in the shared skinned mesh)?

    2. What's the performance/efficiency implications?
    e.g. would each copy of a character instantiated cause Unity to instantiate a new instance of the entire shared skinned mesh, so if I had six of the same characters Unity would load six copies of the shared skinned mesh in memory? Or would it simply reuse or batch from the one single shared skinned mesh?

    If the answer is yes to 1 but it's not a good idea because of 2, can you suggest a strategy for dealing with the skinned mesh side of the equation (the shared material seems an obvious good idea)? Thanks!

    Cheers,
    Bill
     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Yes this will work with some limitations. It will NOT work if you are using Mecanim Avatars because the combined mesh will have many more bones than the mecanim animation clips are expecting. You will need to use the legacy animation system. You will also not be able to use the optimized skinned meshes because the bones are hidden internally and they can't be accessed to be combined.
    You would have your original skinned mesh which is shared so there would be 1 copy of it. The renderers on these would be disabled so there should be no overhead from the SkinnedMeshRenderers. These can be deleted after combined.

    You would also have a single combined mesh which would be equivalent to all the skinned meshes combined together (approx 20k to 30k vertices). There would be no performance benefit on the skinning performance because the same number of verts are being skinned, but on the rendering side you have one drawcall instead of 10.

    Note that once combined, animation and fustrum culling on individual skinned meshes in the combined mesh cannot take place so you may loose the performance benefit of non-visible skinned meshes being culled.
    You may want to take a look at Mesh Baker LOD. It can do amazing things with mobs of skinned meshes. You can have different levels of LOD for the meshes and you can limit how many meshes are allowed in each level. For example you could have a crowd of 100 meshes and limit them so the closest 5 are in the highest level of detail (3k), the next 10 are in a lower level of detail (1k fewer bones) and the rest are a very simple lollypop character with no bones (200 verts). The scene still looks good because the high detail meshes closest to the camera obscure the characters in the background. Check out this video, the skinned mesh part is 6:30 seconds in.
     
    Last edited: Dec 31, 2013
  10. elanguido

    elanguido

    Joined:
    Nov 24, 2012
    Posts:
    4
    it can't be exported for windows phone 8
     
  11. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Thanks for making me aware of this Elanguido, I will try to fix the Widows 8 phone export.
     
  12. kolchaud

    kolchaud

    Joined:
    Apr 25, 2012
    Posts:
    28
    Hi,

    I must confess I didn't read all thread pages and I got a question.

    I need to export Mesh, Material and Maps ligth Probes to a Prefab. I watched the video, and it's ok for the two first points, but what about the third ? Does it keep light probes into prefab ?
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Mesh Baker will not add a light probe group during the baking process, but you should be able to add it to the prefab after it has been baked.
     
  14. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Hi Phong

    I am trying to use Mesh Baker now in my real project. After one try with the old error I remembered that you had to do some change to make it work, so I downloaded the newest version, 2.11.4

    I then set up everything again, and could bake the texture just fine. But everytime I try to bake the skinnedMesh, I get this error:

    System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
    at System.Array.CopyTo (System.Array array, Int32 index) [0x0004a] in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Array.cs:1829
    at DigitalOpus.MB.Core.MB2_MeshCombiner._copyBonesBindPosesAndBoneWeightsFromMesh (UnityEngine.GameObject go, DigitalOpus.MB.Core.MB_DynamicGameObject dgo, Int32 vertsIdx, Int32 bonesIdx) [0x0000f] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\core\MB2_MeshCombiner.cs:882
    at DigitalOpus.MB.Core.MB2_MeshCombiner._addToCombined (UnityEngine.GameObject[] goToAdd, System.Int32[] goToDelete, Boolean disableRendererInSource) [0x01275] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\core\MB2_MeshCombiner.cs:791
    at DigitalOpus.MB.Core.MB2_MeshCombiner.AddDeleteGameObjectsByID (UnityEngine.GameObject[] gos, System.Int32[] deleteGOinstanceIDs, Boolean disableRendererInSource, Boolean fixOutOfBoundUVs) [0x00100] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\core\MB2_MeshCombiner.cs:1482
    at DigitalOpus.MB.Core.MB2_MultiMeshCombiner._bakeStep1 (UnityEngine.GameObject[] gos, System.Int32[] deleteGOinstanceIDs, Boolean disableRendererInSource, Boolean fixOutOfBoundUVs) [0x000b6] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\core\MB2_MultiMeshCombiner.cs:462
    at DigitalOpus.MB.Core.MB2_MultiMeshCombiner.AddDeleteGameObjectsByID (UnityEngine.GameObject[] gos, System.Int32[] deleteGOinstanceIDs, Boolean disableRendererInSource, Boolean fixOutOfBoundUVs) [0x000b8] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\core\MB2_MultiMeshCombiner.cs:345
    at DigitalOpus.MB.Core.MB2_MultiMeshCombiner.AddDeleteGameObjects (UnityEngine.GameObject[] gos, UnityEngine.GameObject[] deleteGOs, Boolean disableRendererInSource, Boolean fixOutOfBoundUVs) [0x0005d] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\core\MB2_MultiMeshCombiner.cs:334
    at MB2_MultiMeshBaker.AddDeleteGameObjects (UnityEngine.GameObject[] gos, UnityEngine.GameObject[] deleteGOs, Boolean disableRendererInSource, Boolean fixOutOfBoundUVs) [0x00032] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\MB2_MultiMeshBaker.cs:63
    at MB2_MeshBakerEditorFunctions._bakeIntoCombined (.MB2_MeshBakerCommon mom, MB_OutputOptions prefabOrSceneObject) [0x000da] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\Editor\MB2_MeshBakerEditorFunctions.cs:42
    at DigitalOpus.MB.Core.MB2_MeshBakerEditorInternal.bake (.MB2_MeshBakerCommon mom) [0x0000b] in D:\local\Unity\Level1\Assets\MeshBaker\scripts\Editor\MB2_MeshBakerEditorInternal.cs:176
    UnityEngine.Debug:LogError(Object)
    DigitalOpus.MB.Core.MB2_MeshBakerEditorInternal:bake(MB2_MeshBakerCommon) (at Assets/MeshBaker/scripts/Editor/MB2_MeshBakerEditorInternal.cs:198)
    DigitalOpus.MB.Core.MB2_MeshBakerEditorInternal:DrawGUI(MB2_MeshBakerCommon, Type) (at Assets/MeshBaker/scripts/Editor/MB2_MeshBakerEditorInternal.cs:147)
    DigitalOpus.MB.Core.MB2_MeshBakerEditorInternal:OnInspectorGUI(MB2_MeshBakerCommon, Type) (at Assets/MeshBaker/scripts/Editor/MB2_MeshBakerEditorInternal.cs:66)
    MB2_MultiMeshBakerEditor:OnInspectorGUI() (at Assets/MeshBaker/scripts/Editor/MB2_MultiMeshBakerEditor.cs:44)
    UnityEditor.DockArea:OnGUI()


    Do you know by any chance what could lead to this error? In my trial scene 2 months ago that error was not a problem. But then I used an older version of Mesh Baker with some changed files from you.
    What should I do?


    Thanks in advance for any help


    Gian-Reto
     
  15. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Hi Gian-Reto,

    Are these meshes "optimized"? Mesh Baker cannot combine "optimized" skinned meshes because the bones are not available.
     
  16. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    It is the same mesh I tested it on a month ago. The base meshes are not skinned at all. They are set to "optimized" though. Setting them to not "optimized" has no effect, still the same error.
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Turned out to be a problem with the scripts. I have fixed it and submitted an update to the Asset store.
     
  18. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Can I get the fix? I need this like right now if possible please :)
     
  19. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    I PMed you with a download link. Let me know if you have any further problems.
     
  20. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Hey, thanks for that but I'm still getting the same error.

    System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
    at System.Array.CopyTo (System.Array array, Int32 index) [0x0004a] in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Array.cs:1829
    at DigitalOpus.MB.Core.MB2_MeshCombiner._copyBonesBindPosesAndBoneWeightsFromMesh (UnityEngine.GameObject go, DigitalOpus.MB.Core.MB_DynamicGameObject dgo, Int32 vertsIdx, Int32 bonesIdx) [0x00025] in E:\Work\Ninjutsu Games\InfestedLand\Assets\MeshBaker\scripts\core\MB2_MeshCombiner.cs:883
     
  21. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    The update is available in the asset store now.
     
  22. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Thank you its working now!
     
  23. HaroldBalls

    HaroldBalls

    Joined:
    Oct 30, 2012
    Posts:
    20
    Is there any way to automate the skeletal mesh combining feature? The characters in my game can vary a lot based on the players actions, so it would be really tough to manually combine them.

    It would be totally awesome to be able to combine the meshes at run-time.. how would you do this?
     
  24. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    I may not be understanding the question correctly. I understand that you have some characters in your scene and they are regularly customized (have meshes added and deleted) based on events in the game.

    I would suggest baking a big atlas in the editor with all possible textures in it.

    Then at runtime you can add to the combined mesh a reasonably simple script (not quite automated):


    GameObject[] objsToAdd = new GameObject[1] {hatInstance.GetComponentInChildren<MeshRenderer>().gameObject};
    skinnedMeshBaker.AddDeleteGameObjects(objsToAdd,null);
    skinnedMeshBaker.Apply();

    See the MB_SkinnedMeshSceneController.cs as an example.

    Does this answer your question?
     
  25. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    I've tried to do this with skinnedMesh before so I have the meshBaker object with the "custom list" empty ofc with the texture atlas already made then execute that code on start and all I got is this "ArgumentException: An element with the same key already exists in the dictionary."

    The only that seems to work for me is defining the custom list and also having the original models on the scene.

    I would like to be able to bake my characters without having to add their skinned meshes to the meshbaker object and have them on the scene.
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Interesting, I had not tested updating a mesh when the source objects have been deleted. I think I have fixed the problem. I had to make these two changes in MB2_MeshCombiner:

    Change line 312 to:

    Code (csharp):
    1.  
    2. instance2Combined_MapAdd(mbDynamicObjectsInCombinedMesh[i].instanceID, mbDynamicObjectsInCombinedMesh[i]);
    I also had to change the method used to Update the skinned mesh bounds line 1491:

    Code (csharp):
    1.  
    2. UpdateSkinnedMeshApproximateBoundsFromBones();
    3.  
    I will make sure these fixes make it into the next version.
     
  27. kokkorollo

    kokkorollo

    Joined:
    Jan 16, 2013
    Posts:
    9
    Hi,
    I'm having trouble with materialBaker.
    I'm trying to combine multiple material applied to a single mesh into a single material.
    Now the mesh has 12 different materials, and i want to create a single material with all the texture applied.

    I think that the problem is related to the 0,1 uv space texture.

    When I press the Bake materials button, after a while of computing i see this:

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Texture One (UnityEngine.Texture2D)has out of bounds UVs that effectively tile by (1.0, 0.9) tiling will be baked into a texture with maxSize:1024
    Texture Two (UnityEngine.Texture2D)has out of bounds UVs that effectively tile by (1.0, 0.9) tiling will be baked into a texture with maxSize:1024
    Texture Three (UnityEngine.Texture2D)has out of bounds UVs that effectively tile by (1.0, 0.9) tiling will be baked into a texture with maxSize:1024
    Texture Four (UnityEngine.Texture2D)has out of bounds UVs that effectively tile by (1.0, 0.9) tiling will be baked into a texture with maxSize:1024
    If the current selected build target is not standalone then the generated atlases may be capped at size 1024. If build target is Standalone then atlases of 4096 can be built

    Estimated texture minimum size:3005.49330393531
    After pack textures size 4096 4096

    Created atlas for: _MainTex at /Users/Myname/ProjectName/Assets/MB-mat-_MainTex-atlas0.png

    UnityEngine.MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it.

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    and the combined material has no texture applied.

    there is a way to solve this problem?
    in report in debug log i see also this with different texture names 7 times:

    Will be resized to:1024x1024 [_MainTex One 1024x1024]
    Materials using:One_D_Mod,

    please help me, because i'm going crazy with this.
    thanks in advice.
     
    Last edited: Jan 26, 2014
  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    The missing reference exception is a nasty problem that showed up in Unity 4.1. The problem is that Unity garbage collects the textures while they are still being referenced. There is a post in the FAQ with some advice on this. Try running with as much free memory as possible and try different texture packers. If none of these work, try PMing me the full log to see if there could be a bug somewhere. BTW which version and platform are you running on?


    The error started in Unity 4.1 and is intermittent. It occurs far less often in Mesh Baker version 2.5.3 and later.

    This error started happening with Unity 4.1.f0 and 4.1.2. It appears to be a bug in Unity. Temporary textures are being destroyed before the script is finished using them. It appears to only happen when a Garbage Collection is triggered. A bug report has been submitted to Unity and Unity is able to reproduce the problem.

    A new Texture Packer was added to Mesh Baker 2.8.2 if you have this version try setting the Texture Packer to “Mesh Baker Texture Packer”.

    Try reducing the size or number of textures being combined.

    To avoid the creation of temporary textures try to make sure all texture slots are filled on the source materials and that they are already resized to the final size they will be in the atlas. Turn off “resize power of two”.

    As a work around it is possible to export models and materials to Unity 4.0. Bake the combined materials and the material bake result asset. Then export the combined materials and material bake result asset back to 4.1.

    Mesh Baker should be able to handle what you are describing. I test it combining 16 x 4096 tiled textures.
     
    Last edited: Jan 26, 2014
  29. Jack2g

    Jack2g

    Joined:
    Aug 6, 2012
    Posts:
    19
    I am using the latest Unity but it does not seem to see that my UV'ing is out of 1,0 range. Any thoughts? The models just look like a mess
     
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    The latest version of Mesh Baker analyses the meshes being combined and prints a recommended treatment in the console. I would check that first. Regarding the out of bounds UVs: often when a UV is at 0.0 or 1.0 it is really at -0.000001 or 1.00001. These trigger the out of bounds UV warnings.

    Most of the time when meshes don't combine correctly it is due to multiple materials (submeshes) combined with tiling. These are tricky. Some of the submeshes need to map to their own submesh. Some can use baked tiling, some can be combined with other submeshes. There is a tutorial video about combining Michael O's tropical nature pack that explains what is going on. Check the log for the recommended treatment.

    Let me know if this helps.
     
  31. Jack2g

    Jack2g

    Joined:
    Aug 6, 2012
    Posts:
    19
    Hi there.

    The issue was the baker. It was set to the Unity texture baker, once I swapped it over to the Meshbaker baker it worked.

    Cheers.
     
  32. 3dhippie

    3dhippie

    Joined:
    Nov 25, 2013
    Posts:
    2
    Hi

    Meshbaker seems really awesome, so I bought it today. Looks like it is doing a fantastic job.

    But I do have a feature request. I have a couple of mirrored objects in my scene (z-scale set to -1). If I try to bake the mesh those objects have flipped normals. Can you add an option to preserve normal directions on flipped meshes? Any other workaround would be greatly apreciated as well.

    kind regards
    David
     
  33. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Thanks for the suggestion. This is something I have looked at. It is actually fairly tricky to detect and implement. The reason is that the local2world transform contains rotations and scales of all the transforms in the hierarchy mixed together. It is impossible to tell from this if a negative scale was used, so I would have to look at the localScale of the objects hierarchy all the way up to the root. The flipping would need to apply to some of the source objects but not others.

    I would say the easiest way to flip these would be to to edit the resulting mesh using a script (or you could use my other asset MeshMaster). Something like the following applied to the CombinedMesh object (not tested). If you need to save the mesh as an asset you will need to do some more work:

    Code (csharp):
    1. MeshFilter mf = GetComponent<MeshFilter>();
    2. Mesh m = mf.sharedMesh;
    3. Vector3[] ns = m.normals;
    4. for (int i = 0; i < ns.Length; i++){
    5.       ns[i] = -ns[i];
    6. }
    7. m.normals = ns;
    BTW: Negative scaling on you models can cause problems with other parts of unity as well such as collision detection, physics, shaders, batching. It is considered a bad practice.
     
    Last edited: Feb 5, 2014
  34. HaroldBalls

    HaroldBalls

    Joined:
    Oct 30, 2012
    Posts:
    20
    Hello, i just noticed that mesh baker will not work on GameObjects that use the “Optimize Game Object” enabled...

    I really rely on the speed difference gained from the "Optimize Game Object” option....Is there a fix for this somewhere in the pipeline? If not...what is more beneficial? Combining skins or Optimize Game Objects?

    Thanks

    Ben
     
  35. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Unfortunately there is nothing that can be done about this until Unity provides some way of accessing the bones in the Mesh through the API. The Mesh API hides this which is why I can't support it.

    It might be possible to somehow export it with bones and animations as an fbx, then re-import it into Unity so that you have a chance to optimize it. Unfortunately I don't know of a tool that can do the export.

    Regarding which is faster, saving the extra drawcall(s) is probably a bigger savings than using optimized skinned meshes (do some profiling to be sure). It would depend on how many bones you have and if they are arranged in a deep hierarchy compared with how expensive the extra drawcall(s) are (which shader, how many lights, which pipeline etc...). The savings for the "optimize skinned mesh" feature comes from more efficient calculation of the Transforms on the bones, so a skinned mesh with fewer bones would see less benefit.
     
  36. Nims

    Nims

    Joined:
    Nov 11, 2013
    Posts:
    86
    Hi,

    I am just starting to experiment with Mesh Baker, and so far no love.
    I was trying to do the very simple following thing:
    I have a skinned fbx model with a single animation on it, the model is made of a few materials.
    This model comes with a few LOD prefabs each containing this single animation.

    So the first thing I was trying to do is create an atlas for this single skinned model. So i went to highest poly LOD (which is significantly lower compared to original fbx) and created a single atlas for all the included materials (All materials were of diffuse shader type for simplicity).
    Following the online tutorials i managed to get material, asset and the texture atlas made and then tried to bake my MeshBaker to a prefab.
    As expected i also got the new combined mesh object in the hierarchy (As a transform with a mesh child object).
    The Bone hierarchy wasn't duplicated into this game object. And no animation component was present on the newly created game object. The material was set to the new atlas material.
    I got the following notification in the console:
    "Render type is skinned mesh renderer. Can't create prefab until all bones have been added to the combined mesh object GameObject (UnityEngine.GameObject) Add the bones then drag the combined mesh object to the prefab."

    I am totaly unclear on what I am supposed to do at this point:
    1. Do i need to keep the original LOD prefab in the scene?
    2. Do i need to duplicate the bone hierarchy from my original LOD prefab to the newly created combined mesh?
    - I tried doing this and adding an animation component, setting the root bone to the correct bone.
    - Also tried playing around with Culling type - to always animate (both on the new combined mesh object after i added an animation component to it and on the original LOD prefab).

    After hours of trying to get this to work, i am asking for a detailed overview on how to preserve the animation on a model with many materials.
    What am i expecting to get in the combined mesh when baking a skinned model with a bone hierarchy?

    Clarifications would be greatly appreciated. And maybe a video of a skinned model with many materials and animations converted to a model with 1 single material atlas and the animations intact?
     
    Last edited: Feb 15, 2014
  37. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Hi Nims,

    Skinned Meshes are tricky to work with. There is a procedure in the FAQ that describes how to prefab a skinned mesh:

    Prefabing a combined skinned mesh is tricky. The mesh needs to be an asset, not an instance and the bones/animations need to be included in the prefab.

    Delete the combined mesh object
    Set the renderer to “Skinned Mesh”
    Set the output to “BakeIntoPrefab”
    Create a prefab and add an empty game object then drag that to the result prefab field. Make sure this is an asset not a scene object. You can delete the game object out of your scene.
    Click “bake” There should be two messages, one reporting that the mesh was saved. The other is a warning that “Render type is skinned mesh renderer. Can’t create prefab until all bones have been added to the combined mesh object ObjectName Add the bones then drag the combined mesh object to the prefab.
    “. You need to do a bit more manual work to include the bones.
    Working with the combined mesh, test that animations work. You may need to adjust the animation culling setting.
    Drag all you source objects (bones) so they are children of the combined mesh scene object.
    Test that animations still work.
    Disable or delete the Renderers and MeshFilters on the bones.
    If everything works then drag the result to your prefab asset.

    =============

    When you bake a combined mesh with mesh baker. It creates a new mesh in your scene with a SkinnedMeshRenderer component. It does NOT copy the bones and animations. The new mesh re-uses these. Your combined skinned mesh should work in the scene at this point. You may have to fiddle with the render bounds and animation culling settings depending on your situation.

    In order to create a prefab of the new mesh two things need to happen:

    1) The created mesh needs to be saved as an asset. This happens when you use the "bake into prefab" feature.

    2) The bones and animation component need to be moved to the prefab hierarchy. You need to do this yourself. since this can get messy. The source skinned meshes are often attached to one of the bones.

    You do not need to include the source skinned mesh renderer component in your new prefab.
     
    Last edited: Feb 16, 2014
  38. Tanshaydar

    Tanshaydar

    Joined:
    Apr 20, 2011
    Posts:
    33
    Sorry if this is already asked, but when I baked a mesh, I can't use it in another scene. Prefabbing doesn't work, nor can I directly copy and paste from scene. It just says "Missing Mesh"
    I can see the mesh in inspector screen but I can't find its location whatsoever.
     
  39. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Prefabing does work, but you need to provide it with a prefab. (Create a new prefab in the project and drag it to the prefab field).
     
  40. kodmistrz

    kodmistrz

    Joined:
    Jun 11, 2013
    Posts:
    12
    $mesh_baker.jpg

    I have poor quality after use Mesh Baker. It seems to be worse resolution of textures and bad shader using... Please help me :(
     
  41. RodolfoLasparri1

    RodolfoLasparri1

    Joined:
    Feb 24, 2013
    Posts:
    14
    Hello!

    thanks for an amazing tool :)

    I'm having an issue when using Multi Mesh Baker and checking "generate new UV2 layout", when hitting Bake I get this error:

    "No GenerateUV2Delegate method was supplied. UV2 cannot be generated."

    It seems to be ok if I use the default Mesh Baker on a smaller selection of objects, is this a bug or am I doing something wrong?

    thanks!
     
  42. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    Hi,

    I've been using Mesh Baker 2 for a while and it works great. However suddenly now when I click on Open Tools For Adding Objects the window doesn't appear. Any ideas why this is happening? I re-imported Mesh Baker 2 again and it still doesn't work. I can add objects manually in the inspector window.

    Never mind I just went back to the default layout in Unity and the window shows up now.
     
    Last edited: Feb 27, 2014
  43. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Sorry for the long delay before responding. I was travelling for a few days.

    It is tough to tell without more information. I would read the console messages when doing the texture bake. It should tell you if the textures are are being re-sampled at a lower resolution. There are also probably warnings/messages explaining why. Usually if there is a dramatic drop in quality it is due to baked tiling.

    The safest thing is to bake like-with-like. For example if all the rocks use the same material then bake these together. Try adding one new object at a time to the bake. You may need to experiment to see what can be baked together with good results and what can't.
     
  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    It is a bug with an easy fix:

    In line 85 of file MB2_MultiMeshBaker.cs

    Change from

    Code (csharp):
    1. meshCombiner.Apply();
    to

    Code (csharp):
    1. meshCombiner.Apply(uv2GenerationMethod);
    I will submit an update to the asset store.
     
    Last edited: Feb 28, 2014
  45. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    Glad to hear you found a solution. I have found that resetting the layout fixes this problem.
     
  46. jathoo

    jathoo

    Joined:
    Feb 11, 2013
    Posts:
    29
    still it won't support mecanim ? any updates or ways to make it support?
     
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    It does support mecanim, but it does not support "optimized" skinned meshes. I won't be able to add support for this until improves their API so that it is possible to access bones in optimized Skinned Mesh Renderers.
     
  48. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Hello Phong,

    did you find out if this works with Amplify Texture?
     
  49. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,068
    I have not had a chance to test Mesh Baker with Amplify Texture and am quite busy at the moment unfortunately. Here is a list of use cases that should work:

    • Using Mesh Baker to combine objects at build time, then using amplify on these combined meshes and generated atlases. You can prefab the combined meshes and use them in other scenes so this is just like using any other Unity model and material.
    • Combining meshes that use the same materials at runtime.

    Here is what almost certainly will not work:

    • Baking textures and atlases together at runtime. After reading how Amplify works I very much doubt this would work.
    • Complex tiling scenarios.

    I don't have time to look into this further at this time, but Mesh Baker has a free evaluation version download so you could test it out.
     
    Last edited: Mar 5, 2014
  50. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Keep getting this stupid bloody error. Only responses to this in the thread link to things I don't understand. Would be nice if it just worked.