Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Mesh Baker by Digital Opus [RELEASED]

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

  1. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    246
    I've got some prefabs that have multiple submeshes with each using a different material. I'm trying to bake them into a single mesh with a single material. I've followed the steps under "Preparing Models For Static/Dynamic Batching" but I keep having issues with the UVs not being mapped correctly. The combined material looks good but the combined mesh is not correctly mapped to it. I've tried this with numerous models and they all suffer from the same issue. Here's a pic of one model along with the combined material version. Any ideas why this is failing?

     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    It looks like some of the submeshes use UVs outside the range 0..1 for the tiling. You need to enable "consider UVs" on the TextureBaker. If the submeshes have significantly different materials you may also need to use the "multiple materials feature".

    Here is an old video that talks more about these features. We will be releasing an updated version of this video in the next 2-3 days.

     
  3. LaCorbiere

    LaCorbiere

    Joined:
    Nov 11, 2018
    Posts:
    29
    Hi Phong - thank you for the info. Makes perfect sense. It sorted the keyboard issues.
     
    Last edited: May 7, 2021
    Phong likes this.
  4. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    642
    Hi,

    Getting error: Assertion failed: Adding texture null to atlas _BumpMap for texSet 2 srcMat Egypt_torch

    Assertion failed: Adding texture null to atlas _BumpMap for texSet 2 srcMat Egypt_torch
    UnityEngine.Debug:Assert(Boolean, String)
    DigitalOpus.MB.Core.<CreateAtlases>c__Iterator0:MoveNext() (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombinerPackerMeshBaker.cs:72)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:292)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    MB3_TextureBaker:CreateAtlases(ProgressUpdateDelegate, Boolean, MB2_EditorMethodsInterface) (at Assets/MeshBaker/scripts/MB3_TextureBaker.cs:535)
    DigitalOpus.MB.MBEditor.MB3_TextureBakerEditorInternal:DrawGUI(SerializedObject, MB3_TextureBaker, Object[], Type) (at Assets/MeshBaker/Editor/MB3_TextureBakerEditorInternal.cs:430)
    DigitalOpus.MB.MBEditor.MB3_TextureBakerEditor:OnInspectorGUI() (at Assets/MeshBaker/Editor/MB3_TextureBakerEditor.cs:37)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Unity 2017.2 (porting an old project to a new platform).
    All meshes use Standard shader.
    Some use various texture slots. Problem material uses only 1 -- Albedo.
    I think they may have used more in the past and Standard Shader keeps those old data. You can see this in the 2 attached images (normal and debug view of the material inspector).
    I suspect MB is enumerating properties and attempting operation on the null _BumpMap.

    Any chance for a fix please :)
     

    Attached Files:

  5. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    642
    Update:
    I tried editing the material's YAML to remove the suspect properties but same problem.
    I tried restarting Unity afterwards too. Nope.

    I've attached a (7z'd) log of a fresh attempt.

    Out of interest, I checked the Torch's UV and can confirm none are outside bounds. I guess this message was also caused by trying to process something that isn't set?
     

    Attached Files:

  6. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    642
    UPDATE 2:
    I've kludged in a check before the assertion for now:
    Code (CSharp):
    1. if (texSet.ts[propIdx].isNull)
    2.     continue;
    Atlasing completed but obviously I don't know what terrible repercussions might have been obscured!
    Thx

    EDIT: Could you let me know if this _might_ cause problems -- I'm proceeding with the kludge-produced assets for now so will need to come back and redo if you say yes :-\
     
    Last edited: May 10, 2021
  7. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    246
    Just wanted to thank you for the quick reply. I watched the video and have been working with it and finally have everything fixed. Using the "consider mesh uvs" option fixed about half of the models. I had to use the "Multiple combined materials" option to fix the others as one of the materials used a different shader and wasn't compatible. MB recognized this and created a 2nd material which then fixed the remaining models. Thanks again!
     
    Phong likes this.
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hi Arkade,

    I am having trouble reproducing the problem. I tried creating two Standard shader materials. I gave one of them a bumpMap and left the other blank. Mesh Baker succeeded in generating a bump atlas. It generated a small blank bump texture for the null bumpMap slot. I also tried with both materials (bumpMap blank) and it also worked.

    Mesh Baker should either not create an atlas if there is no bumpMap for all materials or it should create a texture if one is missing.

    Is it possible to create a simple repro scene and send it to me (email or PM)? I will definitely fix the issue.

    I am not sure if your fix will work. By this point in the code, all textures should exist for copying to the atlas. I am not sure what will happen if there is a null texture.

    Another temporary workaround would be to create a small bumpmap texture that is solid neutral normal map purple color and assign it to the bumpMap field of the material. That should get it working without error. I would be very interested in discovering how this is happening for you however.
     
  9. LaCorbiere

    LaCorbiere

    Joined:
    Nov 11, 2018
    Posts:
    29
    Hi Phong. I have a scene with about 4 materials that use different tiling images (base, normal and roughness). Been following tutorials but having mixed results so far. So looking forward to this video. Thanks.
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    We just put up the new video a few minutes ago:



    We will also are planning to create another video which focuses on tiling specifically. It should be ready in 2-3 weeks.
     
    LaCorbiere likes this.
  11. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    642
    Had a go at a reproduction. Alas, pulling the problem bits into a standalone project didn't reproduce.
    I can send it to you anyway but obviously it's a bit pointless.

     
  12. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    That is frustrating. I wonder if there is something strange about how the materials are serialized. If you can reproduce it in your main project and you have a moment could you capture a log for me?
    • Set the TextureBaker.LogLevel = trace
    • Clear the log
    • Bake the textures
    • Send me the log file
     
  13. mattycocoa

    mattycocoa

    Joined:
    Feb 5, 2021
    Posts:
    2
    upload_2021-5-14_20-31-26.png
    Hello, im having an issue. maybe it is something simple i am over looking. the grass and a few plants you can see in he scene should be green. the use the same material as the buildings and flowers you see in the scene. upload_2021-5-14_20-35-5.png
    here is what it looks like before baking. thanks!
    upload_2021-5-14_20-41-1.png
     
  14. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    How big are the blocks of color in your source textures? If they are only a few pixels or one pixel, I would recommend making the source textures bigger so that each block of source color is four or nine pixels. This is likely a precision problem where the source textures are trying to sample an individual pixel and anything that causes the sampling to be off even by a tiny amount can get a wildly different color.

    Other suggestions: if you are baking solid color pallet source textures like this then make the following changes to the atlas after baking:
    • Filter mode = point
    • Generate Mip-maps = off
    Let me know if this fixes the issue.

    Another possibility is color tint. What shader are you using? Do those materials use a color tint?
    If so then "blend non-texture properties" might help.
     
    mattycocoa likes this.
  15. mirzamujeeb64

    mirzamujeeb64

    Joined:
    Apr 20, 2020
    Posts:
    4
    Hi, help me, I imported the map from GTA V. I tried to get MeshBaker to work, but the textures are not of the same quality as the low ones. How high quality? But if I tried it separately and small, the quality was worked. It doesn't work big time, also after tried changed 8192mb they don't work, 16XXXmb are while crash? sorry, i'm not good english
     
    Last edited: Jun 10, 2021
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    It is difficult to know what the problem is without more information.

    How big are the source textures and how many are you trying to combine? If the source textures are 4k and you are trying to combine them into a 4k atlas then this is not possible without loosing resolution.

    You may need to combine fewer textures per atlas and create more than one atlas.

    Are the textures tiled? If so then I would suggest watching our videos on Multiple Materials and Tiling.



     
    mirzamujeeb64 likes this.
  17. mirzamujeeb64

    mirzamujeeb64

    Joined:
    Apr 20, 2020
    Posts:
    4
    thanks it worked, the tutorial you uploaded last time, I looked at the old tutorial uf!! But Thankyou good
     
    Last edited: Jun 14, 2021
  18. yeagob

    yeagob

    Joined:
    Jan 27, 2014
    Posts:
    18
    Hi guys!

    Im looking for a mesh siimplification to eliminate mesh superposition. I have a runtime generated mesh with some penetration between objects. When unify objects i need to eliminate inside vertex. Your asset do that?
     
  19. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    No, Mesh Baker will not eliminate the inside verts. I don't know of an asset that does that.
     
  20. PhilFaily

    PhilFaily

    Joined:
    Jul 31, 2017
    Posts:
    11
    Parent Scene Object reverting serialised reference bug.

    Hi Phong, I seem to have a strange bug with the Parent Scene Object reference under the Output Section.

    Every now and then the value will be reset to a previous object, in fact every single mesh baker in my scene reverts the value to a previously set object reference.

    It's not a major issue because I can go through and reassign them but I've had to do it more than 10 times now and I have 30+ mesh bakers in my scene that I have to manually click through and drag references too.

    Any idea what is going on here. It's very strange because I can save the scene and reload it and it will be fine but every now and then the values get reverted. Almost like the meta data is using an older value.

    EDIT --------------

    I noticed that if I select more than 1 Baker at a time this value gets changed.
     
    Last edited: Jun 28, 2021
  21. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Thanks for pointing this out. When this happens, is this field the only field that you are setting on the mesh baker?

    I suspect I am not flagging the object as being dirty when this field is assigned to. It is a bug and I will fix it. It should work if you set/unset some other value on the inspector so that the Mesh Baker gets marked as dirty and serialized properly.
     
  22. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hi PhilFaily,

    I am having trouble reproducing the issue. Can I ask what version of Unity you are using?
     
  23. chaobaji

    chaobaji

    Joined:
    Oct 14, 2020
    Posts:
    9
    Hello,I'm using MB3_MeshBaker for real time baking, the baker result create new copy of the origin materials.For some reason, I want the baked result use the origin materials, how can I achieve this.
     

    Attached Files:

  24. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    You can use a Mesh Baker without a Texture Baker. If you do this, the Mesh Baker will re-use the original materials on the combined mesh. The combined mesh will have as many distinct materials/submeshes as the source meshes used.
     
  25. chaobaji

    chaobaji

    Joined:
    Oct 14, 2020
    Posts:
    9
    Thanks for reply. I was using mesh baker without texture baker, but the baked result create a new instance of original material, I want to use the same material instance of the origin. I replaced the bakedRender.materials with original materials for now, but I don't think this is a right way
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hmmm, I will look into that. IMO that is a bug. It should not create new instances. I will fix that in a future version.
     
  27. MaNiC

    MaNiC

    Joined:
    Feb 18, 2013
    Posts:
    28
    Is it possibal to bake 500 textures into 10+ 2K textures automatically?
     
  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    This will probably take some fiddling.

    You can use the Mesh Baker Window -> Analyze Scene and Generate Bakers -> Split Groups If Textures Would Exceed Atlas Size and set the max texture size to 2k. This will create the number of atlases needed to hold the textures. The exact number will depend on the size of the textures and how much tiling there is.
     
  29. PhilFaily

    PhilFaily

    Joined:
    Jul 31, 2017
    Posts:
    11
    We're using 2020.3.1f1
     
  30. MaNiC

    MaNiC

    Joined:
    Feb 18, 2013
    Posts:
    28
    Thank you! I have been able to split the textures and I face the tiling problem. Most uvs of my meshes go over 10, I find the vertical or horizontal packer is very useful. Is it possibale to user different packer based on UVs automatically?
    U is bigger than V, then horizontal pack.
    V is bigger than U, then vertical pack.

    Thank you so much.

    Ps. Maybe subdivide geometry is another option.
     
  31. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    There is currently no way to auto select which packer to use. You would need to hack this in, it might be tricky. IMO it would be easier to write your own script to pre-process the meshes and configure the MeshBaker(s).
    • Set up a TextureBaker with all possible meshes
    • Collect all the meshes used
    • Grab the UV channels of these Meshes and sort them into U bigger and V bigger lists
    • Create a MeshBaker child for each list and add the source objects that use those meshes.
    • Configure each Mesh Baker.
     
    MaNiC likes this.
  32. Xitech_

    Xitech_

    Joined:
    Feb 19, 2013
    Posts:
    132
    Hey!

    I am trying to read the pixel value of a mesh baked with MeshBaker. However, it is somehow giving me the wrong UV coordinate. Do you have any idea what I am doing wrong? It is working correctly on a Quad with the same material / texture. The mesh also has only 1 material.

    Does this mean the original mesh's UV's are wrong and needs fixing in 3D modelling software? Or am I using wrong settings to create a single mesh from these objects?

    My code:
    Code (CSharp):
    1. bool IsPixelTransparent(RaycastHit hit)
    2.     {
    3.         Texture2D textureMap;
    4.        
    5.         textureMap = hit.transform.GetComponent<Renderer>().material.mainTexture as Texture2D;
    6.         MeshRenderer renderer = hit.collider.GetComponent<MeshRenderer>();
    7.        
    8.         //Debug.Log(renderer.sharedMaterial);
    9.        
    10.         Vector2 pixelUV = hit.textureCoord;
    11.         pixelUV.x *= textureMap.width;
    12.         pixelUV.y *= textureMap.height;
    13.         Vector2 tiling = renderer.material.mainTextureScale;
    14.        
    15.         Color pixelColor = textureMap.GetPixel(Mathf.FloorToInt(pixelUV.x * tiling.x), Mathf.FloorToInt(pixelUV.y * tiling.y));
    16.         if (pixelColor.a < 0.5f)
    17.         {
    18.             return true;
    19.         }
    20.  
    21.         return false;
    22.     }


    Result (When put into a texture):
    MeshBaker.png

    Thanks!
     
  33. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hello, I think the problem is that there are two different meshes being queried. These meshes have different UV maps.

    1) The combined mesh. This is assigned to the MeshFilter/MeshRenderer. When you access: textureMap = hit.transform.GetComponent<Renderer>().material.mainTexture as Texture2D; This is the baked atlas. It uses UVs from the combined mesh.

    2) The source mesh. This is probably assigned to the MeshCollider. When you access, Vector2 pixelUV = hit.textureCoord; You are querying the mesh assigned to the MeshCollider.

    One fix would be to replace the MeshColliders with one combined-mesh-MeshCollider. This could mess things up though if you have triggers or callback scripts on those colliders.

    Probably a better fix would be to get the disabled source renderer (probably on the MeshCollider gameobject). If you get the mainTex from that source-material. It will align with the UVs of the MeshCollider.
     
  34. Xitech_

    Xitech_

    Joined:
    Feb 19, 2013
    Posts:
    132
    Hey!

    Thanks for your reply. That makes a little more sense to me know! As I have no need for triggers / colliders on these objects I think the first option is the easiest one. However, where can I select the combined-mesh-MeshCollider?

    I have generated the mesh using MB3_TextureBaker and MB_MeshBakerGroup.

    EDIT: Also, the original mesh had 2 materials. So I needed MeshBaker to create a single mesh with a single material. Current setup is this: MeshBakerMesh.png

    Thanks!
     
    Last edited: Jul 16, 2021
  35. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Re: two materials on source mesh. Mesh Baker will collapse the materials by default unless you use the Multiple Materials feature. There should only be one material on the combined mesh.

    Re: combined mesh collider. There is no combined mesh collider. You will have to create it (Add a MeshCollider to a GameObject and assign the baked mesh to this). You may need to use the Bake Into Prefab in order to save the combined mesh as an asset. Otherwise it is tricky to get a reference to the combined mesh.
     
  36. Xitech_

    Xitech_

    Joined:
    Feb 19, 2013
    Posts:
    132
    Hey!

    Thanks again. It seems I am doing something wrong :)

    So I have created a single atlas, so that the combined mesh can use 1 material. So I now have a mesh and material. When I add MeshCollider I use the same generated mesh and unfortunately I have same results. I have also tried to manually add the Texture2D via code to try and hardcore the correct texture. But also this doesn't have expected results. Please see image below:
    MeshBaker_issue.png

    Please also see code below with comments.

    Code (CSharp):
    1.     bool IsPixelTransparent(RaycastHit hit)
    2.     {
    3.         // Mesh filter and collider use the same mesh: TreeMixMeshBaker0-mesh
    4.         Texture2D textureMap = hit.transform.GetComponent<Renderer>().material.mainTexture as Texture2D;
    5.  
    6.         // This logs: tree_mix-mat-_MainTex-atlas-0, which is the generated atlas.
    7.         Debug.Log(textureMap.name);
    8.  
    9.         Vector2 pixelUV = hit.textureCoord; //Also tried to put the generated texture here as public variable to force correct texture. Same results
    10.         pixelUV.x *= textureMap.width;
    11.         pixelUV.y *= textureMap.height;
    12.  
    13.         Color pixelColor = textureMap.GetPixel(Mathf.FloorToInt(pixelUV.x), Mathf.FloorToInt(pixelUV.y));
    14.         if (pixelColor.a < 0.9f)
    15.         {
    16.             return true;
    17.         }
    18.  
    19.         return false;
    20.     }
     
  37. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hmmm, this looks like it should work. As a double check I would log the name of hit.transform, hit.collider, ((MeshCollider) hit.collider).mesh, meshFiler.sharedMesh.name to make sure that the render mesh and collider mesh are indeed the same.

    Also check that the texture has read/write enabled.

    Another thing I can think of is that sometimes the Y coordinate of a texture can be inverted. You might need to use 1 - y instead of y. See:

    SystemInfo.graphicsUVStartsAtTop
    https://docs.unity3d.com/Manual/SL-PlatformDifferences.html
     
  38. Xitech_

    Xitech_

    Joined:
    Feb 19, 2013
    Posts:
    132
    Hey!

    Thanks for all your input. I tested everything and it should work as everything seems fine. Turns out it was working from the start. I basically shoot a ray and as soon as the ray hits something. I don't check if there's something underneath. As the model has big squares overlapping each other, the shadow mask was correct. I tested this with a color map instead of generating shadow:

    I then set the material to transparent so I would be able to see the full mesh:
    MESHBAKERdasd.png

    Thanks again for you quick responses!

    Kind regards
     
    Phong likes this.
  39. peteburges

    peteburges

    Joined:
    Apr 8, 2020
    Posts:
    4
    Hi There

    I am having a couple of problems with mesh baker. On the whole it's working really well, there are just two things I can't seem to do:

    1) Baking skinned meshes to a single skinned mesh always seems to result in a static mesh for me. I've tried turning on offscreen update and always animate on the original skinned mesh renderers, and tried various configurations in the skinned mesh baker, but I can't seem to get an animated mesh result. Yes, skinned mesh is turned on in the baker. What am I missing....?

    2) How do I export assets that I've already baked for use in another scene/project? If I export them for use in another scene (I am working remotely), even if I 'select all dependencies' the meshes go missing during export. Also I can't seem to find where it saves the combined meshes, though if I search 'mesh' in the mesh slot it looks like they are there- but with 500 meshes all named 'mesh' it's difficult to find the right ones. Is Unity storing them internally, and if so how do I extract them for export....? (I really hope you're not going to say 'bake from the originals again' because I cleared them from my scene and there were hundreds...)

    IMPORTANT: I should point out that I am using a proprietary version of Unity 2017.1 and not the latest version, I don't know if that makes a difference.

    BTW this is not to say it isn't a great product. I am blown away by how much time it's saved me and how much faster my scene runs. But ultimately I need to export the optimised results for assembly elsewhere.

    Please help! Thanks,

    Pete
     
  40. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hi Pete,

    Re: exporting baked meshes. You need to use "Output => Bake Into Prefab" on the MeshBaker component. If you do this then the Mesh gets saved as an asset in the project. The mesh can then be referenced by prefabs and exported.

    Re: The skinned mesh issue. You have covered most of the issues. Here are some debugging suggestions:

    0) Check the console for errors after mesh baking the skinned mesh. There should be a success message.
    1) Find the baked skinned mesh game object in your scene. Select it and disable/enable the SkinnedMeshRenderer component. It should disappear/reappear. This verifies that there is indeed a baked skinned mesh in your scene.
    2) Find the one of the source skeletons in your scene. Try moving some of the arm/leg bones. The skinned mesh should deform. If it does not then it may be that the bones of the skinned mesh are not assigned correctly. Not sure what would cause that. Did you do the bake inside prefab-edit-mode?
    3) If the bones do deform when you manually move them then the problem is with the animations not playing.Is the Animator disabled or the game-object that the animator is on disabled? Is there a script controlling the animator that is not working for some reason.

    We have an updated Skinned Mesh Tutorial. You could watch that to see if there is anything different from your workflow.




    Re: Custom version of Unity. It is possible that this could break something although unlikely. It depends on what was changed of course. Let me know if you still have problems after trying these suggestions.
     
  41. peteburges

    peteburges

    Joined:
    Apr 8, 2020
    Posts:
    4
    Hi Phong,

    Thanks so much for your detailed reply! I will try the things you suggest.

    With the skinned mesh I followed the steps in the video, but it's possible I missed something. The source skeletons are imported from Blender along with the animation, so it's also possible I could have prepared these assets better for use in Unity (I am still fairly new to Unity and learning on the fly). Anyway I will work through the steps you've provided.

    Many thanks!

    Pete

     
  42. peteburges

    peteburges

    Joined:
    Apr 8, 2020
    Posts:
    4
    Hi Phong

    One weird thing that I've been getting is that even if I follow the same procedure exactly I won't always get the same result. This morning I have averaged about 5 attempts per asset to produce a useable mesh. For every successful attempt I get roughly 4 failures which either generate the 'failed to add/delete' message, or generate a mesh with 0 triangles and 0 faces. After every unsuccessful attempt I delete all generated assets and begin the process from scratch in case anything problematic is stored, and I am pretty sure I am setting the same parameters each time. Any idea why this might happen...?

    Thanks,

    Pete
     
  43. SebaGioseffi

    SebaGioseffi

    Joined:
    Oct 18, 2013
    Posts:
    6
    Hi! We were trying to see if it is possible to combine two different fbx files, both with the same bone structure and naming convention, but each one with a different mesh renderer with skinning weights. Basically, one is a piece of armor and the other one is the player itself.

    For the moment we can only achieve this with the multi-mesh baker component but the problem is that we must use two separate controllers and this is not optimum.

    Our idea is to have just one separate fbx file per piece of armor or clothing, to allow us to update assets more frequently instead of having everything in one big fbx file.
     

    Attached Files:

  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hi Seba,

    The setup of having two separate (identical) skeletons is a problem. There is no way currently to merge these into one during the baking process. This is a surprisingly tough problem. Even the if the skeletons are identical, the bone transforms can import in different orders. Then the indexes into the bones array which are used in the mesh bone weights are off.

    I have it on my TODO list to add a tool to MeshBaker that will do this but it does not exist at this time.

    You can either write your own script to do the merge, or merge them in your Modeling program onto the same skeleton and export them.
     
    SebaGioseffi likes this.
  45. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    Hi Pete,

    Sorry to hear you are having so many problems. I don't know why this could be happening without more information. Usually if there is an error: 'failed to add/delete' then there are previous errors in the console. Were there any previous error messages? Mesh Baker is fairly good about printing errors. I would recommend clearing the console before each bake. If there is a failure, then all the errors in the console are relevant to that bake.

    If there are no other errors or they are hard to understand, we could either do a screen share or could you send a screen capture video link of your workflow?
     
  46. peteburges

    peteburges

    Joined:
    Apr 8, 2020
    Posts:
    4
    Hi Phong

    Sorry to have bothered you with that one, that was entirely my bad; I was trying to combine meshes that totalled over 65535 vertices. Eventually I realised that I needed to use the multimesh baker for things over that limit. Since then it's been pretty much plain sailing (though I haven't gotten back to the skinned meshes yet).

    Thanks so much for your help and time!

    Pete
     
  47. SebaGioseffi

    SebaGioseffi

    Joined:
    Oct 18, 2013
    Posts:
    6
    Thank you so much for the reply! We merged them via script before baking as you suggested (taking into account some of the caveats mentioned here: https://www.reddit.com/r/Unity3D/comments/98gc8z/how_can_i_assign_two_skinned_mesh_renderers_to/) and it worked great.

    P.S.: Mesh baker is a great asset and it is amazing to see the dedication to keep working on it and provide fantastic support. So congratulations!
     
  48. alerbuffon22

    alerbuffon22

    Joined:
    Apr 7, 2020
    Posts:
    7
    Hi, I want to sinter a mesh with a texture (the atlas is created) while preserving the original UV0 channel, is it possible? I plan to use tiling in the atlas through a shader and the original UV channel should not change its coordinates
     
  49. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,883
    I do not understand what you mean by "sinter".

    The definition I found describes a physical real world process " the process of compacting and forming a solid mass of material by heat or pressure without melting it to the point of liquefaction". I don't understand how this would be applied to a virtual mesh in Unity3D. Can you explain in more detail what you want to do?
     
  50. longshotsg

    longshotsg

    Joined:
    Dec 8, 2014
    Posts:
    11
    Hi Ian,

    Got a couple of questions that need your help. Thanks.
    Using latest Mesh Baker version and 2019.4.28f1

    1) Quoting this from 2017, I have a character that has a mesh with material at 2nd level of the prefab. Looking through the forums, I saw this below. So what I did is to add the gameobject of each character(2 in total) with the SkinnedMeshRenderer into a newly created MeshBaker without Texturebaker. Changed renderer to SkinnedMeshRenderer and press Bake.
    And I got the following messages.
    Successfully baked 2 meshes each material is mapped to its own submesh.
    d3d11: buffer size can not be zero

    So I thought it's my character's mesh and I tried with another character and I got the same error.
    So what did I do wrong? Do I need the texturebakeresult even when I have multiple instances of the same character with the same material?

    Edit: I tried your SkinnedMeshRenderer example and found the same issue. So it could be Unity version or my PC. If I click on Bake on the Mesh Baker there, it will create successfully overwriting the existing combined mesh.
    But if I delete the combined mesh and click Bake, the same error "d3d11: buffer size can not be zero" appears.
    Any recommended version 2019.4 onwards? Thanks.

    Edit: Ok I downgraded to 2019.4.20f and it's ok now for this issue.



    2) So I went to try MeshRenderer instead for the weapon the character is holding. For this as the weapon consists of multiple parts(body, magazine, handle), I bake the rifle at runtime for each character. Baked successfully. But the problem comes when the script trigger the character to shoot at enemies. Weapon still face downwards(starting position) and never changes. I have applied updategameobjects every frame in lateupdate but the mesh never got updated. Mesh was not rotated to face enemy like the original mesh.
    So what did I not do or done wrongly?

    Just a note: I can't join this with the skinnedmesh because skinned mesh is using a material that uses a color tint. That will affect the color of the weapons if I merge them together and use one combined material. So the plan was to merge the weapon parts at runtime after prefab creation and then merge all the weapons of all characters together into one big mesh at runtime.

    Edit: Ok I changed it to a skinnedmeshrenderer meshbaker and it works fine now.

    Appreciate your help. Thanks.
     
    Last edited: Aug 9, 2021
unityunity