Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mesh Baker by Digital Opus [RELEASED]

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

  1. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    The distorted colors are probably due to non-texture properties in the materials being combined that have different values. You might be able to tweek these to get the result you expect.

    Mesh Baker will use more memory. Although there are some things you can do to reduce the memory footprint. Look at the console log when building. It prints a report listing how much space everything is taking.

    Remove the MeshBaker objects and source objects from your scene after baking if you don't need them. If you need a source object because of its colliders or scripts or another reason. Then consider removing the MeshFiter and MeshRenderer component. These will only be needed if you are doing some dynamic baking. Consider baking meshes into prefabs.

    Compress the atlases that Mesh Baker creates (this will make a BIG difference).

    Even with these steps, Combined Meshes will use more memory than the source meshes. This is because Unity can re-use a source mesh (one instance) many times if there are different renderers that use the same mesh. When meshes are combined, each mesh in the combined mesh is effectively its own instance.

    Consider reusing combined meshes. For example if you have a pile of crates in several places in your game. Bake one pile, then duplicate the combined mesh scene object (the duplicate will share the mesh reference).

    If different scenes use a pile of crates then be sure to bake into a prefab. This way the same mesh asset will be shared by several scenes. If you bake the pile of crates in each scene, then each scene will contain its own combined mesh.

    If you are good with scripting then combine your meshes on scene load (at runtime). This will result in a small build since the only meshes in the build are the source meshes. The combined meshes are created as needed..
     
  2. Ribosome

    Ribosome

    Joined:
    Jan 15, 2013
    Posts:
    43
    Problem with light map shader,Please helpo_O
    When I used Mesh Baker with common shaders, it seems working well,but when I use it with Light map shader, it doesn't work right, and UVs got messed up,
    Here are results,As you can see, the combined meshes and texture are a mess,
    why is that?
    FIY:

    Any tip or help would be appreciated.
     

    Attached Files:

  3. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    I think the problem is the tiling. Does the tiling happen in the UVs or the texture settings? Are there multiple submeshes (I notice that the white lines are not tiled like the splat textures)?

    If there are multiple submeshes with different tiling you will need to use multiple-materials. I would recommend looking at this video
    . It covers situations with tiling and multiple submeshes.
     
  4. Ribosome

    Ribosome

    Joined:
    Jan 15, 2013
    Posts:
    43
    Thanks , that did help me, But now I Have a new problem,as the picture below
    The combined materitial is Blur or at lower resolution than the original one
    Is there a way to improve it?
    Or is this currently a limitation of MB?
     

    Attached Files:

  5. alexman

    alexman

    Joined:
    Jul 11, 2012
    Posts:
    17
    Hi Phong,

    I've got this compile error :

    No overload for method AddDeleteGameObjects takes 2 arguments

    how to resolve? thanks.
     
  6. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Look in the console when combining textures. There should be a report showing what was combined into the atlas, how big the source was and how much it was shrunk (if shrunk) when added to the atlas. Mesh Baker is limited to the maximum size that Unity will handle which is 4096 x 4096. Sometimes the problem is the "Max Size" setting on the texture asset. The size of the image on disk is larger than this setting. If you set this setting larger it may fix the problem.

    Be careful with tiling. Tiling can eat up space in an atlas very quickly. Often it is a good idea to map a tiled material to its own submesh so it is free to tile without baking the tiling. This won't help with drawcalls but it can save space in an atlas.
     
  7. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Did you upgrade? Which file is the error coming from?

    I did clean up the API when I released the Mesh Baker 3 version so you may need to add a parameter, although I am looking at the code and the third parameter looks optional.
     
  8. alexman

    alexman

    Joined:
    Jul 11, 2012
    Posts:
    17
    Hi Phone,

    I've got 14 errors while trying to compile, please see attached screenshots :

    I am using v3.2.1

    screenshot.png screenshot2.png
     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    I would recommend deleting everything in the MeshBaker folder and re-importing. Don't worry, Unity will match up the new scripts with the old ones. Was there an older version of Mesh Baker? If so then delete it before reimporting. Did you move anything to the plugins folder? Try doing a search on MeshBaker in the project after deleting the MeshBaker folder to be sure everything is gone.

    Let me know if this helps. I know this works since I have tested the package on two different versions of Unity on three computers.
     
  10. SpectralRook

    SpectralRook

    Joined:
    Feb 9, 2014
    Posts:
    112
    I'm having a problem creating a prefab from the object generated by MeshBaker. For some reason the mesh is lost when I make the prefab. I'm new to MeshBaker so likely doing something wrong. Note, the work around I used was to open up the scene game object created by MeshBaker in ProCore's QuickEdit and save the mesh. Any recommendations on how to resolve this within MeshBaker? I created a video showing the problem.

     
  11. Deleted User

    Deleted User

    Guest

    I installed the latest update to mesh baker to a new android project,,create new mesh and material baker..and an editor script immediately started throwing errors.

    NullReferenceException: Object reference not set to an instance of an object
    DigitalOpus.MB.Core.MB2_MeshBakerEditorInternal.DrawGUI (.MB2_MeshBakerCommon target, System.Type editorWindowType) (at Assets/MeshBaker/scripts/Editor/MB2_MeshBakerEditorInternal.cs:152)
    DigitalOpus.MB.Core.MB2_MeshBakerEditorInternal.OnInspectorGUI (.MB2_MeshBakerCommon target, System.Type editorWindowType) (at Assets/MeshBaker/scripts/Editor/MB2_MeshBakerEditorInternal.cs:66)
    MB2_MeshBakerEditor.OnInspectorGUI () (at Assets/MeshBaker/scripts/Editor/MB2_MeshBakerEditor.cs:50)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:1124)
    UnityEditor.DockArea:OnGUI()


    MB2_MeshBakerEditorInternal.cs

    line 152 -| if (mom.objsToMesh.Count > 0)

    NullReferenceException : mom.objsToMesh value is null on start/awake

    what do you think??

    If I put an object in the slot it should stop..but...this should have been caught earlier and dealt with..

    The earlier version, in another project does not have this behavior..


    p-
     
  12. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Look at the "output" field. If it says "bakeIntoSceneObject". Then Mesh Baker creates a mesh that is an instance in the scene. The mesh only exists in the scene so it can't be used in prefabs. If you use "bakeIntoPrefab" then the mesh will be saved as an asset.
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Something strange is going on. The error is being thrown from an MB2_MeshBakerEditorInternal component. These are legacy components. Although they are included for backward compatibility it should not be possible to create them from the menu. The new component should be MB3_MeshBakerEditorInternal. Did you upgrade without deleting the old MeshBaker directory first?

    You should be able to delete the _Legacy folder from the MeshBaker/scripts folder if all your meshbaker objects have been upgraded to the version 3 ones.
     
  14. SpectralRook

    SpectralRook

    Joined:
    Feb 9, 2014
    Posts:
    112
    Got it. Thank you.
     
  15. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    I think I may be having the same error as a person above. I just downloaded the evaluation version, and upon import was left with this message: "Assets/MeshBaker/scripts/Editor/MB3_TextureCombinerEditorFunctions.cs(10,42): error CS0433: The imported type `DigitalOpus.MB.Core.MB2_EditorMethodsInterface' is defined multiple times"
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Thanks for letting me know. I will take a look and get back.

    I downloaded the evaluation version and imported it into an empty project with no errors. Was it a clean project. Did you have another version of Mesh Baker there?
     
    Last edited: Jul 19, 2014
  17. ADKar

    ADKar

    Joined:
    Aug 10, 2014
    Posts:
    5
    Hi
    I got some problem with mesh baker.
    when i bake the mesh the light maps connected are displaced randomly on the objects.

    what could be the problem.
     
  18. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    The most likely explanation is that some of the source objects use different lightmaps from each other. There is no way to bake these together and preserve the lightmapping. There should be warnings if this is the case. Also the "list shaders in scene" report will tell you which lightmaps the various objects use.

    Another option is to generated a new UV layout on the combined mesh and bake a new lightmap on the combined mesh.
     
    ADKar likes this.
  19. ADKar

    ADKar

    Joined:
    Aug 10, 2014
    Posts:
    5
    Hi
    thanq very much for the help... i just want one more help, like is there any option in unity for generating a new UV layout for the combined mesh. I am new to unity...
     
  20. ADKar

    ADKar

    Joined:
    Aug 10, 2014
    Posts:
    5
    else how do i do that... when the was combined it is created as .asst or .prefab format.... which i could not take in to maya and regenerate the UVs. So there must be some way in Unity i think...
     
  21. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    The UnityEditor package has an Unwrapping class which has methods for creating UVs and UV2s. These are not accessible through the UI so you will need to write a short script to use them.

    Mesh Baker has an option for generating a new UV2 layout on the combined mesh.
     
  22. ADKar

    ADKar

    Joined:
    Aug 10, 2014
    Posts:
    5
    ok...thats great... where is it in Mesh Baker?
     
  23. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    It is under the "Lightmapping UVs" dropdown menu
     
  24. ADKar

    ADKar

    Joined:
    Aug 10, 2014
    Posts:
    5
    Yup its working now.. thats great. Thnq :)
     
  25. pokybluesky

    pokybluesky

    Joined:
    Feb 19, 2014
    Posts:
    3
    I know that mesh baker can work at runtime but

    How's about when i spawn enemy , can it be at runtime too ?

    Do you have any tutorial about mesh baker with spawned enemy ( using instantiate or object pooling )
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hello, there are a number of examples with Mesh Baker that show how to use Mesh Baker at runtime. The best one for your case is the the Skinned Mesh Render scene. When the scene is played, there are three buttons for instantiating a hat, sword and glasses. When the user clicks these buttons, prefabs are instantiated, and the meshes are added to the combined mesh. I think this is very similar to what you are describing. Does this answer your question?
     
  27. echeg

    echeg

    Joined:
    Aug 1, 2012
    Posts:
    90
    Hello. I have one question.
    Whether meshbaker with models that are animated through mecanim?
    I have several models, each of which uses a 5+ materials. Can I bake them?
     
  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Mesh Baker does work with Mecanim, but it does NOT work with the "optimized" skinned mesh import settings introduced in Unity 4. It also does NOT work with blendshapes. I won't be able to add support for these features until Unity makes blendshape and bone information available through the API.
     
  29. echeg

    echeg

    Joined:
    Aug 1, 2012
    Posts:
    90
    May suggest that I do not so?

    Way may animation not played?
     
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    There are two things that will affect whether or not animations play.

    1) The bounds in the combined mesh skinned mesh renderer. This can be set directly in the inspector or using a script. Mesh Baker includes two scripts that can be used to update the local bounds. You can also write you own script.

    2) The animation culling settings on the original animation. This should be set to "Always Animate". In your scene this looks like it is set to "Based On Renderers". Other settings probably won't work since the original skinned mesh render is disabled so the culling settings will stop the animation from playing.
     
  31. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    173
    hi im interested with mesh baker. but i have a question about skinned mesh renderer. after you combine all the skinned meshes, is the mesh is grouped all together? what i mean is, what if i want to make a zombie game, and i combine all their skinned mesh together, is all of them is counted as 1 gameobject, or do i have the freedom to move them individually?
     
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    When multiple skinned meshes are combined a new game object, mesh and skinned mesh renderer are created. The new mesh uses/shares the same bones (transforms) that the original skinned meshes used. Any scripts, animations, physics etc.. that affected the bones of the original skinned meshes will affect the combined mesh. You move the combined zombies around by moving the bones of the original zombies.
     
    konsnos likes this.
  33. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    173
    so what you said is, its possible to treat the prefab as 1, not as group? im not sure im explaining well, here it goes, a simple image to explain what i mean.
     

    Attached Files:

  34. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    573
    Perphaps this sounds dumb, but when i combine meshes the textures in the final result seem to be blurry and loose detail. What am i doing wrong
     
  35. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    You can move each zombie separately. This youtube video shows how it works (
    ). The separate zombies after being combined will be rendered by a single drawcall but they are each moved around by moving the original zombie bones. Moving the combined skin mesh game object will have no effect. You need to keep the original bones (transforms) for each zombie in the scene after combining, but you can delete the original skinned mesh renderer components from each zombie after the meshes have been combined.

    Does this make sense?
     
  36. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    There could be a few causes:

    Mesh Baker will scale the images to fit the maximum atlas size for the platform you are building for. This may be the problem.

    If there is tiling going on the Mesh Baker will try to bake the tiling. This can result in images that are larger than the maximum atlas size so they are scaled down.

    Textures in Unity have a "Max Size" setting in the inspector. This can be set to a low value even if the underlying image file is much larger. Check what this value is for the generated atlases. Try setting it to the maximum allowed size for your platform.

    Also check the console. Mesh Baker prints a lot of information about how the atlases were generated.
     
  37. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    573
    Thank you for your answer

    Textures in Unity have a "Max Size" setting in the inspector. This can be set to a low value even if the underlying image file is much larger. Check what this value is for the generated atlases. Try setting it to the maximum allowed size for your platform.

    where can i check these settings
     
  38. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    173
    Ahh thanks, that was what i wanted to know. Your video didnt tell that ;)
     
  39. Iegor-Malovanyi

    Iegor-Malovanyi

    Joined:
    Aug 30, 2014
    Posts:
    4
    Hey! I tried version 2.11.6 and had big problem with some objects, we see WARNING: has uvs outside the range (0,1) tex is tiled ....
    Option Fix Out-of-Bound is very-very-very bad.
    Are in new version of Mesh Baker (3.3) some updates of this thing ?
     
  40. DC2922

    DC2922

    Joined:
    Jun 19, 2013
    Posts:
    5
    Hi Does Mesh Beker 2 does not not support for unity 4.5. Cause its showing error message whenever I try to create new mesh baker.
    NullReferenceException: Object reference not set to an instance of an object
    MB2_MeshBakerEditorInternal.DrawGUI (.MB2_MeshBakerCommon target) (at Assets/ExternalPlugins/MeshBaker/scripts/Editor/MB2_MeshBakerEditorInternal.cs:137)
    MB2_MeshBakerEditorInternal.OnInspectorGUI (.MB2_MeshBakerCommon target) (at Assets/ExternalPlugins/MeshBaker/scripts/Editor/MB2_MeshBakerEditorInternal.cs:58)
    MB2_MultiMeshBakerEditor.OnInspectorGUI () (at Assets/ExternalPlugins/MeshBaker/scripts/Editor/MB2_MultiMeshBakerEditor.cs:43)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty)
    UnityEditor.DockArea:OnGUI()
     
  41. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    There are an number of updates, but not for the way that uvs outside the range 0..1 are handled. I would recommend checking the console. There should be some recommendations about how to handle your meshes. Also look at this video,
    . It covers how to combine meshes which use out of bounds UVs to tile.
     
  42. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    Hello, I need some assistance please! I purchased your Asset because I thought it would be very easy to select and add 100's of Game Objects into the Mesh Baker, and Simply Click Bake! But that has not been my experience thus far.

    I read some of the Documentation and Viewed a Few Videos to Understand the Basics, as I think that's all I really need to do for my Game Scene. I need to Select 100's of the Same Game Object Types and Bake them... but adding them to the Baker has been impossible for me to do...

    here is a sample screenshot of my issue... I am Selecting the Parent "Grasses" Object that has 100's of Child Grass Objects below it. I made sure to Set the "Using Shader" to the Shared Material "Grass_06" set my Lightmap Index, but when I click on "Add Selected Meshes" it only imports 5 Meshes out of 100's that are sharing that same Material... what gives? What am I doing Wrong?

     
  43. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    This was fixed several months ago. Do you have the latest version?
     
  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Check the console. There should be some messages similar to:

    "5 objects were excluded because they were not static"
    "3 objects were excluded because they were disabled"
    etc...


    This should explain why the objects were not added to the Mesh Baker.
     
  45. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    OK thank you! Everything seems to be flowing smoothly now... it took me a little to get the hang of how to use this, but so far so good. If i'm not mistaken I should hopefully be able to reduce my 6000 meshes in my scene down to 20! that's like 6000 Drawcalls vs 20 Drawcalls if each mesh is considered a draw call, then that's amazing! I look foward to providing you with the results! and looking forward to dramatically improving my game's Frame-rate. Lets see...
     
  46. Tristan-Moore

    Tristan-Moore

    Joined:
    Aug 22, 2014
    Posts:
    18
    Just picked up Mesh Baker, I'm super pleased with its results so far and it's been great for our performance. However, I've noticed that when I set up bakers using the Auto Generate Bakers tool it doesn't make the bakers for meshes that have multi-subobjects, even though the list correctly identifies them. Is this a planned feature or am I just missing something? It's currently pretty time consuming to make the bakers manually. That being said I think the toolset is awesome and that's my only gripe. Kudos on the good work.
     
  47. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    173
    Can't create prefab until all bones have been added to the combined mesh object GameObject (UnityEngine.GameObject) Add the bones then drag the combined mesh object to the prefab.

    how to add bones? could you do a tutorial about this. i cant see this part clearly.
     
  48. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    173
    Untitled-1.png i have added the animation component and copied object hierarchy into the empty prefab but still getting the error.
     
  49. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    173
    Hi, im still having trouble to saving the combined skin to prefab but as i read the docs, i have another concern.

    I am making a survival game with waves of monster. This require the gameobject to be instantiated and destroyed and instantiated again for the next wave. But from my understanding after i read the documentation, you can only use mesh baker for gameobjects that is saved in the scene, and you cant reuse it.

    Amirite
     
  50. HiroKiro

    HiroKiro

    Joined:
    Mar 17, 2014
    Posts:
    7
    Just purchased Mesh Baker 3.3 Today. I am running a i7 4930k 64 GB ram and GTX 780. When I hit "List Shaders in Scene" button it takes 15 minutes to list them or freezes . Is this Normal? I only have 10 different textures .

    Hiro