Search Unity

Mesh Baker by Digital Opus [RELEASED]

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

  1. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Hi all,

    I am evaluating Allegorithmic Substances for my own project and wondering if anyone have ideas how to integrate Substances with MeshBaker?
    Would be great to get some ideas of workflow and how the two technology could be successfully combined.

    Thanks in advance.
     
  2. Zaffer

    Zaffer

    Joined:
    Oct 21, 2010
    Posts:
    266
    Hi

    After some experimentation, I got Mesh Baker to work well with Unity Tree Creator trees and the results are great! Just look at the draw calls I saved (217 with the original trees and 133 with the Mesh Baker mesh)! And that's only the beginning -- just the birch trees. I still have maples, oaks, regular trees and bushes to do! Mesh Baker is going to help me realize my dream of making my big, clunky landscape into a lean, clean machine -- well much leaner anyway. Thanks so much for making it, Phong.

    Phong has posted a summary I wrote of tips for working with Mesh Baker and Tree Creator here: http://www.digitalopus.ca/site/faqs/tips-for-using-mesh-baker-with-unity-tree-creator-trees/

    Zaffer
     

    Attached Files:

  3. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    I don't know, it probably depends on exactly what you're doing, and is it at run time or at design time? For the sake of an answer, I was able to find this...

    http://forum.allegorithmic.com/index.php?topic=93.0

    If you don't combine them into texture atlases, you might still be able to combine meshes with like substances somehow, I'd hope that MeshBaker would work with Substances to bake the meshes, but I haven't tried it. You might have to do something like making the substances into a bitmap, then create a material out of it, them use meshbaker on the materials? I'm not sure what exactly that workflow would look like. Hopefully someone that knows more about substances than I do can comment.

    Good Luck,
    Ralph
     
  4. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @Zaffer,

    Congratulations on the successfully MeshBaker trees, they results are really good.
    I've been following along and very much appreciate you sharing the hard-earned tips.
    Definitely need more tips like this in the MeshBaker knowledge base.

    Cheers.
     
  5. Jason-King

    Jason-King

    Joined:
    Oct 28, 2010
    Posts:
    56
    I'm attempting to combine multiple skinned and unskinned meshes of a single model into a single mesh. Some of my assets work fine. Others give me...

    The list of objects to combine contains a null at position.0 Select and use [shift] delete to remove
    UnityEngine.Debug:LogError(Object)
    MB2_MeshBakerRoot:doCombinedValidate(MB2_MeshBakerRoot, MB_ObjsToCombineTypes) (at Assets/MeshBaker/scripts/MB2_MeshBakerRoot.cs:48)
    MB2_TextureBaker:CreateAndSaveAtlases(ProgressUpdateDelegate, FileSaveFunction) (at Assets/MeshBaker/scripts/MB2_TextureBaker.cs:171)
    MB2_TextureBakerEditorInternal:DrawGUI(MB2_TextureBaker) (at Assets/MeshBaker/scripts/Editor/MB2_TextureBakerEditorInternal.cs:173)
    MB_MeshBakerEditorWindow:OnGUI() (at Assets/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:175)
    UnityEditor.DockArea:OnGUI()

    When I get this error, all of the individual meshes of the model will give me this error. How do I fix?

    Additionally, when I am successful at combining, it appears that I can combine the meshes into a single mesh via baking into the scene. At that point I can have this new skinned mesh animate without issue. However, this new strain of model only exists in my test scene. But I need to instantiate multiple of these animating models via prefabs in my game. When I attempt to bake into prefab, I lose my connection to the animated model's skeleton. How can I combine skinned and unskinned meshes into a single-prefab-model-with-skeleton that can be animated?
     
  6. Jason-King

    Jason-King

    Joined:
    Oct 28, 2010
    Posts:
    56
    It looks like my errors were due to attempted reuses of MeshBaker game objects.

    Also, I believe I have a solution to the single-prefab-model-with-skeleton issue. First I create a prefab-based baked mesh. Then I create the scene-based baked mesh and instead of using an internal mesh it seems to now use the previously created prefab mesh and proceeds to make the connection between the prefab mesh and the skeleton. At that point, I can then combine the prefab mesh with the skeleton and store the object hierarchy as a new single prefab. Can anyone confirm that this is the proper procedure? Or am I missing something?
     
  7. STARS

    STARS

    Joined:
    Jun 28, 2012
    Posts:
    8
    Hey Phong ...

    I did everything according to your youtube tuts and the Mesh and Material Baking process works like a charm but there are some issues:

    First of all 'd like to have my meshes seperated so that unity could batch them all. All I need, is to get a big atlas from the skinned meshes sharing the same material and apply it all back. with that in mind, this time I tried using the Material Baker instead of Mesh And Material Baker and went throught the same procedure.
    it nicely creates an atlas but wouldn't apply it back to meshes. I was expecting to get it all automatically done just like the mesh baker.
    ok then, I thought maybe I would add it manually ? and I did it but unfortunately the whole atlas is applied, it's kinda like adding a simple texture to a mesh.
    What am I doing wrong ?! I got no error btw.

    Second, a long time ago I saw somewhere that Eric would emphasis on not to combine meshes in thrid party programs because he believed that unity batching system works way better. my question is that what makes your combining system different from third party tools ?

    Third, say we have two objects in a sence with the same material way far from each other and we combine them using Mesh Baker. then what would happen if camera looked at one of them ? would it render the other one as well because they're combined ?
    If so then I guess it would defeat the occlusion calling as well right ?
     
    Last edited: Aug 11, 2013
  8. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    I can answer these two.

    If you own Unity PRO, static batching probably works better. I don't have the spare $1500.

    It can't do object culling, it should still be able to do culling for vertices outside of the view frustum.

    My 2c,
    Ralph
     
  9. STARS

    STARS

    Joined:
    Jun 28, 2012
    Posts:
    8
    I did a little test here to make sure how it works.
    View attachment $Mesh Baker test.zip

    there's no difference in its combining method. it works just like other combining scripts and third party tools HOWEVER with an unprecedented difference of making an atas out of them.
    so it shouldn't be neglected that just because you can create an atlas out of similar materials, you should bake the whole scene with it because if you do, you'd actually turn the scene into a huge high-poly mesh (or meshes) that with any single object put in the view frustum, all combined meshes get renderred. so you'd better manage your objects according to your specific scene imo.

    But what I'm looking for is to bake JUST the materials into a big atlas and then apply it back to all of them. I was hoping to use the Material Baker to get the job done but unfortunately it just makes an atlas out of them and does nothing else. :( Am I missin sth here ?
     
    Last edited: Aug 11, 2013
  10. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    Stars,
    I'm not sure, my big problem is an enormous number of small polys, not materials, I'm also doing everything procedurally. Worst case, I think that there was some recent functionality added to enable the renderers on individual objects. There's a big button labeled Enable Renderers on combined objects. which I believe would still create the combined mesh, but then disable it in favor of the individual objects. Not the ideal method, so be sure, but you might play with it.
     
  11. STARS

    STARS

    Joined:
    Jun 28, 2012
    Posts:
    8
    functionality added to Unity or Mesh Baker cause I don't see any Enable Renderers on combined objects.

    Anyways this is how I do it and I'm still waiting for Phong to get some answer.

    settings for two simple cubes with Diffuse shader and baked with MaterialBaker:
    $Cubes.jpg $BakedMaterial01.jpg

    and here's the atlas:
    $Atlas.jpg
     
  12. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Sorry for the long delay. I was away all weekend. You should only get the error you describe if there are empty slots in your list of objects to be combined.

    Regarding, how to prefab a skinned mesh. There is a procedure in the FAQ describing how to do this. http://www.digitalopus.ca/site/faqs/how-do-i-prefab-a-baked-skinned-mesh/
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I am not sure what is happening based on your explanation, but it it works it is probably good. The recommended procedure is described here. http://www.digitalopus.ca/site/faqs/how-do-i-prefab-a-baked-skinned-mesh/
     
  14. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    What you want is output option Bake Meshs In Place. This will create a new mesh asset for each mesh with adjusted UVs. Make sure your source meshes are at position 0,0,0, rotation 0,0,0 scale 1,1,1 or the vertex positions will be baked into the new meshes.
     
  15. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    What you want is the output = "Bake Mesh Assets In Place".

    Regarding what is the best way to optimize a scene. Static batching is awsome when you can use it. Bake Mesh Assets in Place helps you take advantage of it by making more meshes share materials. You still get the benefits of occlusion culling and fustrum culling with static batching. However often you can't use it because your meshes are being created at runtime by a script, or your environment is modifiable by the user or you have the Indy version or your world is too huge to have as one big scene built in the editor. In these cases you need to do your own mesh combining.

    Dynamic batching is fairly nice but it re-batches every frame which is expensive and often overkill.

    Mesh Baker gives you more options and control over how, when and how often things get combined.

    For example imagine a wall with 1000 bricks that you would like to crumble using physics. Each brick is a separate mesh renderer. This is expensive for Unity since the bricks are not static. However dynamic batching is not ideal either since each batching 1000 objects every frame is expensive. Mesh Baker can combine these into a single skinned mesh which is much faster.

    Another example would be a wall with 1000 bricks that the user can knock out brick by brick by hitting them with a ball. Again these are not static, and dynamic batching is overkill because you don't need to re-batch every frame. What you want is to remove a brick from a combined MeshRenderer mesh each time a brick is hit. Mesh baker can do this.

    Adding decorations to an xmas tree would work the same way. Or throwing darts at a dart board.
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Just wanted to let people know that I will be on Vacation and thus am unable to reply to support requests for the week of August 25 through 31st. I will reply to any support requests as soon as I return.
     
  17. Jason-King

    Jason-King

    Joined:
    Oct 28, 2010
    Posts:
    56
    Hi Phong,

    I'm having an issue where a skinned submesh (the left hand) is being combined but its normals are inverted. The rest of the submeshes in the model combine with appropriate normals. Additionally, most of my skinned models that I'm combining do combine appropriately. But I have two models where I'm seeing the inverted meshes. The artist working with these models are not seeing any indications of anything unusual with those submeshes within 3dsMax.

    Additionally, I purchased your Mesh Master in an attempt to flip the normals, but that solution is not going to work. Mesh Master prevents me from selecting faces on skinned meshes and attempting to access the mesh on it's own (without bones) results in all the submeshes set to the origin and individual faces cannot be parsed out.

    Please help provide a solution.

    Thanks,
    Jason
     
  18. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    This is very strange. I can't think of anything that could cause this to happen and have not had reports of this before. I am on vacation this week and won't be able to look at this until next week. If you are willing to send me the mesh when I return I would love to take a look at this.

    The trick is to temporarily switch the mesh renderer to a MeshFilter/MeshRenderer from a Skinned Mesh Renderer. You can then make changes to to the mesh, save it, and use it in a Skinned Mesh Renderer. All the bone information will be preserved.

     
  19. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    I've been using MeshBaker in a number of projects with a lot of success, however there is one part of it that still eludes me, and that is 'excess textures in memory'.

    Here's an example...

    I have an object pool of collectable objects. Their MeshRenderers are disabled, and as they are generated they're added to a dynamically baked mesh. That works great and my draw calls are one for the entire group of collectables - totally awesome.

    HOWEVER - the original textures for those collectables, those textures are all still in memory, because they exist on the objects in my object pool. If I remove the materials, MeshBaker of course cannot determine what the material was on the object and therefore gives errors. That's of course expected. What eludes me here, though, is how I can use MeshBaker to reduce the amount of textures in memory when I have a situation such as dynamically baked objects? Is there a special way I should pool these? Is there a secondary object I need to create and use as the objects in my pool? Any advice would be super awesome, as I need to reduce what I got in memory.

    Thanks in advance - and I hope you are enjoying your vacation, Phong! :)
     
  20. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Hi I tried the evaluation version, I let it scan my scene for ages then I got the following errors, any ideas?

    Object StrikeToopLOD1 does not have a MeshFilter or a SkinnedMeshRenderer component
    UnityEngine.Debug:LogError(Object)
    DigitalOpus.MB.Core.MB_Utility:GetMesh(GameObject)
    _GameObjectAndWarning:.ctor(GameObject, String, LightMapOption) (at Assets/IMPORTEDASSETS/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:389)
    MB_MeshBakerEditorWindow:listMaterialsInScene(Boolean) (at Assets/IMPORTEDASSETS/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:428)
    MB_MeshBakerEditorWindow:OnGUI() (at Assets/IMPORTEDASSETS/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:54)
    UnityEditor.DockArea:OnGUI()


    And then:


    NullReferenceException: Object reference not set to an instance of an object
    MB_MeshBakerEditorWindow+_GameObjectAndWarning.CompareTo (System.Object obj) (at Assets/IMPORTEDASSETS/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:359)
    System.Collections.Generic.Comparer`1+DefaultComparer[MB_MeshBakerEditorWindow+_GameObjectAndWarning].Compare (._GameObjectAndWarning x, ._GameObjectAndWarning y) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Collections.Generic/Comparer.cs:84)
    System.Array.compare[_GameObjectAndWarning] (._GameObjectAndWarning value1, ._GameObjectAndWarning value2, IComparer`1 comparer) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System/Array.cs:1744)
    System.Array.qsort[_GameObjectAndWarning,_GameObjectAndWarning] (._GameObjectAndWarning[] keys, ._GameObjectAndWarning[] items, Int32 low0, Int32 high0, IComparer`1 comparer) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System/Array.cs:1724)
    System.Array.Sort[_GameObjectAndWarning,_GameObjectAndWarning] (._GameObjectAndWarning[] keys, ._GameObjectAndWarning[] items, Int32 index, Int32 length, IComparer`1 comparer) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System/Array.cs:1674)
    Rethrow as InvalidOperationException: The comparer threw an exception.
    System.Array.Sort[_GameObjectAndWarning,_GameObjectAndWarning] (._GameObjectAndWarning[] keys, ._GameObjectAndWarning[] items, Int32 index, Int32 length, IComparer`1 comparer) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System/Array.cs:1677)
    System.Array.Sort[_GameObjectAndWarning] (._GameObjectAndWarning[] array, Int32 index, Int32 length, IComparer`1 comparer) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System/Array.cs:1623)
    System.Collections.Generic.List`1[MB_MeshBakerEditorWindow+_GameObjectAndWarning].Sort () (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Collections.Generic/List.cs:568)
    MB_MeshBakerEditorWindow.sortIntoBakeGroups2 (Boolean useFilters, System.Collections.Generic.Dictionary`2 shader2GameObjects, System.Collections.Generic.Dictionary`2 gs2bakeGroupMap, System.Collections.Generic.List`1 objsNotAddedToBaker) (at Assets/IMPORTEDASSETS/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:543)
    MB_MeshBakerEditorWindow.listMaterialsInScene (Boolean generateMeshBakers) (at Assets/IMPORTEDASSETS/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:465)
    MB_MeshBakerEditorWindow.OnGUI () (at Assets/IMPORTEDASSETS/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:54)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  21. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hmmm, this is a good question and is something that I have not looked into. One solution might be to remove the textures from the materials with the disabled renderers sometime after the textures have been baked. This should work since Mesh Baker does not look at the textures in a material when baking meshes together. I will try to take a look at this but have a lot to do since getting back so it may take a while.

    Had a great vacation. Thanks.
     
  22. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    This one is puzzling to me. What components are on StrikeToopLOD1? It appears that Mesh Baker is finding a renderer on this object. It then checks that it is a MeshFilter or SkinnedMeshRenderer. But when it tries to call GetComponent<MeshFilter> and GetComponent<SkinnedMeshRenderer> it can't find either of those.
     
  23. Jason-King

    Jason-King

    Joined:
    Oct 28, 2010
    Posts:
    56
    I'm not sure I follow. I believe I tried doing that originally and as I mentioned without the bones (switching from SkinnedMeshRenderer to MeshFilter/MeshRenderer) all the meshes reset to the origin and become a jumble that is impossible to untangle. How are you switching from SkinnedMeshRenderer to MeshFilter/MeshRenderer and accomplishing what you are suggesting?
     
  24. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    I upgraded to the latest version and I get the following compiler errors:

    Assets/MeshBaker/Examples/BakeTexturesAtRuntime/BakeTexturesAtRuntime.cs(17,14): error CS0101: The namespace `global::' already contains a definition for `BakeTexturesAtRuntime'

    Assets/MeshBaker/scripts/MB2_MeshBaker.cs(25,14): error CS0101: The namespace `global::' already contains a definition for `MB2_MeshBaker'

    Assets/MeshBaker/scripts/MB2_MeshBakerCommon.cs(25,23): error CS0101: The namespace `global::' already contains a definition for `MB2_MeshBakerCommon'

    among several others of a similar nature. How should I resolve these errors?
     
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Modifying a SkinnedMesh directly doesn't work because the vertices you see in Unity have been transformed by the bones. Trying to modify them just makes a mess. The workaround is to add your skinned mesh to a MeshFilter. Then you can see it in its bindpose and modify that.

    1) Create a new empty game object add a MeshFilter and MeshRenderer.
    2) Drag the mesh asset from your SkinnedMeshRenderer object to the MeshFilter. Note that if your the skinned mesh is not a standalone mesh asset you will need to use "Save Mesh As Asset" first.
    3) Now you should see your skinned mesh in its original bindpose. Add a MeshMaster component and make the changes you want.
    4) Drag the modified Mesh bake to the mesh slot in the SkinnedMeshRenderer.

    Are you still having the problem you described with your normals being inverted. If so I wouldn't mind taking a look at one of your models to see what is going on. I honestly can't see how this could be happening.
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    It looks like some of the old MeshBaker files are still around (were not overwritten). This is possible since the files were reorganized at some point. The safest thing to do is to completely delete the MeshBaker folder and re-import. Unity is smart enough to map the new scripts to your old components.
     
  27. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    151
    previously i worked on MB worked just fine but recently i went to create some static prefabs from my union character customization assets , it began given me some strange result

    just after baking the skinned mesh

    $1.jpg

    at the play mode ?!

    $2.jpg

    at the edit mode if i touch the mesh ?!

    $3.jpg

    please help.
     
  28. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    I just got MeshBaker and I am struggling a little bit. So I have a newby question.

    The generated combined mesh has the Atlas tiled on it. Shouldn't the combined mesh just have the new atlas not tiled and stretched over the object?

    How do I fix this?

    I am guessing this might be occurring because my original textures are tiled. Can Mesh Baker convert a scene with tiled meshes into an Atlas?


    $MeshBakerTiled.PNG
     
    Last edited: Sep 15, 2013
  29. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Zaddo67,

    It is tough to know with just a picture what is going on. The generated combined material should have a tiling setting of 1,1 and offset of 0,0. Are you finding that it does not?

    MeshBaker will try to bake tiling textures into the atlas. This can get complicated if there are submeshes involved.

    Do your source meshes have submeshes? If so then you probably need to set up multiple materials.

    Are there any warnings in the console? These will probably give hints as to what is going on.
     
    Last edited: Sep 16, 2013
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Another user has reported strange behavior with skinned meshes which I have not been able to reproduce. Could you send:

    • The version of Unity you are using (platform)?
    • Which build target you are using?
    • A screenshot of the inspector?
    • Anything that might be different about this mesh?

    Thanks.
     
  31. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    151
    sure :D :

    - version is the current one 4.2.1
    - PC stand alone running on windows 7

    $inspector.png

    - the FBX File has around 300 skinned meshes , to help provide
    a proper less costly customisable Actors , which is actually using
    a custom plugin fit to this project witch result in proper characters

    - the most costly actor won't exceed 1000 vertices
    and i was using mesh baker since version 2.0 i guess around six month ago
    somewhere in the line i upgraded it to the current 2.5 but i never went back to
    backing an actor since last week and that happens :(.

    - i did not alter your original code.

    - after this i baked it manually without the plugin but the result was same as gave provided it on my previous post .
     
  32. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    151
    one more thing i forgot to mention is that in my project case Every Character Materials are not stored in a file but actually are an instance of it generated by the plugins and actually i commented out the IF statement from MB code at Texture combing script file
     
  33. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    Hi PHong,

    The tiling looks correct. I have attached some screen dumps below.

    I have no submeshes, see other screen dump for example of how meshes have been set up.

    The logs for baking mesh are here:

    Bake materials into combined mesh:
    https://dl.dropboxusercontent.com/u/87201649/meshbakerlog1.txt

    Mesh baker:
    https://dl.dropboxusercontent.com/u/87201649/Meshbakerlog2.txt

    I hope this helps. I appreciate any suggestions you can give me.

    Thx.

    Tony

    $Capture11.JPG $Capture12.JPG
     
  34. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Tony,

    It looks like you are using output option bakeMeshAssetsInPlace. This creates a new mesh asset for every object in the list of objects to be combined. Each new mesh has adjusted UVs so that it can use the new combined material with the new atlas. You will need to manually drag the new mesh assets onto the MeshFilter components and the new combined material onto the mesh renderer components. This output option is for taking advantage of static and dynamic batching. Is that what you wanted? You may want to try bakeIntoSceneObject first since that is the simplest.
     
  35. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I am a bit stumped on this one. The instance of the material sounds problematic since MB uses the material to look up the UV rectangle in the atlas but I don't think it would cause the problems you are seeing. If possible I would love to take a look at one of these meshes. Could you PM me?
     
  36. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi phong
    i was wondering if you made some test with cartoon shader, for some reason i didn t manage to make it work. but it s not a big deal for me as i dont need it, just did as test, so just let you know.
    awesome tool, especially for the animation part
    cheers
     
  37. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    These should work but there are a couple of tricky things.

    The toon shaders use a texture property called _Ramp which is not in the list of texture properties that MeshBaker looks for. You will have to add this in the list of texture property names. Also check that the non-texture properties on the result shader are adjusted the same as the source shaders.
     
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Everyone,

    My MeshBaker LOD asset is almost ready for release and would love to have a few people try it out. Please PM me if you are interested in participating in the Beta. Please only reply if you are very familiar with MeshBaker and are reasonably technical since at this point the documentation and tutorials are limited.

    MeshBaker LOD is a replacement for Unity's LOD system with a few improvements:

    • It works with the Indy version
    • LOD objects are baked into combined meshes. So you get the benefit of combined meshes (fewer drawcalls) combined with the benefit of LOD
    • As the LODs change, the combed meshes are updated dynamically at runtime

    You must have MeshBaker installed to use MeshBaker LOD.
     
  39. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Cool count me in :)
     
  40. jomeier

    jomeier

    Joined:
    Jun 5, 2010
    Posts:
    45
    Hi DCalabrese,

    I have absolutely the same problem as you.

    Did you find a solution for your problem?

    My skinned mesh disappears in a certain distance from the camera and appears again, if a move my cam further.

    I saw that the combined meshes pivot point is not in the center of the mesh but at 0,0,0.

    Have no idea, what the cause of the problem is :-(
     
  41. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Jomeier,

    The problem is most likely the animation culling settings interacting with the bounds of the skinned mesh. Look at the "culling" setting on the inspector for your animations. The safest is to set it to "always animate".

    Also try to print out the bounds of the skinned mesh or display it with OnGizmos to see that it is reasonable. There is a method in the API for regenerating the bounds of a a skinned mesh.

    Another unlikely possibility is the DirectX 11 settings. Some users have reported strange problems if this is turned on. This seems to be graphics card specific. I have not been able to reproduce it myself.
     
  42. jomeier

    jomeier

    Joined:
    Jun 5, 2010
    Posts:
    45
    Hi Phong,

    the culling was set to "Always animate". The bounds seem to be ok. How do bounds look like if they are ok and if they aren't?

    What if there are a few skinned meshes combined together? The bounding box would take the extent of the size of all the skinned meshes. So in my opinion more than one combined skinned model would also show this problem cause the bounding box for a single model would be always as big as the whole combined group in this case.

    Could you implement a "fix bounds" button in your asset?
     
  43. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    The bounds could be set to zero or some value that does not contain the skinned mesh. If this is the case then it could get culled through frustum or animation culling. The bounds should contain the combined skinned meshes. If this is what you are seeing then this should not be the problem.
    Are you still seeing the problem? I can't think of anything else that could cause this. If you would like to send me the model I would be happy to take a look.
     
  44. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    I'm trying to reduce draw calls on a complex asset (similar to your video of "Tropical Nature"). The shader report which Mesh Baker creates is great and it lists a huge number of targets. However, after selecting "Generate Mesh Bakers" and waiting for it to complete, the array "Objects to be combined" is empty. I also get this error message on the console:

    UnityException: Creating asset at path failed.
    MB_MeshBakerEditorWindow.createAndSetupBaker (System.Collections.Generic.List`1 gaws, System.String pthRoot) (at Assets/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:750)

    Any ideas what I'm doing wrong? I did set a folder for the combined assets before selecting Generate. Apologies if this has already been covered earlier in this thread.
     
  45. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Are there any error messages or warnings previous to this one? Normally if asset creation fails then Unity prints two error messages. The first one is the reason for the failure. Is the folder for the combined assets in your Assets folder?
     
  46. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    Thanks Ian, it's working fine now. The folder for the combined assets was outside my Assets folder.
     
  47. TheDemiurge

    TheDemiurge

    Joined:
    Jul 26, 2010
    Posts:
    42
    Hi,
    I'm actually seeing this problem as well. I was trying out this tool to see if it would fit for our mobile game, and I wanted to try it out first before I committed. Using Unity 4.2.1 and the current evaluation version right from your website, and I'm on a Mac. I'm able to bake the textures without any errors/warnings, likewise for the mesh, and it shows up fine. Our camera/character setup is a 3rd person view similar to an RPG. When I start running around in the level, certain camera angles, and in certain positions of the character/camera, the character disappears. And it happens in the Scene view as well, if I start rotating around the character I will inevitably make it appear/disappear.
    The animators are set to Always, and the bounds seem to be around the character himself (if not around the weapon on his back, but that's no different between when he renders and when he doesn't). I was about to try a build to see if it was only in the editor and then I learned that my coworkers misunderstood the difference between the free version and the full one :)

    As with the previous mention of this issue, changing any setting on this renderer in the inspector will make it render again. Also, checking "Update When Offscreen" will keep it rendering.

    Any help you can provide is much appreciated.
     
  48. jomeier

    jomeier

    Joined:
    Jun 5, 2010
    Posts:
    45
    Hi TheDemiurge,

    "Update when offscreen" destroys all benefits of this tool :)

    Maybe theres an error in unity 3d :-( ?

    Regards,

    Josef
     
  49. TheDemiurge

    TheDemiurge

    Joined:
    Jul 26, 2010
    Posts:
    42
    I did notice some odd behavior when checking that option, and since my intention is to 'bake' each character rather than all of them, that would indeed go against our intention for some situations. And I haven't seen any other mention of this being a requirement for it to work.
    I will try in the morning to sync all the info to one of our Windows computers, for the heck of it.
     
  50. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi TheDemiurge and Jomeier,

    I have not yet been able to reproduce the problem on my end, however I am sure that the problem as to do with the bounds of the SkinnedMeshRenderer. From the manual:

    There is a method in the API called updateApproximateBounds which recalculates the bounds based on the transforms of all the bones. I would suggest calling this function. Try saving the following code in a C# script called UpdateBounds and attaching it to the meshbaker component. Please let me know if this solves the problem.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class UpdateBounds : MonoBehaviour {
    6.    
    7.     MB2_MeshBaker mb;
    8.    
    9.     // Use this for initialization
    10.     void Start () {
    11.         mb = GetComponent<MB2_MeshBaker>();
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.         mb.UpdateSkinnedMeshApproximateBounds();
    17.     }
    18. }
    19.  
    If anyone has a simple scene in which they are able to reproduce this problem please send it to me.
     
    Last edited: Oct 15, 2013