Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

Mesh Baker by Digital Opus [RELEASED]

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

  1. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    464
    I just watched the video. Curious, would it be possible to choose to have a particular texture or textures just tile within the atlas by taking up the upper rows? This would solve the issue for some cases where the textures only tile from left to right. I hit this limitation a lot as I use a lot of trim sheet textures.
     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    That is what the "Mesh Baker Texture Packer Horizontal" and "Mesh Baker Texture Packer Vertical" do. They are experimental features. They might work for you.
     
  3. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    464
    Duh...I've been using Meshbaker for a couple of years and never noticed that option...thanks!
     
  4. Fernando-Pain

    Fernando-Pain

    Joined:
    Jun 20, 2016
    Posts:
    6
    Tried with Unity 2018.4.1 and 2019.3.2 and tried with gamma and linear Color spaces. Standard shader, build target PC Mac and Linux Standalone.

    Attached a package with a couple of cubes with materials. Many thanks!

    https://drive.google.com/file/d/1x8mH3hGkFk532tengLK2Kjg6p5Hlpdv4/view?usp=sharing
     
  5. Fernando-Pain

    Fernando-Pain

    Joined:
    Jun 20, 2016
    Posts:
    6

    Tested with the cubes I shared and it works, but I think it is because they are two cubes with one material each. But what I'm trying to do is merge several different materials from a single mesh. Please find below the unity package with the character. When trying bake the texture atlas of the body the normal maps appear corrupted.

    This are the Texture baker settings I use:

    upload_2020-7-8_10-41-13.png


    https://drive.google.com/file/d/1L8zAfBX79X4APtDs1uvPSg4VnP4D1A1J/view?usp=sharing
     

    Attached Files:

  6. okrongly

    okrongly

    Joined:
    Dec 23, 2019
    Posts:
    49
    That's exactly what I needed to know! thank you :)
     
  7. Fernando-Pain

    Fernando-Pain

    Joined:
    Jun 20, 2016
    Posts:
    6

    Hi everyone, I found the solution to the problem quoted above. If you are importing iClone or Character Creator characters into Unity using the Reallusion Auto Setup plugin, it is good practice to move the character's folder out of the "CC_Assets" folder. Then you can use Mesh Baker on that character without issues.

    Another solution is to deactivate the plug in via Tools/Character Creator & iClone Auto Setup/Autoprocessing/off

    Cheers
     
    Phong likes this.
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Interesting, I presume they are using some custom Import Pipeline scripts? I hadn't thought of that. Good sleuthing.
     
  9. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    103
    When baking into a prefab, is there a way to reset the transform offset to zero? For example, when I add my new prefab to a scene the transform says position 0,0,0 but the actual object is offset from that position by whatever the source object was offset by it.

    In other words, I have several objects I bake that are near position(100, 100, 100). After baking into a prefab and adding a new one to the scene, the prefab position is at (0,0,0) but the object is on top of the source one (100, 100, 100). I'd like my prefab transform position to be the center of the baked mesh, so when I add a new instance of the prefab to the scene it will be at (0,0,0) accordingly. Hope that makes sense.

    Is this possible?
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    In the Mesh Baking settings there is a setting:

    Pivot Location Type which can be set to Bounds Center. That should do what you want.
     
  11. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    103
    Thanks!
     
  12. WuchiOnline

    WuchiOnline

    Joined:
    Apr 5, 2018
    Posts:
    6
    Hi, I've just purchased Mesh Baker after a friend recommended it. It seems like it's an awesome asset, but I can't get it to work properly :(

    I've watched the first four tutorials, and have followed them to a tee.

    I have a level environment I'd like to make a mesh bake of. It's comprised of roughly 135 renderable objects.

    I used the Mesh Asset Tools to separate them by shader type. This ended up being a split between 3 shaders: 2 of which only had 1 object, and the last shader constituted the rest of the 133 objects in the environment objects.

    When I went to bake the last cluster (133 object one), it yelled at me to use Multi Mesh baker. I used that component instead, and it ended up a mesh that looked roughly 60% complete. Many objects were missing.

    What is the best way to troubleshoot incomplete bakes? The errors did not provide much assistance.

    Update: I was able to resolve my issues by making sure I grouped my game objects into ones that were similar in shader/look. Once I broke it up into clusters, everything started working well. Great tool!
     
    Last edited: Jul 25, 2020
    Phong likes this.
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Glad you were able to resolve your problem. Let me know if you have any other issues.
     
  14. ankoro199

    ankoro199

    Joined:
    Jun 25, 2018
    Posts:
    3
    Hi, I tried to bake all meshes and Skinned meshes in my model. But meshes with blend shapes disappeared after bake, and I got an error messages like below

    " SkinnedMesh 0 (BLW_DEF (UnityEngine.GameObject)) in the list of objects to combine has no bones. Check that 'optimize game object' is not checked in the 'Rig' tab of the asset importer. Mesh Baker cannot combine optimized skinned meshes because the bones are not available."

    I checked the 'Rig' tab but 'optimized game object' was not checked.
    Also, uhchecking 'Optimize Mesh' option from 'Model' tag didn't work.

    Could you give me any advise?
     
  15. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    I can't think of any reason why this wouldn't work. Would you be able to send me (email or PM) one of the skinned mesh prefabs that is not working?
     
  16. ankoro199

    ankoro199

    Joined:
    Jun 25, 2018
    Posts:
    3
    Thank you so much for your reply.
    I started conversation with you and attached the prefab.
     
    Phong likes this.
  17. Imillionaire

    Imillionaire

    Joined:
    Dec 14, 2012
    Posts:
    60
    hey guys! love this asset but im having trouble getting it to work. when i use it to optimize my levels, it does great at limiting the batches, and setpass calls, but it absolutely balloons my build size, almost doubling it. is there anything i can do to help limit this?
     
  18. colpolstudios

    colpolstudios

    Joined:
    Nov 2, 2011
    Posts:
    150
    Hello, I am trying to replace the cowboy in the third-person cover shooter.
    however, I can't work out an element.
    Currently, my replacement character has only one gun. By default, we start unarmed. However, the gun shows in the unarmed state.
    If I deactivate the meshbaker version and re-enable the original I do not have this issue.

    on a side note: I added the update skin mesh bounds script, I am getting a long delay when I try to shoot.
    after a few seconds, it eventually kicks in and starts to work.

    Edit:

    all the weapons that you can use in third person cover shooter have scripts attached.
    I believe the mesh rendering component is switched on or off.

    But if I choose to disable mesh rendering on the source objects, this highlights my issue.

    Each possible weapon is a part of the source. Is there any work around?
     
    Last edited: Aug 23, 2020
  19. zhoujiazhiwork

    zhoujiazhiwork

    Joined:
    May 23, 2020
    Posts:
    2
    I have a prefab that contains 4 MeshRenders and 2 SkinMeshRenders, how can I bake them into 1 SkinMeshRender and play animations
     
  20. colpolstudios

    colpolstudios

    Joined:
    Nov 2, 2011
    Posts:
    150
    this should help:
     
  21. jamesparksart

    jamesparksart

    Joined:
    Dec 1, 2017
    Posts:
    31
    I know this had probably been asked before and it is probably pretty easy.. but just started working with this today. I used a mesh baker to bake some drawers together into a prefab. Success! Then, swapped out the models for the wheels put a new empty prefab object for it to bake into. Hit bake. Success! or.. I thought it was.. but it swapped out my both prefabs "The wheels" and "The drawers" with the wheels.. :| SO.. started over this time I made a separate meshbaker instead of using the same one and swapping out the models I want to combine. Same result.. just swaps out both prefabs with one. So, how do I go about combining a group models. Then combining another group of models. And another, and another, and so on in the same scene. Thank you!
     
  22. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    90
    Hi.
    Start using the Mesh Baker to unify skinned meshes with blend shapes into a single skinned mesh in runtime.
    With a very simple script, I combining can be done but I am struggling to find out the way how to get the gameobject which has the combined skinned mesh.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class RuntimeMeshBakerTest : MonoBehaviour
    6. {
    7.     [SerializeField]
    8.     MB3_MeshBaker meshBaker;
    9.     public GameObject objWithCombinedSKM;
    10.  
    11.     public List<GameObject> objs = new List<GameObject>();
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.         meshBaker.AddDeleteGameObjects(objs.ToArray(), null, true);
    17.         meshBaker.Apply();
    18.         //objWithCombinedSKM = ???;
    19.     }
    20. }
    21.  
    MeshBaker's output is set to "Bake into Scene Object" and I set nothing for both "Combined Mesh Object " and "Mesh", When I hit play, an object "Combined-MeshBaker-Mesh" is created and it has a child with combined skinned mesh.
    How do I access the spawned the game object after the combination process is done?
     
  23. ankoro199

    ankoro199

    Joined:
    Jun 25, 2018
    Posts:
    3
    Thank you so much for your support. It is working fine now!
     
  24. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    536
    In my game, i have game objects that activate/deactivate based on player's level.
    Is it possible to turn on/off one particular gameobject if all gameobjects in the scene already baked into one gameobject ?
     
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Mesh Baker can be used at runtime. It is possible update a combined mesh to add or remove other meshes. You can also use the super quick "show/hide" which only updates the triangles (leaving all vertices in the mesh). There is an example: SceneDynamicAddingDelete which has a script which adds and deletes meshes.
     
    rerwandi likes this.
  26. rerwandi

    rerwandi

    Joined:
    Dec 8, 2014
    Posts:
    536
    Thanks, i will look into it
     
  27. jamesparksart

    jamesparksart

    Joined:
    Dec 1, 2017
    Posts:
    31
    @Phong - See my comment above. Still awaiting an answer. Thank you.
    :)

    p.s. - Using 2019.4.0f1 if that helps
     
  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Apologies for not noticing your earlier post.

    The problem is the "mesh" field. You are switching the prefab, but leaving the mesh from the previous prefab assigned in the MeshBaker.Mesh field. For prefabs the mesh will be an asset in the project folder, so when you bake the second prefab, it overwrites the mesh being used by the first prefab.

    The solution is to set the "Mesh" field to null/none in the mesh baker when you assign a new prefab to be baked. Then mesh baker will generate and save a new fresh mesh asset, leaving the previous prefab unaffected.
     
  29. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    90
    @Phong And could you give me any support to my issue, sir?
     
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Hi Lmillionaire, the problem is that when all the objects are separate meshes, Unity only needs to include one instance of each mesh in the build. Each mesh-instance can be rendered many times in the scene. When the meshes are combined, then a copy of each meshes vertices is baked into the combined mesh each time it gets rendered. Unity's static batching has the same problem, it also creates large meshes when the project is built.

    There are really only two things that can be done to reduce this issue:
    • If there are clusters of meshes grouped together, (like a pile of rocks and stumps and a log). You can bake these into a prefab and re-use it many times.
    • You could do your combining at runtime. In your build you leave everything separate, then at runtime you bake things together. The batch prefab baker can help with this. You can use prefabs that already share a material. These are really easy to combine at runtime. Unfortunately this approach doesn't work well if your objects are lightmapped.
     
  31. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Hi colpolstudios,

    There are a few things you could do to deal with the multiple different guns & no-gun issue:
    • The easiest solution would be to leave the gun(s) out of the bake and let them be rendered as separate objects. This is not a terrible idea, especially if the gun has a lot of verticies. The source-gun renderers are probably MeshRenderers. By leaving them out, they don't need to be skinned which saves some overhead (although they do have an extra drawcall). If the guns have a lot of vertices it would be a good idea to leave them out.
    • If you want to combine them, I would do my baking at runtime and re-bake the skinned mesh each time the weapon is changed. See the example scene "SkinnedMeshRenderer" to see an example where you can add and delete from a skinned mesh at runtime. (Make sure you disable 'clear buffers after bake')
    Regarding the bounds, If there is only one cowboy in the combined skinned mesh, I would re-use the bounds from the source skinned mesh + a bit of extra space for the weapon. I would only recommend using the dynamic bounds script if parts of the combined skinned mesh can become separated by unpredictable distances (for example can the gun be dropped).

    It is strange that there is a long delay when you shoot. Is it a lag spike or a delay of some kind? I cant think of a reason why the bounds script or combined mesh would causing this issue.
    • Have you checked the profiler to see if there is a big lag spike caused by some scripts? If there is a lag spike, the profiler should show what is causing it.
    • Have you tried adding some Debug.Log messages. (This should tell you if there is some kind of intentional delay in the scripts)?
      • Add a Debug.Log message to the script where the fire button is pressed. Be sure to print the Time.frameCount
      • Add a Debug.Log message to the script where the bullet is spawned. Also print the Time.frameCount
    • Are there a bunch of log messages being printed when the fire/bullet spawn happens? Note that console messages are fairly expensive in Unity. If you print several messages during a single frame, this can cause a noticeable lag on that frame.
     
  32. colpolstudios

    colpolstudios

    Joined:
    Nov 2, 2011
    Posts:
    150
    Thank you so much for your detailed reply.

    The lag issue was due to me putting the script in the wrong place.

    Here is a short video showing the character before and after using meshbaker:

    It is worth noting that the charatcer is an abobe fuse model.

    The slight difference between the two characters is that meshbaker recenters the action point!

     
  33. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Hi colpolstudios, by action point, do you mean the "bone" transform that the gun is parented to? The skeleton should have a "hand" bone or "lower-arm" bone. The source gun mesh renderer should be a child of that. When the gun is baked into the skinned mesh, the gun-mesh-renderer-transform in the skeleton should become a bone for the gun verticies in the baked skinned mesh. Is the "action point" the "gun-mesh-renderer-transform"? Has that transform been shifted, or has an offset been baked into the gun verticies as they were baked into the skinned mesh?
     
  34. baconbap

    baconbap

    Joined:
    Sep 13, 2013
    Posts:
    3
    Is there a way to atlas textures but not bake meshes together ? or is there a plan to support it in the future?
     
  35. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    There is the "Batch Bake Prefabs" feature.
    • First you create the atlases for a set of prefab-prop-models
    • Then mesh baker creates a duplicate of each prefab with adjusted UVs that uses the atlas material
    You can use these shared-atlas prefabs in your scene instead of the original prefabs. They work great with Static/Dynamic Batching and are very easy to combine once set up.



    Is this what you are looking for?
     
  36. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    98
    Is it possible to take a prefab that has 3 sub-meshes/materials and atlas 2 of the materials, resulting in a new mesh/prefab that has 2 materials? Looking at the manual I think the multiple combined materials option does what I want.

    I got it working, but it could be a little more user friendly for a first time user:
     
    Last edited: Sep 16, 2020
    Phong likes this.
  37. tushtush91

    tushtush91

    Joined:
    Sep 17, 2019
    Posts:
    14
    Hi, So I have a character (skinned mesh) which uses multiple textures and i want to combine them but when animating the character i want to be able to put cloth component on the clothes part to animate them. My question is, after baking the character will i be able to put cloth component on the clothes parts or will they be combined into 1 mesh?
     
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    To use the combined textures the meshes would need to be combined into a single mesh. It might be possible to use the "cloth constraints" to constrain the skin to not-move and the cloth to-move. I have not tried to use the cloth component much so I don't know how difficult this would be.
     
  39. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    44
    Hi, I used lit materials of HDRP, And ThenGroupBy is Standard Rendering Mode,So tested result is renderingMode = NotApplicable,Transparency and opacity cannot be filtered,What is the reason? Thank you.

    Mesh Baker 3.30.3
    Unity 2019.3.8f1(HDRP)
     
  40. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    This is an oversight on my part. When I added support for the HDRP shader I forgot to update the group-by features detect if the materials are using the "transparent" or "opaque" versions. I will add this to the next version. The same is probably true for the URP shader. Thanks for pointing this out.
     
  41. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    44
    OK, thank you. I hope the new version will fix this problem. When will the next version be released?
     
  42. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Hope the next version will be mid-October.
     
  43. GameHourStudio

    GameHourStudio

    Joined:
    Apr 17, 2020
    Posts:
    105
    Hi, today I gave it another try and I noted the combined objects and combined material is affected by the light. (I am using baked lighting) But the look of the object is changed a lot. I am attaching the images showing comparison between the original and combined roads along with the Mesh Baker object settings for your review. Please check what could be the issue. Though I am using unity 2019.4.5f1 but I also got the same results in unity 2018.4.10f as well. I use same material properties for objects before and after combining but still both are not same. Also I tried your typical rainbow cubes to combine. I just combined single cube using texture array with no other cube and after combining again the cube turned dull. So I think this is something to have with texture array standard shader. Can you please sort this issue so that I can use this awsome feature to combine my tiled roads etc without increasing texture atlases size.

    Regards,
     

    Attached Files:

  44. GameHourStudio

    GameHourStudio

    Joined:
    Apr 17, 2020
    Posts:
    105
    More images explaining problem.
     

    Attached Files:

  45. mlaibow

    mlaibow

    Joined:
    Feb 5, 2014
    Posts:
    40
    Is it possible to specify different material baker properties for different submesh materials in a multi-material texture bake?

    For example, different materials could be packed with a different max size, tiling size, and especially if Blend Non-texture properties is checked. If that is checked, it generates new textures for all of the materials, but i may only need that on one of the sub materials that uses multiple copies of the same texture with different properties.

    Also the horizontal and vertical packers, it would be nice to be able to have a combined material set with some of the atlases horizontal and others vertical.

    Thanks,
    -mat
     
  46. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    At this time no, only "consider mesh UVs" is configurable per material mapping. I do like your idea though. I will add it to the wishlist.
     
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    Regarding the "this object has overlapping UVs" problem. What MeshBaker Lightmapping settings are you using? If you want to lightmap the combined mesh after baking, you should use "LightmappingUVs" = "generate new UV2 layout" or "copy UV2 to separate rects"

    Regarding the shader issue. I presume you are using the example StandardTextureArray shader from github? I think that is based on the 2018.4 Standard shader so it is possible that it doesn't work properly in 2019, although you mention that you get the same result using 2018.4. It should work correctly in 2018.4. What color space are you using (linear or gamma)? If it is possible to put together a simple repro project (perhaps an empty scene with those two cubes) it would make it easier for me to debug this.

    [Update] BTW are you using version 3.31.0 (check release notes)? There were some changes in release 3.30.1 with fixes for linear vs gamma color space. That may fix the issue if you are using an older version of Mesh Baker.
     
    Last edited: Sep 28, 2020
    GameHourStudio likes this.
  48. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    84
    Hello, I would like to say a few wishes about future updates.

    Jobs and BURST functionality is incredibly fast and has excellent math libraries. Will they be used for baking?

    An ideal solution would be a runtime bake manager for meshes and textures with simple AddObject () and RemoveObject () functions; which runs asynchronously and on different cores.
    Of course, I understand that this is difficult, but it's worth it. Especially on mobile devices with their weak GPU and multi-core processors.

    Also not sure about LOD. Will it be faster to re-bake when the level of detail has changed. But without HLOD in Unity, baking LODs can be useful too.


    I hope you will be interested in this development path. Thank you, best regards.
     
  49. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,871
    DOTS/ECS is a high priority for me. This will be a feature we will be adding (hopefully in the next half year). I agree that this is very much worth it.
     
    dreamer2017helloworld and Hobodi like this.
  50. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    121
    Hello i have a simple question
    I know the proccess of baking everything but what if a object for example a tree has 2 shaders one for leaves which SHOULD be alpha and one for trunk
    How to bake the same trees into one with 2 shaders
    Is it possible at all?
     
unityunity