Search Unity

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:
    1,543
    Thanks for letting me know. Will take a look.
     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Looked into this. The problem is that the example scene is mis-configured. The "Texture Bake Results" has no materials. If click bake on the TextureBaker, this will bake the materials on the source objects. After this has been done the scene will run correctly.

    Will fix this in the next release.
     
  3. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,331
    Thanks, that fixed the problem.
     
  4. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    48
    Hello and gongrats for
    One of the best assets in assetstore
    Im using it for a while now and sholud tell its awsome!
    I only have one question and that is what about baking terrain stuffs?i mean tree,grass,stone or whatever that painted on terrain
    Doese mash baker capable of baking its textures and meshes?
    Any help will appreciated
     
  5. unity_RMiJ7SENDRQxhQ

    unity_RMiJ7SENDRQxhQ

    Joined:
    Oct 5, 2018
    Posts:
    1
  6. bbvrdev

    bbvrdev

    Joined:
    Aug 11, 2009
    Posts:
    221
    Hey Phong, quick question for you. I am trying to apply Texture/Mesh Baker in a prefab in Unity 2019, but as soon as I drag objects into the "Objects to be combined" array the Mesh Baker game asset disappears from the hierarchy. Any idea why this is happening? Does it not work in a prefab?
     
  7. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,331
  8. CD-ECEU

    CD-ECEU

    Joined:
    May 21, 2019
    Posts:
    3
    Is there any reason why a lightmap generated by meshbaker would get cannibalized during runtime? When I hit the play button, our baked lightmap vanishes. Poof! It is clearly visible in the editor, and when I rebake it returns.


     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Sorry for the slow reply. For some reason the email alerts from the forums don't seem to work.

    Re: Baking terrain stuff.

    It is always a good idea to reduce the number of materials as much as possible. The Batch Prefab Baker is great for this. If many terrain props share a material then Unity has a much easier time batching them.

    Regarding Mesh Baking. For vegetation and grass I would recommend letting the Unity Terrain system manage things for you. The terrain LOD system handles this fairly efficiently and uses billboards for distant trees. For mesh props it is also a good idea to use Unity's mesh system if possible too however you can often help it by baking a few clusters of pebbles and such together. Then Unity needs to manage far fewer instances of detail meshes.

    Try to make sure that the details all use "instancing" materials. Unity can be much more efficient if the props use instancing.
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Sorry for the slow response. Sometimes the forum email notifications don't arrive.

    You need to use scene object instances in the list of objects to combine. The reason is that many of the things that effect how things are baked (lightmap indexes, negative scaling on one axis) are only available in the context of a scene.
     
  11. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Try setting the lightmapping UVs settings to "generate new UV2 layout" or "copy UV2 to separate rects". The preserve_current_lightmapping is only reliable in certain versions of Unity. I should remove that option.
     
  12. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    48
    Hi there no problem at all
    And thank you for the tips!
    Wish luck for you and your project
     
  13. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    125
    How do I combine materials without combining meshes?

    Edit - I found "Preparing Models For Static/Dynamic Batching (Batch Prefab Baker) AKA Combining Textures Without Combining Meshes" but it doesn't work. While it swaps the mesh, the material remains the original. If I manually assign the new material that mesh baker created, certain meshes have a bad appearance

    Edit 2 - After manually assigning the new materials, I also had to change the Mesh Renderer number of materials to 1.

    Edit 3 - So I got it working, but there are a lot of unnecessary manual steps, such as dragging the prefab in the scene and duplicating the prefab because "Batch Bake Prefabs" can't take the source and destination the same. There's no reason you can't have a one-click solution "Combine Materials" that finds all materials on the objects, creates a new material that combines them, then replaces all materials with the new material on the same prefab.
     

    Attached Files:

    Last edited: Aug 23, 2019
  14. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    19
    Hi. I am considering buying mesh baker but I am wondering if it's compatible with HDRP or scriptable rendering pipeline in general?
     
  15. Sound_Priest

    Sound_Priest

    Joined:
    Nov 7, 2013
    Posts:
    8
    Hi! MeshBaker bake all geometry with LODs into single mesh or it bake only LOD 0 without other LODs ?
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Yes, Mesh Baker works with Unity Materials and the assigned textures. It does not care what rendering pipeline is being used.
    Thanks for the feedback. Are you using the full version of Mesh Baker?
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    There should be no problem with the HDRP pipeline. Mesh Baker works with Unity Materials and the textures used by those materials. It doesn't care what is happening within the shaders themselves.
     
  18. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    You can set up a baker for each LOD level so that all geometry in several LOD0s will be baked together into a combined LOD0 mesh and all geometry for the LOD1 meshes will be baked together into a combined LOD1 mesh etc...
     
  19. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    140
    I have a question regarding combining skinned mesh renderers at runtime. I have a MeshBaker object in my scene. I can combine the meshes without an issue. This is the code I'm using to do so:

    Code (CSharp):
    1. SkinnedMeshRenderer[] skinnedMeshRenderers = playerHolder.GetComponentsInChildren<SkinnedMeshRenderer>(true);
    2.         GameObject[] objectsToCombine = new GameObject[skinnedMeshRenderers.Length];
    3.  
    4.         for (int i = 0; i < skinnedMeshRenderers.Length; i++)
    5.         {
    6.             objectsToCombine[i] = skinnedMeshRenderers[i].gameObject;
    7.         }
    8.         Debug.Log("smrCount = " + skinnedMeshRenderers.Length);
    9.  
    10.         playerBaker.AddDeleteGameObjects(objectsToCombine, null, true);
    11.         playerBaker.Apply();
    The problem I am running into is when I try to remove meshes. It'll often give me an error, but never seems to actually remove the meshes. In fact, the meshes that I'm attempting to remove stop animating and move to the local origin of the mesh baker object. This is the code I'm using.

    Code (CSharp):
    1. playerBaker.AddDeleteGameObjects(null, skins, true);
    2.         playerBaker.Apply();
    where skins is an array of game objects with skinned mesh renders that I'd like to remove.

    The errors I get are:

    Could not get bounds. Not updating skinned mesh bounds
    UnityEngine.Debug:LogError(Object)
    DigitalOpus.MB.Core.MB3_MeshCombiner:UpdateSkinnedMeshApproximateBoundsFromBoundsStatic(List`1, SkinnedMeshRenderer) (at Assets/MeshBaker/scripts/core/MB3_MeshCombiner.cs:414)

    and

    go paramater was null

    UnityEngine.Debug:LogError(Object)
    DigitalOpus.MB.Core.MB_Utility:GetBounds(GameObject, Bounds&) (at Assets/MeshBaker/scripts/core/MB_Utility.cs:375)
    DigitalOpus.MB.Core.MB3_MeshCombiner:UpdateSkinnedMeshApproximateBoundsFromBoundsStatic(List`1, SkinnedMeshRenderer) (at Assets/MeshBaker/scripts/core/MB3_MeshCombiner.cs:411)

    Any ideas what I could be doing wrong here?
     
  20. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    140
    I was able to resolve this. I'm using a mesh baker on a bunch of skinned meshes in my scene. I instantiate them and add them at the start of the scene. As they are killed in the game, I flag them for removal and add them to a list. I was handling the removal in LateUpdate. Instead, I now copy that flagged list to a new one, clear that initial list, and then remove all of the objects in a coroutine. This does the trick in a not too convoluted manner.
     
    Phong likes this.
  21. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    140
    Hi again. Now that I've managed to resolve the previous issues, I'm running across a new problem. When I remove skinned meshes and apply the changes, I get a whole flood of errors along the lines of:
    Assertion failed on expression: 'IsFinite(distanceForSort)'
    Invalid AABB inAABB
    Invalid AABB in a
    Assertion failed on expression: 'IsFinite(distanceAlongView)'

    I've done some googling and saw the previous mention in this thread but nothing there seems to help with the issue. Any ideas?
     
  22. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    140
    And... never mind on this as well. I managed to fix it. Thanks!
     
  23. nektariosfifes14

    nektariosfifes14

    Joined:
    Jun 25, 2015
    Posts:
    6
    I am trying to combine the textures of 2 different meshes. I use texture baker tool , add the wanted meshes. Yet the atlas produced doesn't seem to have the right texture coordinates , for none of the two meshes. tried everything what should I do?
     
  24. nektariosfifes14

    nektariosfifes14

    Joined:
    Jun 25, 2015
    Posts:
    6
     
  25. nektariosfifes14

    nektariosfifes14

    Joined:
    Jun 25, 2015
    Posts:
    6
    nevermind I used batch prefab baker. but I want to use this tool on runtime . can I script to combine the materials of multiple gameobjets while running the game using prefab baker?
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Regarding the texture coordinates being wrong. Do the meshes use tiling? That is most likely the problem. This video explains the issue and different solutions to fix it.



    Regarding using the batch prefab baker at runtime. This cannot be used at runtime because it is not possible to create project assets at runtime and prefabs are project assets. However you can still create meshes with adjusted UVs without creating a prefab at runtime. These meshes can be used with the combined material.

    • Set the output of the baker to "bake mesh assets in place".
    • Visit the source meshes one renderer/mesh at a time
      • Assign the renderer to the mesh baker so that it is the only object in the list of objects to combine.
      • Position the renderer at pos: 0,0,0 rot: 0,0,0 scale: 1,1,1
      • Assign a new Mesh to the combiner.
      • Assign a new game object to "Combined Mesh Object"
      • Bake
    • Now that you have your duplicated meshes you can replace the source meshes with your baked versions and the source materials with your combined materials.
    You can combine materials at runtime, however there are limitations. The textures must be readable and be in a format that supports fetching pixels. Some compressed texture formats do not allow this.
     
  27. CD-ECEU

    CD-ECEU

    Joined:
    May 21, 2019
    Posts:
    3
    The solution was to use a script to force the lightmap back on during runtime.


    Also, the modes you discussed resulted in failure in my setup. I strongly recommend not removing the option, but fixing it.
     
    Phong likes this.
  28. tjoshi

    tjoshi

    Joined:
    Nov 1, 2016
    Posts:
    6
    Hey Phong, I have a question for you.

    I have a character from MakeHuman and it has 9 Skinned Meshes. I use the Mesh Baker to first combine all the textures (selecting all the skinned meshes and put them into Texture_Baker and it outputs a flawless combined texture atlas for me. For the next step, I want to combine all the meshes into 1 single skinned renderer mesh, so I go to MB3_Mesh_Baker and select (Same as Texture Baker) and output it to "Bake into Scene Object" as well as "Bake into Prefab". I get the log message as "Successfully baked 9 Meshes".

    It also creates a new object in my scene with a child object named "MeshCombiner-mesh-mesh". Now, this is where things get tricky. I can't move the new scene object or the child, it's like moving an empty object. It doesn't move the transform of the new object. I can clearly see the new combined object in the scene but somehow it is stuck with the source object and only moves if I move the source object.

    upload_2019-8-28_11-42-46.png

    As you can see above, if I move the child object or the parent combined object, all it moves is that huge square and not the combined object.

    Now this is what I want to achieve:
    1) I want the combined object to be an independant entity (no link to the source object) and act as a seperate object
    P.S: I have tried baking it to Prefab but it's the same problem.
    2) The combined texture and automatically assigned material is always "Legacy/Diffuse" instead of Standard shader (as all my Skinned Rendered Meshes use Standard Shader so I don't know why it automatically switches to Diffuse)

    I am using Unity 2019.1.5f1.
     

    Attached Files:

    Last edited: Aug 28, 2019
  29. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    1) The bones for your baked skinned mesh will be the same as the bones for your source meshes. If you move the source mesh bones then the combined mesh should deform. You can create a prefab by:

    1. Baking as you did using the bake into prefab option.
    2. Moving the skeletons from the source rigs so they are a child of the "MeshCombiner-mesh-mesh" parent.
    3. Delete any source SkinnedMeshRenderer components that may have been moved.
    4. Make sure the render bounds of the combined skinned mesh renderer is resonable.
    5. Set the animator culling settings to "always animate" if the animator(s) are not above the combined skinned mesh in the hierarchy.
    6. Make a prefab of this.
    2) Are you using Mesh Baker Free? It is limited to diffuse and bump-diffuse. If you are using pro, you can control the output shader type by setting the shader on the combined material before baking.

    Hope this answers your questions. You might be interested in these two videos. They show how to bake skinned meshes into prefabs and mix an match multiple skinned mesh parts.



     
  30. nektariosfifes14

    nektariosfifes14

    Joined:
    Jun 25, 2015
    Posts:
    6
    in ur tutorial ep 8 I cannot clearly understand how to make-mimic the mesh u have created in blender.when I try to extract ur mesh from example scene I get some weirst stuff going on. so I cannot mimic the way u modelled the mesh (blender noob). can u profid some screenshots with the hierarchy in blender? or is it possible please to attach the .blend file to a message thanks.
     
  31. tjoshi

    tjoshi

    Joined:
    Nov 1, 2016
    Posts:
    6
    Hey Phong, I was able to solve the issue with your help. Thanks a ton!!
    And no, I am using Mesh Baker paid version (not the free version).

    I have a few more queries if you don't mind. I have a lot of prefabs that I want to programatically convert to mesh while also combining the materials. I have an array of objects in which each object has children that I want to combine. If I set the size of the array to 1 and add one parent object (with 9 skinned submeshes), it creates the texture atlas and creates a combined mesh on runtime. However, if I add 1 more parent to the array (now the array has 2 parent objects), it would still work for only the first parent object.

    I think I may have to reset something but I am not sure why. I am attaching my code below for you to review. I would be glad if you help me with this as well.

    I have one more question, how do I save the texture atlas as an asset during runtime; and when I say runtime, I will enable [RunInEditMode] as soon as this script works as I don't plan to use this in runtime but only want to automate the process of creating the combined mesh with their combined texture atlas.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Auto_Merge_Sample : MonoBehaviour
    6. {
    7.  
    8.     public GameObject[] objectsToBeMerged;
    9.     MB3_TextureBaker textureBakerObject;
    10.     MB3_MeshBaker meshBakerObject;
    11.     public GameObject FinalCombinedObjects;
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.         textureBakerObject = gameObject.GetComponent<MB3_TextureBaker>();
    17.         meshBakerObject = gameObject.GetComponent<MB3_MeshBaker>();
    18.  
    19.         for (int i = 0; i < objectsToBeMerged.Length; i++)
    20.         {
    21.             StartCoroutine(MeshTextureCombiner(i, objectsToBeMerged[i]));
    22.         }
    23.     }
    24.  
    25.     //Make sure all the textures are set to RGBA32 or else this will not work. Also make sure it has the "Read" flag enabled.
    26.     IEnumerator MeshTextureCombiner(float time, GameObject parent)
    27.     {
    28.  
    29.         yield return new WaitForSeconds(time/10f);
    30.         SkinnedMeshRenderer[] smr = parent.transform.GetComponentsInChildren<SkinnedMeshRenderer>();
    31.         // GameObject[] objsToAdd = new GameObject[smr.Length];
    32.  
    33.         for (int i = 0; i < smr.Length; i++)
    34.         {
    35.             textureBakerObject.objsToMesh.Add(smr[i].gameObject);
    36.             // objsToAdd[i] = smr[i].gameObject;
    37.         }
    38.  
    39.         //These can be assets configured at runtime or you can create them
    40.         // on the fly like this
    41.         textureBakerObject.textureBakeResults = ScriptableObject.CreateInstance<MB2_TextureBakeResults>();
    42.         textureBakerObject.resultMaterial = new Material(Shader.Find("Standard"));
    43.  
    44.         textureBakerObject.CreateAtlases();
    45.  
    46.         //only necessary if your not sure whats
    47.         //in the combined mesh
    48.         meshBakerObject.ClearMesh();
    49.         meshBakerObject.textureBakeResults = textureBakerObject.textureBakeResults;
    50.         //Add the objects to the combined mesh
    51.  
    52.         // meshBakerObject.AddDeleteGameObjects(objsToAdd, null, true);
    53.         meshBakerObject.AddDeleteGameObjects(textureBakerObject.GetObjectsToCombine().ToArray(), null, false);
    54.  
    55.         meshBakerObject.Apply();
    56.  
    57.         // GameObject finalObj = GameObject.Find("CombinedMesh-Advance_Merge_Sample-mesh");
    58.  
    59.         GameObject finalObj = meshBakerObject.resultPrefab;
    60.  
    61.         if (finalObj != null )
    62.         {
    63.             finalObj.transform.SetParent(FinalCombinedObjects.transform);
    64.             parent.transform.Find("CMU compliant skeleton").SetParent(finalObj.transform);
    65.             finalObj.name = parent.name + "_Combined";
    66.         }
    67.         else
    68.         {
    69.             Debug.Log("Cannot find the final combined mesh. Please try again");
    70.         }
    71.     }
    72. }
    73.  
     
  32. enblomquist

    enblomquist

    Joined:
    Jul 25, 2012
    Posts:
    79
    Hey Phong! I was wondering if there was a tutorial or explanation of how the agglomerative grouper works. I THINK I'm using it correctly - but I'm not sure lol.
     
  33. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Hi Tjoshi,

    Regarding your code. I can see two things:

    • The Mesh Baker re-uses the same mesh for the second bake. This will overwrite the results of the first bake. You need to replace the reference to the mesh between bakes so that you are baking into a different, new mesh the second time. You should be able to do this with meshBakerObject.meshCombiner.SetMesh(myNewMesh);
    • It is a bit sketchy that you are creating multiple coroutines (one for each parent) that you are kicking off at the same time and all of these coroutines are sharing the same texture baker and mesh baker. If you add a yield statement to the middle your MeshTextureCombiner coroutine then everything will break because each coroutine will get a chance to do some work, then will pause to let the other coroutines do some work. When the first coroutine tries to resume its work, the TextureBaker and MeshBaker data will be messed up because it will have been reset by the last coroutine.
    You don't need to do the baking in playmode, it is better to do it in edit mode. When Unity enters playmode it creates temporary duplicates all the objects in the scene so that any changes can be undone. It is likely that assets you create during playmode will end up with broken references when the temporary objects are cleaned up when you return to edit mode. Also I don't think you can do things like re-importing a Texture in a different format in runtime.


    • If you run the code in edit mode then you don't need the coroutine, you can just use a regular function.
      There are a few ways to trigger the execution:
      • You can add [ContextMenu("My Custom Operation")] to one of the functions on your monobehaviour.
      • You can create a custom menu operation add: [MenuItem("MyMenu/Do Something")] to a static method.
      • You can create a custom inspector with a button to do what you want.

    Re: Saving the atlas as a texture. This is a multi step process:

    Code (CSharp):
    1. byte[] bytes = myAtlasTex.EncodeToPNG();
    2. string myPathInAssetsFolder = "MyFolder/mySavedTex.png";
    3. System.File.File.WriteAllBytes(Application.dataPath + myPathInAssetsFolder , bytes);
    4.  
    5. // Now that there is a saved PNG in the assets folder we need to get a reference to it.
    6. // These lines probably won't work in playmode because I don't think the asset database will refresh and import new assets while the game is running.
    7. AssetDatabase.Refresh();
    8. Texture2D myNewTextureAssetReference = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/" Textures/" + myPathInAssetsFolder , typeof(Texture2D))
     
  34. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Unfortunately I don't have a tutorial. The main steps are:

    • Click "Click To Build Clusters"
    • Move the mouse around in the main window. You should see some white wire gizmo spheres in the scene representing the clusters appear.
    • Adjust the "Max Distance" slider. As you do this you should see the white spheres change. There should be more or fewer as the number of clusters change.
    • When you are happy with the result, click, "Generate Mesh Bakers"
     
  35. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Hello,

    The blender file is in a .UnityPackage in the example scenes. (It is packaged this way because the Asset Store does not allow Blender files). Assets/MeshBaker/Examples/CharacterCustomization/blenderFile.unitypackage. If you import the Unity Package you should have the blender file.

    Note that I have not tested this file with the latest version of blender. Will try that today.

    [UPDATE] The blender file in the package should work with all recent versions of blender (2.77+)
     
    Last edited: Sep 3, 2019
    nektariosfifes14 likes this.
  36. Balours

    Balours

    Joined:
    Nov 27, 2013
    Posts:
    44
    @Phong

    When merging a mesh with the Generate Lightmap UVs in the importer is it possible to copy the generated UV instead of the one packaged with the mesh?

    Thank you,
     
  37. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Yes, you should use the "Copy UV2 To Separate Rects" option. If you copy the UV2 unchanged you will have UV triangles that overlap in the combined mesh which will produce strange blotches in the lightmap. The "Copy UV2 To Separate Rects" option ensures that there are no overlaps.
     
  38. Balours

    Balours

    Joined:
    Nov 27, 2013
    Posts:
    44
    I just tried that but got an error as soon as I click Bake:

    Code (CSharp):
    1. System.IndexOutOfRangeException: Array index is out of range.
    2.   at DigitalOpus.MB.Core.MB3_MeshCombinerSingle._copyUV2unchangedToSeparateRects () [0x0014a] in MeshBaker\scripts\core\MB3_MeshCombinerSimple.cs:2679
    3.   at DigitalOpus.MB.Core.MB3_MeshCombinerSingle._addToCombined (UnityEngine.GameObject[] goToAdd, System.Int32[] goToDelete, Boolean disableRendererInSource) [0x01a82] in MeshBaker\scripts\core\MB3_MeshCombinerSimple.cs:1062
    4.   at DigitalOpus.MB.Core.MB3_MeshCombinerSingle.AddDeleteGameObjectsByID (UnityEngine.GameObject[] gos, System.Int32[] deleteGOinstanceIDs, Boolean disableRendererInSource) [0x001b3] in MeshBaker\scripts\core\MB3_MeshCombinerSimple.cs:1938
    5.   at DigitalOpus.MB.Core.MB3_MeshCombinerSingle.AddDeleteGameObjects (UnityEngine.GameObject[] gos, UnityEngine.GameObject[] deleteGOs, Boolean disableRendererInSource) [0x0006a] in MeshBaker\scripts\core\MB3_MeshCombinerSimple.cs:1872
    6.   at MB3_MeshBaker.AddDeleteGameObjects (UnityEngine.GameObject[] gos, UnityEngine.GameObject[] deleteGOs, Boolean disableRendererInSource) [0x00025] in MeshBaker\scripts\MB3_MeshBaker.cs:43
    7.   at MB3_MeshBakerEditorFunctions.BakeIntoCombined (.MB3_MeshBakerCommon mom, System.Boolean& createdDummyTextureBakeResults, UnityEditor.SerializedObject& so) [0x001e3] in MeshBaker\Editor\core\MB3_MeshBakerEditorFunctions.cs:94
    8.   at DigitalOpus.MB.MBEditor.MB3_MeshBakerGrouperEditor.OnInspectorGUI () [0x00190] in MeshBaker\Editor\MB3_MeshBakerGrouperEditor.cs:139
    9. UnityEngine.Debug:LogError(Object)
    10. DigitalOpus.MB.MBEditor.MB3_MeshBakerGrouperEditor:OnInspectorGUI() (at Assets/MeshBaker/Editor/MB3_MeshBakerGrouperEditor.cs:144)
    11. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  39. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543

    Just tested it and it worked for me.

    Which version of Mesh Baker are you using.

    Also, was this a clean, mesh baker or were you updating a baker that had some existing meshes already combined? Was "clear buffers after bake" checked? I think it might be possible to get this error if that was unchecked, you baked without lightmapping UVs, then turned on the lightmap UVs option and re-baked.
     
  40. nek1113

    nek1113

    Joined:
    Apr 10, 2019
    Posts:
    8
    in texture baking is legacy diffuse the only shader available? is there any chance for support of unlit shaders?
    ::::Game object Spine030(Clone) (UnityEngine.GameObject) does not use shader Legacy Shaders/Diffuse (UnityEngine.Shader)
     
  41. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Mesh Baker can work with any shader that uses texture properties. Set the shader in the combined material after it gets created. If you do this then Mesh Baker will look for the texture properties in that material.

    Note that if you are using the free version, it is limited to Diffuse and Bump Diffuse shaders.
     
  42. cyuxi

    cyuxi

    Joined:
    Apr 21, 2014
    Posts:
    32
    Hi,
    I am using Unity 2018.4.0 and latest version of Mesh Baker, the "preserve current lightmaping" seems out of work.
    Lightmap can only be fetched on the first time of baking, everything is perfect until reopenning the scene, all combined meshes are unlinked from lightmap.
    I tried several times and the issue is remaining. Is it likely to be a bug?
    Thanks
     
  43. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Yes, this is a bug. I will try to address it in the next version of Mesh Baker.
     
  44. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    39
    Hello!

    I´m having this error when trying to use batch prefab baker:

    Mesh Mech_01_Head (UnityEngine.Mesh) is used by both the source and result prefabs. New meshes will be created.
    UnityEngine.Debug:LogWarning(Object)
    DigitalOpus.MB.MBEditor.MB3_BatchPrefabBakerEditor:BakePrefabs(MB3_BatchPrefabBaker, Boolean) (at Assets/MeshBaker/Editor/MB3_BatchPrefabBakerEditor.cs:315)
    DigitalOpus.MB.MBEditor.MB3_BatchPrefabBakerEditor:OnInspectorGUI() (at Assets/MeshBaker/Editor/MB3_BatchPrefabBakerEditor.cs:150)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


    I have absolutely no idea what I´m doing wrong...

    To give you some more information:

    The objects I´m trying to atlas are parts of a customizable mech, there are 7 different mechs and they combine parts like heads, torsos, arms, legs, etc...

    The objects itself are inside a root empty object, inside this empty object there are two other containers, one with the skeleton and the other with the mesh of the relevant part.

    It´s necessary so I can combine them in the game.

    Using this objects, everything in MB works perfectly, until I try to Batch prefabs then I get this weird message.
     
    Last edited: Sep 14, 2019 at 5:28 PM
  45. nek1113

    nek1113

    Joined:
    Apr 10, 2019
    Posts:
    8
    I followed ur instruction on ep 8 mesh baker. I went on blender and on ur .blend file I add a mesh on the character with a bone just like all the subparts of Player rig. I then import it on unity press bake meshes on mesh baker and get this message:
    Bones do not match bindpose.///what am I doing wrong?

    edit: I also get warning : Mesh 'Head' has 1 (out of 575) vertices with no weight and bone assigned (they will be assigned to bone #0 with weight 1). The list of vertices: 523.
     
    Last edited: Sep 15, 2019 at 12:47 AM
  46. nek1113

    nek1113

    Joined:
    Apr 10, 2019
    Posts:
    8
    ok I figured it out went on avatar and did auto configure
     
    Phong likes this.
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    Is it a warning (Yellow) or error (Red)?

    If it is a warning you can ignore it. The warning is there because the SourcePrefab and ResultPrefab are using the same "Mesh" asset. This is a problem because the BatchPrefabBaker will replace the UVs in the mesh which would also replace the UVs for the source mesh. This message lets you know that the BatchPrefabBaker will create a new mesh asset for the ResultPrefab so that this doesn't happen.
     
  48. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    39
    Hi, Well, yes, it´s a warning, but I´m also having some errors mentioning something about the bones structure...

    And, it´s not modifying the result prefabs UVs, so, It´s not working...

    I naver had any problem with batchprefabbaker before, but also, I never tried it with skinned meshes and I think it´s the problem...

    I´ll upload three of those files and, whenever you find some time, if you tried it to reproduce the error I´d really appreciate that...

    I removed the textures to reduce the file size, you can use anything you see fit

    thanks a lot in advance
     

    Attached Files:

  49. CDCappa

    CDCappa

    Joined:
    Mar 18, 2016
    Posts:
    14
    Hello Phong!

    I have a question to ask you.
    In runtime, I need to create more than one "Combined Mesh Object", since by the logic of my application, I only need to combine parts of an object, for example:

    In this case I have this object:

    Object
    -children 1.
    --children 1.a
    --children 1.b
    -children 2.
    -children 3.
    -children 4.
    --children 4.a
    --children 4.b
    --children 4.c

    And I just need to create a combination of 1.a + 1.b and in parallel 4.a + 4.b + 4.c.

    I'm not sure how to do this, I made some quick attempts but it seems that the plugin always comes to the first "Combined Mesh Object".

    What am I missing?

    Thank you!
     
  50. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,543
    The MeshBaker/MeshCombiner has a reference to the "resultSceneObject" and to a mesh. If you want to re-use the same MeshBaker/MeshCombiner several times baking different "combined mesh object" each time, then you need unset its references to these objects or the second bake will overwrite the result of the first bake.


    Code (CSharp):
    1.         MB3_MeshBaker mb;
    2.         mb.meshCombiner.resultSceneObject = null;
    3.         ((MB3_MeshCombinerSingle)mb.meshCombiner).SetMesh(null);