Search Unity

Mesh Baker by Digital Opus [RELEASED]

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

  1. laurencew

    laurencew

    Joined:
    Jul 24, 2012
    Posts:
    7
    Hi,
    I'm interested in purchasing. I was wondering if the realtime skinned mesh combine had been tested with Morph 3D characters by chance? I'll ask on their forum too.

    Additionally, does the runtime skinned mesh & atlases creator allow for spreading the operation over a number of frames using co-routines? Is there a nice place to do this that you can think of?
    Thanks
     
  2. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    226
    In the newest version, I've get empty uv2s when baking with "copy uv2 unchanged" and "copy uv2 on seperate rects".

    Also, isn't there an easy way to check how many verticies will be split when I generate a new uv2 layout. It's really annoying to let the multimeshbaker generate or half an hour just to find out that one of the meshes is over 65k. Maybe cancelling the process when this happens is a good idea.
     
  3. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    The mesh baking is very quick so I have not put it in a coroutine. If you are baking multiple meshes you could put it in a coroutine yourself easily. The Texture Baking is a coroutine so yes the texture bake can be spread across several frames.
     
  4. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    I have not seen the empty UV2s problem. I did fix another problem with the "copy uv2 on seperate rects" that would generate NAN if there were source meshes that had no UV2s. I will be submitting a new version with that fix today. What version of Unity are you using?

    Regarding how many vertices will be split. Unfortunately there is no way to tell in advance. The API does not even mention that this can happen at all. I am surprised to hear that Multimeshbaker is taking half an hour? Texture combining can be slow, but Mesh Baking should be fast.
     
  5. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    Hey, didn't see this mentioned anywhere explicitly, but does this tool allow you to combine materials without textures that only use the main color for color information?
     
  6. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    That will only work if the all source materials use the same color or the colors are coming from the meshes. This is because the combined material will use the same shader which will only have a single color, no texture, applied to everything.

    You could modify the shader so that it uses a texture instead of a color. Then you could combine the materials and everything would retain its original colors. Your meshes would also need a UV channel for this to work.
     
  7. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    260
    Hi all!

    config:
    Unity 5.4.3xf0; Meshbaker (newest version); Shader: Mobile Vertex light/ Mobile Vertex unlit (supports direction light); android 5.0+

    So, I am building out a MOBILE FPS VR game (Gear VR), and of course, optimization is the name of the game for Mobile VR. The game is a FPS dungeon crawler and I have to keep the total draw calls under 100. I have ONE 1x1 dungeon wall tile that I am currently using to build out the 3d dungeons.

    In it's base unity form, The raw geometry/level design gets like 22 draw calls. and I was hoping mesh baker could help take that down to say 5 or so, so that I could use the extra draw calls for my monsters or some more complex geometry ... and as well as I wanted to build out some texture aliases to see if that could shave a few draw calls as well..

    I purchased the mesh baker asset a few days ago and went through a couple of tutorials and combined the environment/level meshs (that one wall tile) in my level. However, I ran into a few problems.

    1. Draw calls went up from 22 to 31 after I baked the mesh. (there are aprox 125 of the titles I used to make a small test level) not sure what went wrong there.

    2. When I baked the meshs, I lost my Light mapping. I have to run ZERO realtime lights, so all lighting is also baked. I did a light bake of the level BEFORE I ran the mesh baker and it looked great. After baking with mesh baker it just seemed to go back to the standard texture with no lighting effects. I then tried to bake the light map on the Meshbaker object/geometry after I had run the mesh baking and that did not seem to work. I have to use the mobile shaders and preferably the mobile/vertex lite one as its the fastess Unity shader. What is the correct procedure for baking a level mesh and keeping the lightmapping?


    I know I am doing something silly, but I am fairly new to Unity and only a couple of days in with mesh baker. Can anyone point me in a direction or to a tutorial that may go over this in a bit more detail. I'm sure it's something simple I am overlooking, based o the reviews I read of this product.

    Thanks in advance all.
     
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    I think the two issues are likely related. If the combined meshes are not lightmapped then they will be lit using either lightprobes or dynamic lighting which could cause the drawcalls to rise.

    You will need to bake lightmaps using the combined mesh(es). To do this:
    1) make sure you bake the mesh with either 'generate new UV2 layout' or 'copy UV2 to separate rects'
    2) set the 'static lightmap' flag on the combine meshes.
    3) Adjust the scale in lightmap.
    4) ensure source objects are disabled.
    5) bake lightmaps.

    I would suggest only combining meshes that are very close together. Clusters of barrels and crates. Making the clusters too big can be counter productive since the GPU is given a lot of geometry to render that may extend outside the view fustrum. Also if you have multiple lightmaps you can use "LightmapParameters.SystemTag" to ensure that objects that use the same material also share a lightmap.

     
  9. Mon0waR

    Mon0waR

    Joined:
    Aug 16, 2017
    Posts:
    7
    Hi,
    I'm getting this error when trying to bake Assets in Place
    > Could not find a tiled rectangle in the atlas capable of containing the uv and material tiling on mesh
    Material is super simple, just _Color + Lightmap
    Interesting, that only several meshes affected, others (similar) are ok.
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    If you are using the 'Consider UVs' feature, then Mesh Baker copies exactly the rectangle used by the source meshes into the atlas. If you try to try to bake a mesh that uses UVs that are not enclosed by the UVs of the mesh used in the texture bake then you get this message. You need to include all the potential meshes in the original Texture Bake
     
  11. Mon0waR

    Mon0waR

    Joined:
    Aug 16, 2017
    Posts:
    7
    I understand, but material does not use texture at all, it is simple Color.
    So there is no atlas for this material.
     
  12. Spaniel

    Spaniel

    Joined:
    Dec 23, 2012
    Posts:
    52
    Hello. I have been using your fantastic plugin at work and want to see if I can use it for personal projects before purchasing it. I have a mesh from an old game and for each mesh, there are multiple materials applied to one mesh.

    In the editor it looks like this:

    https://i.imgur.com/OhlVlqu.png

    The combining all of these materials into an atlas works great but the problem happens when I try to get the mesh to use the new material.

    I use these settings: https://i.imgur.com/KQivL6m.png

    When I view the newly created model, I see this: https://i.imgur.com/kWmhRWq.png

    Not sure what I did wrong. I realize that this is an edge case. Most models use UV maps and not many different textures (materials in Unity) but this is an old game. Curious as to what I can do.

    Thank you :)
     
  13. TomCmore

    TomCmore

    Joined:
    Dec 2, 2016
    Posts:
    1
    Hi,
    Unity 5.5.0f3 and 2017.1.0f3 halt on errors
    Assets/MeshBaker/scripts/Editor/core/MB3_TextureCombinerEditorFunctions.cs(10,35): error CS0433: The imported type `DigitalOpus.MB.Core.MB2_EditorMethodsInterface' is defined multiple times
    Assets/MeshBaker/scripts/Editor/MB3_BatchPrefabBakerEditor.cs(385,32): error CS0433: The imported type `MB2_TextureBakeResults' is defined multiple times
    Assets/MeshBaker/scripts/Editor/core/MB3_BakeInPlace.cs(12,40): error CS0433: The imported type `DigitalOpus.MB.Core.MB3_MeshCombinerSingle' is defined multiple times
    Assets/MeshBaker/scripts/Editor/core/MB3_BakeInPlace.cs(12,116): error CS0433: The imported type `DigitalOpus.MB.Core.ProgressUpdateDelegate' is defined multiple times
    Assets/MeshBaker/scripts/Editor/core/MB3_TextureCombinerEditorFunctions.cs(312,63): error CS0433: The imported type `DigitalOpus.MB.Core.ShaderTextureProperty' is defined multiple times
    Assets/MeshBaker/scripts/Editor/core/MB3_TextureCombinerEditorFunctions.cs(392,32): error CS0433: The imported type `DigitalOpus.MB.Core.MB_ObjsToCombineTypes' is defined multiple times


    Additionally in 2017.1.0f3
    Assertion failed: Assertion failed on expression: 'GetPathNameExtension(path) == "unity"'
    UnityEditorInternal.InternalEditorUtility:projectWindowDrag(HierarchyProperty, Boolean)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    Assertion failed: Assertion failed on expression: 'GetPathNameExtension(path) == "unity"'
    UnityEditorInternal.InternalEditorUtility:projectWindowDrag(HierarchyProperty, Boolean)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    Assertion failed: Assertion failed on expression: 'GetPathNameExtension(path) == "unity"'
    UnityEditorInternal.InternalEditorUtility:projectWindowDrag(HierarchyProperty, Boolean)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


    Would you have any recommendations how to deal with this?
    Thanks,
    Tom
     
  14. solidearthvr

    solidearthvr

    Joined:
    Jan 23, 2017
    Posts:
    50
    Tom,

    It looks like you have MB2_EditorMethodsInterface defined more than once. In my installation it's defined in "MeshBaker/scripts/core/MB2_Core.cs".

    If you're using Visual Studio, right click on MB2_EditorMethodsInterface and then "Find all References".
     
  15. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    By any chance did you install the free version of Mesh Baker then upgrade to the full version? If so you probably have both. I would recommend deleting the Mesh Baker folder and re-importing.
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    This is an unusual situation. Is there any chance you could send me a simple example that produces the problem? I am wondering if there is an edge case if combining meshes with no textures.
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Hello, this is a fairly common situation. I think you have tiling using UVs outside the range 0..1. This video explains the situation and various solutions.
     
  18. Mon0waR

    Mon0waR

    Joined:
    Aug 16, 2017
    Posts:
    7
    I've got another issue with Bake In Place.
    For example, I have 10 object to combine.
    I generated combined material, select bake in place for MeshBaker component and click Bake.
    So it starts baking meshes into assets in the folder I choose, and I have 10 new assets.
    But in the scene, I have only one new mesh renderer - actually the last from the list of objects.
    This is because there is an iterator over all objects in BakeMeshesInPlace(), but only the last outMesh returned.
    Is it possible to fix it?
     
  19. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Yes, that is how it works. I am not sure what you would want the desired behavior to be?

    Have you considered using the Batch Prefab Baker? It may be more efficient for you.
     
  20. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Hi folks, I am fighting pneumonia at the moment so support may be slow for the next week or two.
     
  21. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    Take care of yourself! Best wishes! :)
     
  22. zukinet

    zukinet

    Joined:
    Oct 30, 2016
    Posts:
    51
    Hi, I am new to Unity & Mesh Baker...and currently create my first game...

    I would like to know about draw call, i see in newest unity editor (v2017.1), there's no drawcall parameter anymore...



    so, what's current variable relative to draw call. i see "SetPass calls" but what're the different ?

    ===Update

    i try to bake 24 Objects using simple Mesh Baker (baked into scene & mesh render), but it seems no changes in "SetPass Calls" :



    any idea ?
     
    Last edited: Sep 2, 2017
  23. Hagen

    Hagen

    Joined:
    Aug 16, 2014
    Posts:
    36
    Hi, after baking and having a new combined mesh its all good, but, where is the combined model?
    Can it be saved to a file? After successfully combining, now I need to reduce triangles for further optimization, but I can't get access to the new model.
     
  24. Mon0waR

    Mon0waR

    Joined:
    Aug 16, 2017
    Posts:
    7
    Assume you have a scene with really lot of MeshRenders and very complicated hierarchy. Basically it is not possible to work with it manually. Poor design and so on.
    And I need to bake texture atlases (this is so cool in MB!), and then remap UV's for existing meshes.
    MB can do it using "in place" baking. But after bake, we have a directory with hundreds of .asset files.
    And I have to put them into the scene either manually or via the script, and assign a proper material - this is the main problem, because we can have dozen of baked materials, and .asset file does not retain material mapping.
    So the idea is to add all of this remapped meshes during bake. Right now you add only one - the last object from bake list. Thus, I'd like to have the same functionality what this plugin does.
    As for the batch prefab baker, it appeared to be very unclear how to use it :(
     
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    As of Unity 5+ they are now called Batches and Setpass calls. Setpass calls are the most expensive and the most important for performance it means that the GPU state needs to be updated before a new Batch of meshes can be rendered. Batches is less important because multiple batches can be pushed through the GPU back to back as long as the GPU state doesn't need to change.

    I would suggest using the Frame Debugger. You should be able to see what every Batch is doing. It will even give a reason if a different setpass call is needed.
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Using the "Bake into Prefab" feature. The mesh will be saved as an asset in the project.
     
  27. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Both the "bake-assets-in-place" and "Batch Prefab Baker" are designed for working with prefabs. The idea is to create duplicates of the prefabs and use that in the scene instead. I don't have a good workflow at this time to automatically replace the meshes and materials for a scene full of objects if those objects are not prefab instances. I have tried to make Mesh Baker non-destructive and that operation would be very dangerous.
     
  28. zukinet

    zukinet

    Joined:
    Oct 30, 2016
    Posts:
    51
    Hi, but why after bake i stil got same "SetPassCall" ?

    and also, what kind of frame debugger ? is it a unity plugin ?

    thanks...
     
  29. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
  30. Mon0waR

    Mon0waR

    Joined:
    Aug 16, 2017
    Posts:
    7
    Understand, but you can perfectly bake meshes into scene objects (combined meshes) regardless if they are prefabs or not. Why not bake the same way in place? It should be also non-destructive, IMHO.
     
  31. zukinet

    zukinet

    Joined:
    Oct 30, 2016
    Posts:
    51

    Hi, thanks for the clue...

    i've tried Frame Debugger and Baked 90 Objects, but why I dont get 1 draw call for Object that has been baked ?

    in below screen shot you can see each baked objects still cost a draw call :



    it still cost 6 draw calls...

    any idea ?
     
    Last edited: Sep 7, 2017
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Some things that cause extra drawcalls are: shadows, lights (each dynamic light causes a drawcall per mesh). Also check your global GI settings. If you have both realtime and baked GI turned on then you can expect a lot of drawcalls. Also check your rendering path. A good recipe for performance efficient scenes is:
    • Forward rendering
    • One directional light
    • Set everything to static that doesn't move
    • Use Baked GI for lighting all static geometry
    • Optional realtime shadows only on the main character
    • As few materials as possible
    BTW in Unity 5.6 and up you should be able to select a drawcall in the Frame Debugger and Unity will give you a reason why the drawcall was not batched with the previous drawcall. Very useful.
     
  33. roberto_sc

    roberto_sc

    Joined:
    Dec 13, 2010
    Posts:
    144
    Hi, I'm wondering if I bake objects spread in the scene, will they be included in occlusion even if they are outside of the frustum because they are now one single game object with one mesh?
     
  34. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Yes, for this reason I would recommend using the Batch Prefab Baker to create prefabs that use the same material. Set everything possible to use "Static batching". This way you should get the benefit of fustrum culling and mesh combining. Only combine meshes that are very close together (a pile of sandbags, crates, rocks) etc...
     
  35. roberto_sc

    roberto_sc

    Joined:
    Dec 13, 2010
    Posts:
    144
    Thank you for your prompt reply! I'm trying to use Batch Prefab Baker (using MB3_Texture Baker previously to generate the required texture for BPB (error "Texture Bake Results is not set"). I have around 200 prefabs that use the same shader but different material files (exact the same properties and shader, though... :( ). I found 3 problems:

    1. It's hard to assign 200 prefabs in BPB. I resolved this by dropping them in a scene, assigning them in the Texture Baker and pressing the Populate Prefab Rows in BPB. Sounds right?
    2. It's awesome that BPB can work with renderers outside the root object, but Texture Baker is complaining about it. "Object Tree_Variation17 does not have a MeshRenderer or a SkinnedMeshRenderer component", it's in its children...
    3. Is there a way to automatically replace game objects in the scene with their new prefab counterparts?

    Finally, reading your answer I assumed that replacing materials that use the same shader with one single material would provide a benefit, but my understand is that static objects would be batched by unity even when using different materials (with the same shader). Am I missing something?

    Sorry for the wall text, thank you.
     
  36. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Yes, there is significant benefit to sharing the same material, not just the same shader. Unity can't batch objects that use the same shader, only objects that use the same material. They also need to be on the same lightmap (if using baked or realtime lights), and use the same lightprobes if lit by lightprobes.

    The objects in the TextureBaker list need to be the actual renderers. Try dropping the prefabs into the scene. Selecting them all and using "tools for adding objects to be combined" to add the renderers to the Texture Baker.

    I don't have a good solution at this time to automatically replace game objects in the scene with the new prefabs. I have used the prefabs in the scene as the "result prefabs" and created duplicates to use as the source prefabs. Make sure you make a backup before trying this procedure.
     
  37. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    I noticed that you submitted a fix for submeshes with zero length causing an error.

    I have that error in a scene that I'm using and want to identify the mesh that has this issue.

    I've baked 100s of meshes, is there an easy way to tell which one is causing the issue?
     
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    I would write a script. Here is a script that should find and select the bad meshes. I haven't tested it very hard:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5. public class FindBroken : MonoBehaviour {
    6.  
    7.     [ContextMenu("Find Meshes With Zero Submeshes")]
    8.     void FindMeshesWithZeroSubmeshes () {
    9.         List<Transform> badRenderers = new List<Transform>();
    10.         MeshRenderer[] mrs = FindObjectsOfType<MeshRenderer> ();
    11.         foreach (MeshRenderer mr in mrs)
    12.         {
    13.             Mesh m = mr.GetComponent<MeshFilter>().sharedMesh;
    14.             for (int i = 0; i < m.subMeshCount; i++)
    15.             {
    16.                 if (m.GetIndices(i).Length == 0)
    17.                 {
    18.                     Debug.Log("Found a Mesh with zero length submeshes " + mr.name);
    19.                     if (!badRenderers.Contains(mr.transform)) badRenderers.Add(mr.transform);
    20.                 }
    21.             }
    22.         }
    23.         UnityEditor.Selection.objects = badRenderers.ToArray();
    24.     }
    25.    
    26. }
     
  39. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    I have a iClone model (player character).. I need to combine its mesh so it works with another asset I have... I tried to use the free verision of this... but it didnt seem to work very well..his skin did show thrue the shirt, arms not on the right place.. his pants were broken on places.. no bones so did not know how to use him afterwards....maybe I dont fully grip this..
     
  40. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    Thanks...I'll give it a try
     
  41. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    You say there are no bones. Is the 'Renderer' of the MB3_MeshBaker set to "skinned mesh"? If so then the bones will be the orginal bones used by your source meshes. Also try with Optimize Mesh turned off and on. In some versions of Unity the Optimize mesh can mess up some skinned meshes. What version of Unity are you using?

    You say the skin shows through the shirt. Does it work when the meshes are not combined?
     
  42. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,151
    5.6 the latest update.. yes it works when not combined.. I have to try again..
     
  43. Sam0waR

    Sam0waR

    Joined:
    Nov 30, 2015
    Posts:
    26
    Quick question. Which texture size does MB use when baking atlases - physical size of the source image file or size according to the import settings? For example we have 8k TGA file, but in the import settings it is set to max 1k.
     
  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    Mesh Baker uses the size of the physical size of the source image file which is what is returned by the unity3d Texture2D API.
     
  45. Sam0waR

    Sam0waR

    Joined:
    Nov 30, 2015
    Posts:
    26
    Ok, thanks, another question.
    I have troubles trying to bake with generate_new_uv2_layout. Please look at the screenshot.
    MBM.JPG
    MB warns that we can go over 65k verts cap, but does not propose how to workaround.
    So when baking, I have the error in console:
    SetPerIndexUVs failed because the output has >64K vertices
    UnityEditor.Unwrapping:GenerateSecondaryUVSet(Mesh, UnwrapParam)
     
  46. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    You will need to manually remove some of the meshes from the bake. Unfortunately there is no way to predict in advance how many vertices will be split. You could try the multi mesh baker and set the maximum number of vertices per mesh to something like 50-60k lowering it until the bake works.
     
  47. Sam0waR

    Sam0waR

    Joined:
    Nov 30, 2015
    Posts:
    26
    It is already Multi baker, ask you can see on the screenshot. And of course first I have tried to do - is to change the max verts in mesh. But appeared it is impossible! - every time you change the value, it immediately returns back to 65535. Read-only property or a bug?
     
  48. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,086
    It is a bug. You can't change the value of the field once there are objects in the combined mesh. It should work with "Clear Buffers After Bake" but internal data is not being cleared correctly. To fix it change the method ClearBuffers in MB3_MultiMeshCombiner.cs

    Code (CSharp):
    1.    
    2.  
    3. public override void ClearBuffers(){
    4.         for (int i = 0; i < meshCombiners.Count; i++) {
    5.             meshCombiners[i].combinedMesh.ClearBuffers ();
    6.         }
    7.         obj2MeshCombinerMap.Clear();
    8.     }
    9.  
     
  49. christophercimbaro

    christophercimbaro

    Joined:
    Aug 30, 2017
    Posts:
    12
    Hi Mesh baker team and Unity users,

    I have a question, acutally we're using Vertex Tool Pro, I try to attach our modular environment to limit number of draw call. Vertex tool pro use a custom shader with 2 or 3 materials which are blend on RGB vertex color.

    First point, when I create atlas with MeshBaker my atlases are well created for Red channel but not for the green one (in the same shader). Surely, I miss something but I don't find even with the documentation. I checked to add manually Custom shader propert names. So I have in fact a specific atlas but never with material in green channel.

    Second point, I checked in output Bake Into Prefab and I create a game object empty but my object are always empty after the bake. Did i miss something?

    Some attachement bellow,

    Have a nice day,

    Best,
     

    Attached Files:

  50. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510

    Thanks for the script! I found the meshes that were giving the issue and re-baked them with the latest version of MeshBaker