Search Unity

Mesh Baker by Digital Opus [RELEASED]

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

  1. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    [Simplified explanation, but should be close enough]

    Meshes are a set of X, Y and Z coordinates. Each vertex also has an X and Y coordinate for the UV coordinate which is used to map a texture to the mesh. One corner of the texture is 0,0 the other is 1,1.

    Atlases are collections of textures. MeshBaker also scales the U, V coordinates so that if 4 textures are together, the UV coordinates go from 0 to 0.5 for one texture, 0.5 to 1 for the next, etc. Scaling all of them to fit between 0 and 1.

    The meshes can use values greater than 1 to apply the texture multiple times to the object. This can make the object look clearer up close, but unless the texture is created right, it can be easy to spot the similar patterns as a checkerboard.

    If the base mesh uses UV values < 0 or > 1, then there is no easy way to put multiple textures into the atlas.

    I'm not sure what program you're using to generate the meshes, but there should be some way to require that it constrain the UV values to be between 0 and 1. You can also check the box that constrains the UV values to be between 0 and 1, but you might get funny looking results because of the scaling of the textures.

    Does Meshbaker tell you which texture/mesh has the issue?
     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Shinfo, the reason that MeshBaker does not automatically check "fix out of bounds UVs" when it finds outside the range 0..1 is because the user may want a different configuration depending on the situation. Some possible situations are:

    1. Many times the out of bounds UVs are only out by a tiny amount. This is essentially a false positive and good results can be obtained without using the "fix out of bounds UVs".
    2. The user may be combining meshes that all use the same texture and does not want the UVs adjusted.
    3. The tiling may work in x but not y or vice versa and the result can work depending on how the atlas is packed.
     
  3. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    You can always try to combine the meshes by adding your meshes to the list of objects to be combined. Mesh Baker does not prevent this however these meshes will not be added using the automatic tools.

    Meshes that have out of bounds UVs and multiple materials are usually very hard to combine. There are two approaches to combining these meshes:

    1. Combine only meshes that use the same textures and leave the out of bounds UVs (bake meshes with the same materials).
    2. Bake the tiling using the "fix-out-of-bounds-UVs" feature. There will probably be quality loss from the baked tiling.
     
  4. HH_M2tM

    HH_M2tM

    Joined:
    Jan 14, 2014
    Posts:
    1
    Hello! I am currently investigating use of Mesh Baker in a project involving a character customization system.

    This character customization system has multiple Skinned Mesh Renderers attached to a single skeleton, it seems like Mesh Baker has been implemented in such a way as to assume bone references are unique. In my case, I am dynamically adding skinned meshes to a single shared skeleton and as a result, there is an overlap of the bones they handle.

    I've been having quite a few issues, and it's taken me a while to come up with a question/request that can be concisely stated.

    One of the issues I've had is the following: "Bones do not match bindpose." I believe this error occurs because of the way bones are simply copied, instead of treated as a shared reference so multiple meshes can share a transform without having duplicitous copies of that original bone.

    I'm currently hacking my way around the code base to try and fix this issue. I do not currently have a solution, but having begun this task I feel like an official patch fixing this oversight would be beneficial for the community. I would love it if the author of Mesh Baker could investigate this implementation.

    My email is mhamilton@hotheadgames.com I'd be happy to correspond further with the issue and a possible solution!
     
  5. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    494
    This asset works great when it actually works, but so far in my experiments with it it causes unity to crash more than 50% of the times I try to use it. Half or more of the time that I try to bake materials into a combined material it crashes. About 1/4th of the time that I try to bake into a combined object it crashes. I've never really had unity crash on me much before but when using this I get a crash about every 5 minutes.

    I can't seem to copy the text in the box that pops up when it crashes, but if it helps you to make this asset better here's my most recent crash log from trying to combine multiple materials:

    Code (csharp):
    1. (Filename: Assets/MeshBaker/scripts/Editor/MB2_TextureCombinerEditorFunctions.cs Line: 141)
    2.  
    3. d3d: failed to create 2D texture id=6401 w=4096 h=4096 mips=13 d3dfmt=21 [out of memory]
    4. failed to create 2D texture
    5.  
    6. (Filename: C:/BuildAgent/work/d3d49558e4d408f4/Runtime/GfxDevice/d3d/TexturesD3D9.cpp Line: 309)
    7.  
    8. !texture.texture
    9.  
    10. (Filename: C:/BuildAgent/work/d3d49558e4d408f4/Runtime/GfxDevice/d3d/TexturesD3D9.cpp Line: 655)
    11.  
    12. DynamicHeapAllocator out of memory - Could not get memory for large allocationCould not allocate memory: System out of memory!
    13. Trying to allocate: 67108880B with 4 alignment. MemoryLabel: NewDelete
    14. Allocation happend at: Line:421 in C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Graphics/Image.cpp
    15. Memory overview
    16.  
    17.  
    18. [ ALLOC_DEFAULT ] used: 458346098B | peak: 0B | reserved: 489928538B
    19.  
    20. [ ALLOC_GFX ] used: 1301920437B | peak: 0B | reserved: 1323908936B
    21.  
    22. [ ALLOC_CACHEOBJECTS ] used: 1588768B | peak: 0B | reserved: 81788928B
    23.  
    24. [ ALLOC_TYPETREE ] used: 775376B | peak: 0B | reserved: 84934656B
    25.  
    26. [ ALLOC_PROFILER ] used: 509688B | peak: 0B | reserved: 8388608B
    27. Could not allocate memory: System out of memory!
    28. Trying to allocate: 67108880B with 4 alignment. MemoryLabel: NewDelete
    29. Allocation happend at: Line:421 in C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Graphics/Image.cpp
    30. Memory overview
    31.  
    32.  
    33. [ ALLOC_DEFAULT ] used: 458346098B | peak: 0B | reserved: 489928538B
    34.  
    35. [ ALLOC_GFX ] used: 1301920437B | peak: 0B | reserved: 1323908936B
    36.  
    37. [ ALLOC_CACHEOBJECTS ] used: 1588768B | peak: 0B | reserved: 81788928B
    38.  
    39. [ ALLOC_TYPETREE ] used: 775376B | peak: 0B | reserved: 84934656B
    40.  
    41. [ ALLOC_PROFILER ] used: 509688B | peak: 0B | reserved: 8388608B
    42.  
    43. UnityEngine.Texture2D:EncodeToPNG()
    44. DigitalOpus.MB.Core.MB2_EditorMethods:SaveAtlasToAssetDatabase(Texture2D, String, Int32, Material) (at Assets\MeshBaker\scripts\Editor\MB2_TextureCombinerEditorFunctions.cs:145)
    45. DigitalOpus.MB.Core.MB_TextureCombiner:__CreateAtlasesUnityTexturePacker(ProgressUpdateDelegate, Int32, List`1, List`1, Material, Texture2D[], MB2_EditorMethodsInterface, Int32) (at Assets\MeshBaker\scripts\core\MB_TextureCombiner.cs:629)
    46. DigitalOpus.MB.Core.MB_TextureCombiner:__Step3_BuildAndSaveAtlasesAndStoreResults(ProgressUpdateDelegate, List`1, List`1, Int32, MB2_EditorMethodsInterface, MB_AtlasesAndRects, Material) (at Assets\MeshBaker\scripts\core\MB_TextureCombiner.cs:440)
    47. DigitalOpus.MB.Core.MB_TextureCombiner:__combineTexturesIntoAtlases(ProgressUpdateDelegate, MB_AtlasesAndRects, Material, List`1, List`1, List`1, MB2_EditorMethodsInterface) (at Assets\MeshBaker\scripts\core\MB_TextureCombiner.cs:216)
    48. DigitalOpus.MB.Core.MB_TextureCombiner:_combineTexturesIntoAtlases(ProgressUpdateDelegate, MB_AtlasesAndRects, Material, List`1, List`1, MB2_EditorMethodsInterface) (at Assets\MeshBaker\scripts\core\MB_TextureCombiner.cs:179)
    49. DigitalOpus.MB.Core.MB_TextureCombiner:combineTexturesIntoAtlases(ProgressUpdateDelegate, MB_AtlasesAndRects, Material, List`1, List`1, Int32, List`1, Boolean, Boolean, Int32, Boolean, MB2_PackingAlgorithmEnum, MB2_EditorMethodsInterface) (at Assets\MeshBaker\scripts\core\MB_TextureCombiner.cs:101)
    50. MB2_TextureBaker:_CreateAtlases(ProgressUpdateDelegate, Boolean, MB2_EditorMethodsInterface) (at Assets\MeshBaker\scripts\MB2_TextureBaker.cs:175)
    51. MB2_TextureBaker:CreateAtlases(ProgressUpdateDelegate, Boolean, MB2_EditorMethodsInterface) (at Assets\MeshBaker\scripts\MB2_TextureBaker.cs:74)
    52. DigitalOpus.MB.Core.MB2_TextureBakerEditorInternal:DrawGUI(MB2_TextureBaker, Type) (at Assets\MeshBaker\scripts\Editor\MB2_TextureBakerEditorInternal.cs:174)
    53. MB2_TextureBakerEditor:OnInspectorGUI() (at Assets\MeshBaker\scripts\Editor\MB2_TextureBakerEditor.cs:22)
    54. UnityEditor.InspectorWindow:DrawEditors(Boolean, Editor[], Boolean) (at C:\BuildAgent\work\d3d49558e4d408f4\Editor\Mono\Inspector\InspectorWindow.cs:850)
    55. UnityEditor.InspectorWindow:OnGUI() (at C:\BuildAgent\work\d3d49558e4d408f4\Editor\Mono\Inspector\InspectorWindow.cs:270)
    56. System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception)
    57. System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    58. System.Reflection.MethodBase:Invoke(Object, Object[]) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    59. UnityEditor.HostView:Invoke(String, Object) (at C:\BuildAgent\work\d3d49558e4d408f4\Editor\Mono\GUI\DockArea.cs:231)
    60. UnityEditor.HostView:Invoke(String) (at C:\BuildAgent\work\d3d49558e4d408f4\Editor\Mono\GUI\DockArea.cs:224)
    61. UnityEditor.DockArea:OnGUI() (at C:\BuildAgent\work\d3d49558e4d408f4\Editor\Mono\GUI\DockArea.cs:661)
    62.  
    63. [C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Allocator/MemoryManager.cpp line 793]
    64. (Filename: Assets/MeshBaker/scripts/Editor/MB2_TextureCombinerEditorFunctions.cs Line: 145)
    65.  
    66.  
    67. *** Launching bug reporter due to fatal error!
    68. Full stack trace:
    69. StackWalker::ShowCallstackSimple
    70. GetStacktrace
    71. ExitDontLaunchBugReporter
    72. LaunchBugReporter
    73. EditorMonoConsole::LogToConsoleImplementation
    74. LogToConsoleImplementation
    75. DebugStringToFilePostprocessedStacktrace
    76. DebugStringToFile
    77. OutOfMemoryError
    78. MemoryManager::Allocate
    79. malloc_internal
    80. Image::Image
    81. ConvertImageToPNGBuffer
    82. Texture2D::EncodeToPNG
    83. Texture2D_CUSTOM_EncodeToPNG
    84.  (wrapper managed-to-native) UnityEngine.Texture2D:EncodeToPNG () + 0x75 (1BF2CB38 1BF2CBED) [09536D20 - Unity Child Domain]
    85.  DigitalOpus.MB.Core.MB2_EditorMethods:SaveAtlasToAssetDatabase (UnityEngine.Texture2D,string,int,UnityEngine.Material) + 0x3d5 (1BF2BEC8 1BF2C4F3) [09536D20 - Unity Child Domain]
    86.  DigitalOpus.MB.Core.MB_TextureCombiner:__CreateAtlasesUnityTexturePacker (DigitalOpus.MB.Core.ProgressUpdateDelegate,int,System.Collections.Generic.List`1<DigitalOpus.MB.Core.MB_TextureCombiner/MB_TexSet>,System.Collections.Generic.List`1<string>,UnityEngine.Material,UnityEngine.Texture2D[],DigitalOpus.MB.Core.MB2_EditorMethodsInterface,int) + 0x1982 (1BF28B50 1BF2A72C) [09536D20 - Unity Child Domain]
    87.  DigitalOpus.MB.Core.MB_TextureCombiner:__Step3_BuildAndSaveAtlasesAndStoreResults (DigitalOpus.MB.Core.ProgressUpdateDelegate,System.Collections.Generic.List`1<DigitalOpus.MB.Core.MB_TextureCombiner/MB_TexSet>,System.Collections.Generic.List`1<string>,int,DigitalOpus.MB.Core.MB2_EditorMethodsInterface,MB_AtlasesAndRects,UnityEngine.Material) + 0xe8e (1BF27258 1BF2899A) [09536D20 - Unity Child Domain]
    88.  DigitalOpus.MB.Core.MB_TextureCombiner:__combineTexturesIntoAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,MB_AtlasesAndRects,UnityEngine.Material,System.Collections.Generic.List`1<string>,System.Collections.Generic.List`1<UnityEngine.GameObject>,System.Collections.Generic.List`1<UnityEngine.Material>,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0x35a (1BF229C0 1BF22D36) [09536D20 - Unity Child Domain]
    89.  DigitalOpus.MB.Core.MB_TextureCombiner:_combineTexturesIntoAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,MB_AtlasesAndRects,UnityEngine.Material,System.Collections.Generic.List`1<UnityEngine.GameObject>,System.Collections.Generic.List`1<UnityEngine.Material>,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0x353 (1BF221F8 1BF226E8) [09536D20 - Unity Child Domain]
    90.  DigitalOpus.MB.Core.MB_TextureCombiner:combineTexturesIntoAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,MB_AtlasesAndRects,UnityEngine.Material,System.Collections.Generic.List`1<UnityEngine.GameObject>,System.Collections.Generic.List`1<UnityEngine.Material>,int,System.Collections.Generic.List`1<string>,bool,bool,int,bool,DigitalOpus.MB.Core.MB2_PackingAlgorithmEnum,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0xea (1BF220F0 1BF221E5) [09536D20 - Unity Child Domain]
    91.  MB2_TextureBaker:_CreateAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,bool,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0xb09 (1BF09EE0 1BF0ABB5) [09536D20 - Unity Child Domain]
    92.  MB2_TextureBaker:CreateAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,bool,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0x6a (1BF09B80 1BF09EC2) [09536D20 - Unity Child Domain]
    93.  DigitalOpus.MB.Core.MB2_TextureBakerEditorInternal:DrawGUI (MB2_TextureBaker,System.Type) + 0x1080 (1BED6B48 1BED7CBD) [09536D20 - Unity Child Domain]
    94.  MB2_TextureBakerEditor:OnInspectorGUI () + 0x77 (1BED6A90 1BED6B2E) [09536D20 - Unity Child Domain]
    95.  UnityEditor.InspectorWindow:DrawEditors (bool,UnityEditor.Editor[],bool) + 0x1591 (1BE6CC20 1BE6E834) [09536D20 - Unity Child Domain]
    96.  UnityEditor.InspectorWindow:OnGUI () + 0x1fd (1BE6C148 1BE6C4A3) [09536D20 - Unity Child Domain]
    97.  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (159AC1F8 159AC352) [09536D20 - Unity Child Domain]
    98. mono_jit_runtime_invoke
    99. mono_runtime_invoke
    100. mono_runtime_invoke_array
    101. ves_icall_InternalInvoke
    102.  (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception) + 0x90 (1599A3F8 1599A4C8) [09536D20 - Unity Child Domain]
    103.  System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) + 0x370 (15998FC0 15999418) [09536D20 - Unity Child Domain]
    104.  System.Reflection.MethodBase:Invoke (object,object[]) + 0x4d (15A54878 15A548D0) [09536D20 - Unity Child Domain]
    105.  UnityEditor.HostView:Invoke (string,object) + 0x6d (0BFC6948 0BFC69CC) [09536D20 - Unity Child Domain]
    106.  UnityEditor.HostView:Invoke (string) + 0x2f (0BFC68F0 0BFC6936) [09536D20 - Unity Child Domain]
    107.  UnityEditor.DockArea:OnGUI () + 0x1f48 (0C013430 0C015591) [09536D20 - Unity Child Domain]
    108.  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (159AC1F8 159AC352) [09536D20 - Unity Child Domain]
    109. mono_jit_runtime_invoke
    110. mono_runtime_invoke
    111. scripting_method_invoke
    112. ScriptingInvocationNoArgs::Invoke
    113. MonoBehaviour::DoGUI
    114. GUIView::OnInputEvent
    115. GUIView::ProcessEventMessages
    116. GUIView::GUIViewWndProc
    117. gapfnScSendMessage
    118. GetThreadDesktop
    119. CharPrevW
    120. DispatchMessageA
    121. std::vector<HaloManager::Halo,std::allocator<HaloManager::Halo> >::push_back
    122. WinMain
    123. strcpy_s
    124. BaseThreadInitThunk
    125. RtlInitializeExceptionChain
    126. RtlInitializeExceptionChain
    127.  
    128. Received abort signal from the operating system
    129.  
    130. *** Launching bug reporter due to fatal error!
    131. Full stack trace:
    132. StackWalker::ShowCallstackSimple
    133. GetStacktrace
    134. ExitDontLaunchBugReporter
    135. LaunchBugReporter
    136. HandleAbort
    137. abort
    138. EditorMonoConsole::LogToConsoleImplementation
    139. LogToConsoleImplementation
    140. DebugStringToFilePostprocessedStacktrace
    141. DebugStringToFile
    142. OutOfMemoryError
    143. MemoryManager::Allocate
    144. malloc_internal
    145. Image::Image
    146. ConvertImageToPNGBuffer
    147. Texture2D::EncodeToPNG
    148. Texture2D_CUSTOM_EncodeToPNG
    149.  (wrapper managed-to-native) UnityEngine.Texture2D:EncodeToPNG () + 0x75 (1BF2CB38 1BF2CBED) [09536D20 - Unity Child Domain]
    150.  DigitalOpus.MB.Core.MB2_EditorMethods:SaveAtlasToAssetDatabase (UnityEngine.Texture2D,string,int,UnityEngine.Material) + 0x3d5 (1BF2BEC8 1BF2C4F3) [09536D20 - Unity Child Domain]
    151.  DigitalOpus.MB.Core.MB_TextureCombiner:__CreateAtlasesUnityTexturePacker (DigitalOpus.MB.Core.ProgressUpdateDelegate,int,System.Collections.Generic.List`1<DigitalOpus.MB.Core.MB_TextureCombiner/MB_TexSet>,System.Collections.Generic.List`1<string>,UnityEngine.Material,UnityEngine.Texture2D[],DigitalOpus.MB.Core.MB2_EditorMethodsInterface,int) + 0x1982 (1BF28B50 1BF2A72C) [09536D20 - Unity Child Domain]
    152.  DigitalOpus.MB.Core.MB_TextureCombiner:__Step3_BuildAndSaveAtlasesAndStoreResults (DigitalOpus.MB.Core.ProgressUpdateDelegate,System.Collections.Generic.List`1<DigitalOpus.MB.Core.MB_TextureCombiner/MB_TexSet>,System.Collections.Generic.List`1<string>,int,DigitalOpus.MB.Core.MB2_EditorMethodsInterface,MB_AtlasesAndRects,UnityEngine.Material) + 0xe8e (1BF27258 1BF2899A) [09536D20 - Unity Child Domain]
    153.  DigitalOpus.MB.Core.MB_TextureCombiner:__combineTexturesIntoAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,MB_AtlasesAndRects,UnityEngine.Material,System.Collections.Generic.List`1<string>,System.Collections.Generic.List`1<UnityEngine.GameObject>,System.Collections.Generic.List`1<UnityEngine.Material>,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0x35a (1BF229C0 1BF22D36) [09536D20 - Unity Child Domain]
    154.  DigitalOpus.MB.Core.MB_TextureCombiner:_combineTexturesIntoAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,MB_AtlasesAndRects,UnityEngine.Material,System.Collections.Generic.List`1<UnityEngine.GameObject>,System.Collections.Generic.List`1<UnityEngine.Material>,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0x353 (1BF221F8 1BF226E8) [09536D20 - Unity Child Domain]
    155.  DigitalOpus.MB.Core.MB_TextureCombiner:combineTexturesIntoAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,MB_AtlasesAndRects,UnityEngine.Material,System.Collections.Generic.List`1<UnityEngine.GameObject>,System.Collections.Generic.List`1<UnityEngine.Material>,int,System.Collections.Generic.List`1<string>,bool,bool,int,bool,DigitalOpus.MB.Core.MB2_PackingAlgorithmEnum,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0xea (1BF220F0 1BF221E5) [09536D20 - Unity Child Domain]
    156.  MB2_TextureBaker:_CreateAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,bool,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0xb09 (1BF09EE0 1BF0ABB5) [09536D20 - Unity Child Domain]
    157.  MB2_TextureBaker:CreateAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate,bool,DigitalOpus.MB.Core.MB2_EditorMethodsInterface) + 0x6a (1BF09B80 1BF09EC2) [09536D20 - Unity Child Domain]
    158.  DigitalOpus.MB.Core.MB2_TextureBakerEditorInternal:DrawGUI (MB2_TextureBaker,System.Type) + 0x1080 (1BED6B48 1BED7CBD) [09536D20 - Unity Child Domain]
    159.  MB2_TextureBakerEditor:OnInspectorGUI () + 0x77 (1BED6A90 1BED6B2E) [09536D20 - Unity Child Domain]
    160.  UnityEditor.InspectorWindow:DrawEditors (bool,UnityEditor.Editor[],bool) + 0x1591 (1BE6CC20 1BE6E834) [09536D20 - Unity Child Domain]
    161.  UnityEditor.InspectorWindow:OnGUI () + 0x1fd (1BE6C148 1BE6C4A3) [09536D20 - Unity Child Domain]
    162.  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (159AC1F8 159AC352) [09536D20 - Unity Child Domain]
    163. mono_jit_runtime_invoke
    164. mono_runtime_invoke
    165. mono_runtime_invoke_array
    166. ves_icall_InternalInvoke
    167.  (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception) + 0x90 (1599A3F8 1599A4C8) [09536D20 - Unity Child Domain]
    168.  System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) + 0x370 (15998FC0 15999418) [09536D20 - Unity Child Domain]
    169.  System.Reflection.MethodBase:Invoke (object,object[]) + 0x4d (15A54878 15A548D0) [09536D20 - Unity Child Domain]
    170.  UnityEditor.HostView:Invoke (string,object) + 0x6d (0BFC6948 0BFC69CC) [09536D20 - Unity Child Domain]
    171.  UnityEditor.HostView:Invoke (string) + 0x2f (0BFC68F0 0BFC6936) [09536D20 - Unity Child Domain]
    172.  UnityEditor.DockArea:OnGUI () + 0x1f48 (0C013430 0C015591) [09536D20 - Unity Child Domain]
    173.  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (159AC1F8 159AC352) [09536D20 - Unity Child Domain]
    174. mono_jit_runtime_invoke
    175. mono_runtime_invoke
    176. scripting_method_invoke
    177. ScriptingInvocationNoArgs::Invoke
    178. MonoBehaviour::DoGUI
    179. GUIView::OnInputEvent
    180. GUIView::ProcessEventMessages
    181. GUIView::GUIViewWndProc
    182. gapfnScSendMessage
    183. GetThreadDesktop
    184. CharPrevW
    185. DispatchMessageA
    186. std::vector<HaloManager::Halo,std::allocator<HaloManager::Halo> >::push_back
    187. WinMain
    188. strcpy_s
    189. BaseThreadInitThunk
    190. RtlInitializeExceptionChain
    191. RtlInitializeExceptionChain
    192.  
    193.  
     
  6. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Thanks for the information. You are definitely running out of memory. By any chance are you using the "Unity Texture Packer"? I have had a lot of memory problems with the Unity Texture Paker. The Mesh Baker texture packer is much more efficient. Also can you let me know which version of Unity and Mesh Baker you are using?

    Thanks.
     
  7. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    494
    I'm not using Texture Packer. I have Cruncher in a project with it but I don't think I've used Mesh Baker to combine anything I've used that on. I'm using Mesh Baker 2.11.6 and Unity 4.3.2.
     
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Let me clarify. There is a field in the Mesh Baker inspector called "Texture Packer". It has two options, "Unity's Texture Packer" and "Mesh Baker Texture Packer".

    I have had a lot of memory problems with the "Untity's Texture Packer" option. Please check if you are using that option and try "Mesh Baker Texture Packer" if so. Please let me know if you get crashes using the "Mesh Baker Texture Packer" option. I have tested this extensively and have not seen any crashes even with giant atlases (can combine 16 x 4096 textures).

    I am puzzled with your report of crashes when combining the meshes. I have never had this happen and this is the first report from a user of this happening. If it is possible to create a reproducible case could you let me know and possibly send me the case?

    Thanks.
     
  9. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    I tried out the demo of mesh baker and I've now tried to remove it (it seems like an excellent tool just not particularly for my needs) and its ghost is haunting my project. The MeshBaker folder keeps creating itself in my Assets, and it throws typeloadexception errors in the console. Would anyone happen to know what I have to do to make it go away?
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I would try the following:

    Restart editor, DON'T PRESS PLAY. Delete MeshBaker folder. Restart editor

    If that doesn't work I would shut down the editor. Delete everything in Library/ScriptAssemblies folder, Delete the MeshBaker folder and restart the editor.

    If that doesn't work, try turning on non-hidden meta files and delete the meta file as well as the mesh baker folder. Then reimport all.
     
  11. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Thanks a ton Phong. It looks like the first one worked for me.
     
  12. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    494
    I found the option you mentioned and with Mesh Baker Texture Packer selected it doesn't crash nearly so often. I was able to combine some objects that caused crashes before. It does still crash occasionally though, and many times it will seem as though it's combining the objects and it creates the final combined object but it's an empty object with an empty mesh and there will be an 'Array Out of Bounds' warning.

    Just as a side note, most of the things I've attempted to combine with this are from the Fantasy Megapack asset available here: https://www.assetstore.unity3d.com/#/content/8355 The buildings in that pack are extremely high-poly and use a multitude of textures per building. Thought I'd link it on the slim chance that you may have that asset to experiment on.

    Here's a screenshot from the most recent crash, coming from attempting to combine two of the buildings from that asset pack: http://oi61.tinypic.com/2gy165s.jpg
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I will investigate to see if I can discover what is going on. Are the crashes you now experience happening on the texture packing side or on the mesh combining side? Also do you know what channels and options are checked?

    I suspect that the meshes are exceeding the 64k limit. Mesh Baker tries to check this, but I have run into strange problems. For example if "generate uv2" is used unity can split vertices which can push it over the 64k limit.
     
  14. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Managed to get passed the PITA uv errors by using Multi-Mesh Material Baker for the material, but no matter what I use, I can't get it to output an actual combined mesh. Just created an empty object in the hierarchy called "CombinedMesh-MeshBaker0".
     
  15. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Could you post or email the output from the console?
     
  16. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    I managed to get past that issue, but now I've found it's rendering the textures wrong I guess? In some spots, the texture is rendered on the wrong face, so for a wall that has, essentially, two planes (for depth), it's rendering both on the back side. If that mades sense.
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Do any of the source meshes have negative scale? If so I would suggest flipping the scale on the source, combining, then flipping the scale on the result and the source.
     
  18. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Hi Phong,

    I purchased Mesh Baker around the time it came out and only now really need to use it, Ive been combining some meshes then came to some half columns that I want to combine and it looks like the norms are flipped, pics below, is there a quick and easy solution to correct this?

    1st picture the column
    2nd picture the combined mesh
    3rd picture the combined mesh rotated 180 degrees

    Thanks.

    $Screen Shot_01.jpg $Screen Shot_02.jpg $Screen Shot_03.jpg
     
  19. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Do the source columns have a negative scale somewhere? That is probably the problem. Negative scale is very hard to deal with since it gets combined with rotation. Fix it in the source model if you can. In your case it looks like you could set it to positive before baking with no ill effect.
     
  20. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Thanks, that sorted my problem out.
     
  21. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    Got an interesting problem here. I have a set of characters, which I'm baking to use the same set of color swatches. All of them baked just fine, until - naturally - I get to the very last one. She's giving me some odd issues. Her model isn't any different from the other characters (aside from looking different), and my baking technique for her is the same. I say this to say that the setup I have is working fine, which means there is probably something bad about the model. Though right now I'm not sure where to start looking.

    Here is the set of errors I get right after attempting to bake:

    Obviously there is something funky here involving transforms. :) Though since the setup is, from what I can tell, the same as the other characters, I'm not really sure what the issue is. Does anyone have any pointers, or might I be able to send a sample project with the character and meshbake setup to someone to take a look at and determine what I might have done wrong?

    Thanks in advance!
     
  22. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    I've got another problem, when light mapping some mesh baked objects I'm getting dark squares, any ideas?

    Thanks.

    $Screen Shot_01.jpg $Screen Shot_02.jpg $Screen Shot_03.jpg
     
  23. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Strange, one side light spots, other side dark spots ..

    $Screen Shot_02.jpg $Screen Shot_01.jpg

    $Screen Shot_03.jpg
     
  24. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hello,

    This is a guess on my part but I think the problem may be that the MeshBaker object was created by duplicating another mesh baker object after that object has baked a mesh. This is a problem because the duplicated baker retains a reference to the mesh in the original baker and tries to re-use it. Another user made me aware of this issue recently and I hope to have a fix for it soon.

    I would try re-creating and re-setting up the MB2_MeshBaker component.

    Please let me know if that does not work.
     
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
  26. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    I've tried both, but I want to light map after baking ..
     
  27. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Griffo, I have tried experimenting with the various lightmap options and can't see anything wrong. Things appear to be working in all my tests. I would try the following:

    0) Always delete the combined mesh game object before baking.

    1) Always check the log after baking.

    2) Preserving existing lighmapping will not work if the source objects use different lightmaps (have different lightmap indexes). There will be warnings if this is the case.

    3) If you want to lightmap after baking then I would try "generate new UV2 layout". Before baking delete the combined mesh object. After baking set the combined mesh game object to "static". Disable renderers on source objects and rebake the lightmap. This is the most reliable option. Please let me know if this does not work.

    4) You could try the "ignore lightmapping". If you use this option then Mesh Baker does not assign anything to the UV2 channel after clearing the mesh. However in my tests it appears that Unity generates a UV2 channel when vertices are assigned. I don't know what values Unity uses for this so I can't really predict what the results for this will be.

    5) You could try the "copy UV2 unchanged". There is a good chance this won't work. Since the UV2s normally need tweaking to work correctly.

    6) You may want to experiment with deleting and recreating the "MeshRenderer" component on the combined mesh before baking the lightmap. There are some posts in the forums describing sticky lightmap settings in the renderer that affect re-baking of lightmaps.
     
  28. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    Phong,

    The object was actually a fresh model imported into Unity. Though aside from that, I've recreated the mesh baker objects numerous times and it makes no change. I've also tried re-saving the model from 3DS Max and re-importing it with various adjustments and still get the same errors.
     
  29. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Phong,

    I had a column made up of 4 parts, and 8 columns, so I baked 1 column into 1 mesh, I then baked the 8 columns into 1 mesh setting "generate new UV2 layout" I've light mapped the new mesh and this time no strange dark or light bits.

    Thanks for the help.
     
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Dave, I had a look at the model you sent and can't generate the errors you are seeing. It appears to be baking correctly for me. Looking at the first error, it looks like a problem building the prefab. If baking into a prefab I would suggest deleting the old prefab and creating a new one. Make sure to drag the asset to the combined mesh prefab field not a scene object.

    Let me know if this helps.
     
  31. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi Phong,

    I'm trying to use Mesh Baker in my current project and would love some guidance. I'm using the latest version of Unity Pro and have a game where characters (skinned mesh renderers) are being spawned. Within a given level, I will have 4 various enemies spawn and be systematically killed by the player. In this situation, does it make sense for me to bake the skinned meshes of the 4 various enemies in a given level?

    If so, how exactly should I do this? I have followed the video tutorial and documentation and created a combined skinned mesh renderer baker object. I have left this off the screen. Now, when I spawn one of my enemy unit prefabs ... is it actually using that baked mesh and material or not? I really can't tell as when I click on the unit in the editor during a game, it just shows it as using the original material ... as far as I can tell. Please advise.

    Secondly, when baking, does it remove the light maps that have been baked? I tested it on one of my levels by baking the background objects and I saw that the light maps were affected. Is there a way around this? If I have light maps baked in my scene, is there a different option I should be selecting when mesh baking?
     
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    If the four enemies spend much of the time visible together then it makes sense to bake them since it will save 3 drawcalls. If only one is visible at a time then it would be more efficient to leave them separate as the non-visible enemies will not be animated and there will be a lot less skinning.

    If by "spawn" you mean "instantiate" then it will not be using the combined skinned mesh. If you spawn by moving the bones of your source object onto the screen then you will be using the combined mesh.

    I would recommend using a script to add and remove from the combined mesh as part of the spawn process. The skinned mesh example scene does this.

    Make sure you are baking all the channels your meshes will need and check the console for errors and warnings.

    Lightmaps are tricky. One approach is to preserve existing lightmapping. Lightmaps can be preserved if all the source objects use the same lightmap index. You need to set the lightmap option to "preserve existing lightmapping". In my tests this works although I have had some users report problems. I have not yet been able to track down what works and what doesn't. Please let me know if this works or doesn't.

    Another approach is to lightmap after baking. To do this you want to use the "Generate new UV2 Layout". Then you bake the lightmap using the combined mesh. This should always work.

    The other option "leave UV2 unchanged" most likely will not work.
     
  33. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Thanks for the clarification. I'll take a look at the example scene and will experiment with lightmap baking as you mention.
     
  34. ilya_ca

    ilya_ca

    Joined:
    Nov 19, 2011
    Posts:
    274
    Hi, does Mesh Baker work with Unity's LOD system? Is it possible to create only texture atlases without combining meshes (so that Unity itself will do static batching)?

    Thanks.
     
    Last edited: Apr 27, 2014
  35. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Yes, the feature is called "Bake Meshes In Place". It bakes texture atlases and creates modified versions of the meshes with UVs adjusted to use the texture atlases. You can then replace the new material and mesh on your game object to take advantage of static/dynamic batching.
     
  36. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Been using your mesh baker 2 for like a year now I think? Great tool, has proven very reliable so far.

    Theres one thing thought that is annoying me and that is. If any of your game objects have a negative scale, when you bake them into a single mesh, that object will have it's normals inverted. Having to go back and manually reflip faces, or having to flatten all my instances is kind of cumbersome.
     
  37. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Thanks for the feedback. As it happens I have been working on this and should have a fix in the next version which should come out at the end of this week or next week some time. It is actually a hard problem because the scale gets mingled with rotation. It took some research to discover how to detect if the mesh has been inverted or not.
     
  38. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    This sounds very interesting. In my current project, I have several 3d character models that are fairly inefficient as they have different meshes and materials for things like armour pieces and jewelery. I'd like to have that all be combined into a single mesh and material (using a texture atlas). As I mentioned earlier, I instantiate these characters during the game from prefabs.

    Can you explain how exactly I should use mesh baker to combine it? I'm still a little unclear on the steps.
     
  39. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Also, when I use the meshbaker rect packer, set with my target to iPhone, it says the target max resolution is 2048 and packs my textures down to 2048. I've hack the code to force 4096, but it'd be nice if you changed it to to do it automatically.

    Also, I don't want to request crazy amounts of features, so in the requests i just want you to know I am putting a good amount of thought into it.

    I notice internally you use the Collada exporter. I'd be cool if as a mesh output you could specify a place for it to save a .dae file out. I am actually using a workflow where I use mesh baked to combine meshes in Unity, then export this out to Modo to bake lightmaps, and import it back.

    Another feature that would be really useful, and this partially goes in line with your LOD system I think, maybe you could add it to that instead. But being able to manually specify combines 'zones'. So I can place a box, or even a mesh, then everything inside of the bounds of that will be combined into a single mesh. Then I could load in one or more CombinedMaterial objects to the zone combiners, then it would combine all the meshes in a zone, then put out a separate mesh for each CombinedMaterial that was loaded into it.
     
    Last edited: Apr 29, 2014
  40. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    There are a couple of example scenes that do almost exactly what you are describing. The SkinnedMeshRendererSetup example scene builds an atlas and a combined material that uses that atlas. The SkinnedMeshRenderer scene uses the atlas built in the first scene and combines several skinned meshes together into a single skinned mesh. It also has a GUI allowing the users to add and remove objects (a hat, a sword and glasses) to the skinned mesh dynamically. The script is very simple, only 100 lines of code.
     
  41. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Mesh Baker 3 has been released. It should be live in the Asset Store shortly. This version is a big cleanup and refactor of the code. It is something I have wanted to do for a long time but have been avoiding because the changes require changing how settings are stored in the components and would cause everyone’s components to forget their settings. This problem has been dealt with by creating a new set of components and classes (“MB3_” classes). The old (“MB2_” classes) are still available but I will not add new features or fix bugs with them. A button has been added to the inspector of the MB2_ classes for upgrading to the new MB3_ components. I would encourage everyone to switch to the "MB3_" version of the classes.
     
  42. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Hello,

    I've looked over the manual for Mesh Baker and didn't see the answer. If I use the Mesh Baker on a number of skin rendered objects. If I deactivate/reactivate them in the game at runtime, will that make them appear and disappear if they were part of the large baked texture? I'm assuming they won't and I have to explicitly add/remove them using your API, or change their transform (to move them from the camera view) and use your update API.

    When I say deactivate and reactivate I'm referring to unity native object enable and disable methods.

    My concern is that the dynamic object will have to disappear when player touches them and am concerned with performance of adding/removing or moving them using mesh baker API.

    Target platform is iPhone 4s, FYI for context of my concern.

    Thanks in advance for any info you can provide.
     
    Last edited: May 12, 2014
  43. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    You are correct. You will need to either move the bones offscreen or use the API to remove the mesh from the combined mesh.

    The performance is very good. You wouldn't want to do this every frame but you can easily bake a 20k vertex mesh occasionally without a noticeable change in the frame rate. You can also call AddDelete in one frame and Apply in the next frame to spread the load across two frames.

    This will work fine on iPhone 4s. You could try experimenting with the Skinned Mesh Renderer example scene as it does add/delete from skinned mesh at runtime to see what performance would be like.
     
  44. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thank You. I'll give it a go. :)
     
  45. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Hello again,

    So I purchased the package and am trying various tests. In the documentation there is the following statement:

    If you want to move objects around almost every frame then consider baking into a SkinnedMeshRenderer. It is much faster than Update.

    I was wondering if you could expand on what this means.

    Tom
     
  46. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Mesh baker can bake MeshFilter objects together into a skinned mesh. This is useful when you have several objects that:

    • Have materials that have been combined into an atlas
    • Move independently of each other
    • Don't have a huge number of vertices
    • Are likely to be on screen together

    For example imagine a machine with a dozen different gears and pistons. Normally each piece would require at least one drawcall. You could combine the entire thing into a skinned mesh. This would incur the overhead of a skinned mesh but would reduce the drawcalls from 12 to 1.

    Another example might be a Christmas tree with dozens of ornaments. You want the ornaments to fall when the tree is shaken. This would normally take dozens of drawcalls but if you combine the whole thing into a skinned mesh then it could be reduced to one drawcall.

    If you want to get really fancy, you could bake the Christmas tree into a MeshRenderer when it is not being shaken. Then switch it to a SkinnedMesh when it is being shaken, and switch it back to a MeshRenderer when it everything has stopped moving.

    This is much like dynamic batching but the performance is better and it is more flexible.
     
    Last edited: May 16, 2014
  47. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    I understand. Thank You.
     
  48. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    I'm seeing an improvement of about 15 frames from before. So very good results. However because of the nature of my game I am now loosing the culling benefits. I was wondering if you have a suggestion on how I can achieve what I'm looking for using mesh baker.

    I have a plane and many skinned objects of the same type on it. Before mesh baker the objects that were not seen by the camera were culled. Now after I use the baker they are all one mesh and are all drawn. What I was thinking of doing is instead of baking them all in one huge texture, bake several smaller groups. This way I still take down the number of draw calls but will get some of the culling. Especially if you imagine the plane wrapped aground a cube for example and camera only looking a two of the faces at any given time as it rotates around the cube. The objects on the other two faces behind the cube could be drawn with two different textures and this way both textures could be culled. So each cube face would be a separate texture. I'm using the cube as an example only. I hope this explanation makes sense...

    So if I continue with the cube example. Using mesh baker I created one large texture for the whole cube and lost culling behind the cube. So I figured I will create a mesh baker object for each cube face and add the appropriate objects to it creating a separate texture for each face. This however is not working for me because I think the mesh baker objects are conflicting with each other somehow. The objects are added dynamically and are not present at the start of the scene. You know mesh baker obviously inside out so was wondering if you have a suggestion on how I can achieve my goal, or if you have any other suggestions.

    Thank you.

    Tom
     
    Last edited: May 18, 2014
  49. Phong

    Phong

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

    I don't think the faces on the back side of the cube will be culled. The reason is that fustrum culling compares the bounding box of each mesh against the camera fustrum. Even though the faces you describe are back facing, the bounding box containing them will still intersect the camera fustrum so they will be rendered.

    Mesh Baker should be able to handle what you are describing. You could also still use one large shared texture. You can have multiple different MeshBaker components using the same output from a TextureBaker. You can bake your objects into smaller groups.

    You mention that you have many skinned objects of the same type. Could you have a small pool of skinned renderers and move them into position each time an object becomes visible. Non-visible game objects would still have colliders and scripts running but no renderer associated with them.
     
  50. pleribus77

    pleribus77

    Joined:
    Jul 9, 2013
    Posts:
    36
    Is MeshBaker3 compatible with MeshBaker LOD?

    Bought MeshBaker LOD but think there is an issue, as LOD_Manager is asking for a MeshBaker instance (MB2_ ) where all the new classes have (MB3_).

    How do I go about getting a copy of MB2_ Mesh Baker?