Search Unity

Mesh Baker by Digital Opus [RELEASED]

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

  1. Deleted User

    Deleted User

    Guest

    Hello, do you support meshes with UV>1 ?

    Thank you.
     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    As long as you are generating the same channels in the combined mesh as in the source mesh then this should work. What error are you getting?
    Currently the only way is to add/delete from the combined mesh. It is in the future plans to write a show/hide which would remove or add the triangles for a mesh but leave the vertices in the combined mesh. Doesn't exist yet however.
    The entire combined mesh shares the same shared material (which is the whole purpose of baking). There is not way to apply a highlight color to just a part of it.
    Currently there are no plans, although if you would like to send me some suggestions I would consider adding it.
    I started to look into it but then got distracted and didn't finish. The combined meshes generated by MeshBaker are pretty much clones of the original meshes with UVs altered to work with an atlas instead of a texture. So it should work unless Skyshop makes heavy use of tiling which doesn't work well with atlases.
     
    Last edited: Jun 24, 2013
  3. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Yes. you can look through the docs at http://www.digitalopus.ca/site/mesh-baker/. MeshBaker treats it like tiling. There is a "fix out of bounds uvs" option that bakes the tiling into the atlas (can make atlases large) and scales the UVs to they are in the range 0..1. Or you can leave the out of bounds UVs unaltered this works when combining many objects that use the same material.
     
  4. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Yes!! Been waiting on a sale to jump in! :)
     
  5. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Use the cubes in the "list of objects to combine" in the MB2_TextureBaker component but omit them from the list on the MB2_MultiMeshBaker component (uncheck the use same as texture baker) option and edit the custom list of objects. You can even bake the textures in a separate scene and use the combined material asset in this one.
     
  6. lh

    lh

    Joined:
    Dec 20, 2012
    Posts:
    10
    Hi, Phong. When some objects have missing materials and I use the "List Shaders in Scene" function, I get this error:

    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. MB_MeshBakerEditorWindow+_GameObjectAndWarning.CompareTo (System.Object obj) (at Assets/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:359)
    3. System.Collections.Generic.Comparer`1+DefaultComparer[MB_MeshBakerEditorWindow+_GameObjectAndWarning].Compare (._GameObjectAndWarning x, ._GameObjectAndWarning y)
    4. System.Array.compare[_GameObjectAndWarning] (._GameObjectAndWarning value1, ._GameObjectAndWarning value2, IComparer`1 comparer)
    5. System.Array.qsort[_GameObjectAndWarning,_GameObjectAndWarning] (._GameObjectAndWarning[] keys, ._GameObjectAndWarning[] items, Int32 low0, Int32 high0, IComparer`1 comparer)
    6. System.Array.qsort[_GameObjectAndWarning,_GameObjectAndWarning] (._GameObjectAndWarning[] keys, ._GameObjectAndWarning[] items, Int32 low0, Int32 high0, IComparer`1 comparer)
    7. System.Array.Sort[_GameObjectAndWarning,_GameObjectAndWarning] (._GameObjectAndWarning[] keys, ._GameObjectAndWarning[] items, Int32 index, Int32 length, IComparer`1 comparer)
    8. Rethrow as InvalidOperationException: The comparer threw an exception.
    9. System.Array.Sort[_GameObjectAndWarning,_GameObjectAndWarning] (._GameObjectAndWarning[] keys, ._GameObjectAndWarning[] items, Int32 index, Int32 length, IComparer`1 comparer)
    10. System.Array.Sort[_GameObjectAndWarning] (._GameObjectAndWarning[] array, Int32 index, Int32 length, IComparer`1 comparer)
    11. System.Collections.Generic.List`1[MB_MeshBakerEditorWindow+_GameObjectAndWarning].Sort ()
    12. 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/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:543)
    13. MB_MeshBakerEditorWindow.listMaterialsInScene (Boolean generateMeshBakers) (at Assets/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:465)
    14. MB_MeshBakerEditorWindow.OnGUI () (at Assets/MeshBaker/scripts/Editor/MB_MeshBakerEditorWindow.cs:54)
    15. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    I replaced the relevant code with this:
    Code (csharp):
    1.                 //compare shaders
    2.                 int shaderCompare = (shader == null ? "null" : shader.ToString()).CompareTo(gobj.shader == null ? "null" : gobj.shader.ToString());
    3.                 if (shaderCompare != 0){
    4.                     return shaderCompare;  
    5.                 }
    6.                
    7.                 //compare materials
    8.                 int materialCompare = (material == null ? "null" : material.ToString()).CompareTo(gobj.material.ToString());
    9.                 if (materialCompare != 0){
    10.                     return materialCompare;
    11.                 }
    You may want to change this to print a warning/error, or exclude those meshes. It's not so nice to just throw an exception. Thanks!
     
  7. Rico21745

    Rico21745

    Joined:
    Apr 25, 2012
    Posts:
    409
    I was thinking about buying during the sale but tried the free edition and couldn't get baking to work properly. The baked objects did not seem to have the UVs created correctly so the textures on them ended up being some weird blurry/garbled mess.

    Best of luck though, maybe it just won't work for my project. Glad I was able to find out prior to buying. Perhaps this is something with the free version, but I'm not willing to gamble based on that.
     
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Did you check the console for warnings? If there is a problem there are almost always warnings in the console. There are a number of things that can make meshes hard to combine with other meshes. (tiling, submeshes sharing vertices, UVs outside the range 0..1). I would suggest looking at the warnings and looking at the documentation to see what can be done about it.
     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Thanks for your feedback! Good suggestion. I will try to add it tomorrow.
     
  10. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Mesh baker is taking quite long to just combine 19 materials. Is there reason why this would happen? Always freezes on "Resizing texture" then completely fails to combine the materials.
     
  11. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    4. As I am integrating MeshBaker more and more into the existing project, there's more and more need for more flexibility and speed requirements. Currently MeshBaker is very slow in Combining and Updating Meshes. Would it be possible to integrate LOOM Multithreading into Meshbaker to make MeshBaker really robust? Do you have plans to include LOOM as an option in the future? If not, can you suggest what would be the best way to integrate LOOM so that future updates of MeshBaker would not break custom integration.

    Currently there are no plans, although if you would like to send me some suggestions I would consider adding it.

    May I suggest a starting place for Loom Integration would be to improve the Mesh Combining/Updating.

    1. Improve Combining/Updating meshes so that Meshbaker objects can be used just like the "Original" objects. This makes the Great features of MeshBaker truly transparent with less pains of combining/updating.
     
  12. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Are there any errors or warnings in the console? Is it crashing or just failing to combine the materials? If it is crashing it is probably that the collection of source textures is simple too large to combine. MeshBaker prints out an "estimated texture minimum size" in the console after collecting the textures and before baking. If this is larger than 4000 - 5000 then you are probably running out of memory and will need to bake fewer materials or reduce the size of some of the source textures.

    If the problem is that some of the atlases are missing then you need to set the shader on the result material.
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Rocki, I am not sure what you mean by "Original" objects. Do you mean using combined meshes as source meshes in another bake?
     
  14. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hmm, that's kind of unfortunate. All my tile textures are 512x512. What's the optimal size to use?

    Errors:
    This one is new (or I didnt read it completely the first few times):

     
    Last edited: Jun 25, 2013
  15. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    The size of individual textures doesn't matter. Its the size of all of them together that is the problem.


    Ahh, you got the infamous UnityEngine.MissingReferenceException. This is a bug that showed up in 4.1. It appears that if Unity is in danger of running out of memory the garbage collector destroys Texture2D instance objects even if a script is still using them! I have submitted a bug to Unity but it hasn't been fixed yet. There is nothing further I can do to fix this one. There are a few options:

    avoid scenarios that trigger resizing (these cause an extra Texture2D instance to be created)
    Resize your source textures so they are padding * 2 smaller than a power of two
    Fewer or smaller source textures / materials.
    Avoiding tiling or reducing the number of textures in a bake that are tiled.

    Another approach is you can export your materials, import them into Unity 4.0 or earlier (you don't have to export your models, you can put the materials on placeholder cubes). Bake the textures there then export the combined material and atlases back to your current version. This is a major pain unfortunately but does work if you are desparate.

    You should be able to ignore the warnings about the texture formats. They are just to inform you that Mesh Baker is changing the format of your textures so it can read and resize them. Mesh Baker restores the format at the end of the bake.
     
    Last edited: Jun 25, 2013
  16. EmeralLotus

    EmeralLotus

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

    "Original" means that whatever we can do with the non-combined objects like transforming, rotating, scaling without having to worry about the speed problem with the Combined Version.
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Ahh, have you tried baking your ordinary MeshRender objects into a skinned mesh renderer? This behaves exactly as you describe. You can move, rotate scale the source objects (with renderers disabled) and the combined mesh responds as if the source objects were being moved. This is much faster than using MeshBaker.Update because the SkinnedMeshRenderer internally uses optimized C++ code which can directly access the internals of the Mesh class. If you want to update the position/rotation/scale of objects every frame this is the way to go.
     
  18. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    I just tried this technique on mobile Ipad1 and it performs better than MeshBaker.Update. Only thing is that it's still far from the speed of the source object also, when the object has more geometry, it's gets worse.

    I think your suggestion of turning on/off the triangles in the combined mesh is really great.

    It would be a perfect solution to get the fast interaction without having to use Loom.

    To move an object, I can turn OFF the triangles for that object in the combined mesh, turn on the source object renderer. After moving I can turn ON the triangles and switch off the renderer.

    This would be a Fantastic Feature. The ability to Hide/Show individual object in the combined mesh. This will also save lots of combine/ uncombined CPU.

    Additionally, when we need to highlight individual objects ( very common behaviour), we can do the same thing without having to incur the performance hit of combine/uncombine.
     
    Last edited: Jun 26, 2013
  19. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I will try to add this over the next few days.
     
  20. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    I just picked up this package.

    I'm creating a hex grid programatically on the fly, so doing anything in the editor is out :(.

    Am I correct in thinking that if I want to merge several material which have different shaders, I'm going to have to walk though all the material and see which shaders they have and set them up in the resultmaterials before I can do anything? I'll also have to keep track of which meshes use which materials to be able to pass these to the meshmaker?

    Am I missing anything here?

    Any suggestions on troubleshooting? I'm doing what I think is right and passing a bunch of gameobjects into the routine, but the display coming out is all white. :(

    Is there any way to tell it to just combine meshes but not combine textures? I didn't see a way but I thought I'd ask.

    Thanks,
    Ralph
     
  21. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    OK, I tried that and must have done something wrong :(

    For now I'm setting up 4 separate MeshBaker instances, one per shader, And, I've hit my next problem :(

    I guess I'm getting this error because the hexes are being instanced? Here is how they're created.
    Code (csharp):
    1.                         Map.Add(Instantiate(HexList[0], Vector3.zero, Quaternion.identity) as GameObject);
    2.  

    Here is where the error happens.
    Code (csharp):
    1.                     if (mat.name.Contains("(Instance)")){
    2.                         Debug.LogWarning("The sharedMaterial on object " + mc.name + " has been 'Instanced'. This was probably caused by a script accessing the meshRender.material property in the editor. " +
    3.                                        " The material to UV Rectangle mapping will be incorrect. To fix this recreate the object from its prefab or re-assign its material from the correct asset.");
    Since I'm creating them programatically, I can't do what the error suggests.

    Being a programmer, the first thing I tried was commenting out the warning ;) It 'sort of'' works now, the material is displayed, but it isn't displayed the same as without combining. The shiny one is the one after combining.
    $UnityBad.png
    $UnityGood.png
     
  22. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    You have to put the materials on objects and feed these into the MB2_TextureBaker component and bake. Note that these objects don't have to be the objects will be combining they can be placeholder cubes so this can be done ahead of time in the editor. It is much preferable to do this in the editor.

    Your combined mesh will have only one material unless you want multiple materials. You have to set the shader on that.

    I would suggest experiment with a bunch of cubes in the editor to get the combined material working properly. Start simple and gradually add complexity. Once that is working focus on baking the procedural meshs. You should be able to re-use the prebaked combined material unless you are creating materials on the fly too.
     
  23. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    The instanced thing is probably caused by assigning your material to MeshRenderer.material. You almost certainly want to assign to MeshRenderer.sharedMaterial. The "material"/"sharedMaterial" and "mesh"/"sharedMesh" thing is one of the most confusing parts of the Unity API. You almost never want to use "material" and "mesh". These should not have been implemented as properties they should have been methods. They are a trap waiting for the unwary programmer who doesn't sit down and spend an hour using GetInstanceID() to figure out exactly how these work.

    Sorry for the rant. That being said I don't think this is your problem or you would be getting errors saying MeshBaker can't find your material in the list of baked materials.

    Is there tiling involved or UVs outside the range 0..1? If so then you may need to use the bake out of bound UVs option.

    Are your source textures uncompressed and in ARGB32 format? I have sometimes had problems reading pixels from compressed textures that produce strange results like you see. I try to check for these and disallow them but I may have missed a format.
     
  24. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    <extremely long and creative string of cuss-words and other such things deleted>
    I've finally figured out what was wrong, but only after reducing the package down to the smallest possible piece, deleting all the generated files, renaming and opening the project again.

    Somewhere there there was a bad file. Once I backed up and deleted everything except the assets and projectsettings directories and rebuilt, everything started working fine.

    Oh, I was referencing material.shader instead of sharedmaterial.shader, but that was just making it instances, causing a less obvious problem.

    Ralph
     
  25. nikolida

    nikolida

    Joined:
    Nov 6, 2012
    Posts:
    1
    Can I such generated object [baked] .. use in another project ?

    ThanX
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Objects can be baked into:
    • Scene objects (difficult to move to another project because mesh is an instance not an asset)
    • Prefabs (the mesh gets saved as an asset. These are very easy to move to another project by exporting as a Unity package). Note that prefabing skinned meshes is tricky because the bones need to be included in the prefab. The FAQ describes the procedure for skinned meshes.
    You can also bake materials textures into atlases in one project and export the Combined Material asset and its atlases to another project, then bake objects in that other project using those atlases and Combined Material.
     
  27. EmeralLotus

    EmeralLotus

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

    This is great. Thanks very much.
     
  28. randomtiger

    randomtiger

    Joined:
    May 23, 2013
    Posts:
    4
    Hi there, I am evaluating Mesh Baker. It looks ideal but after following your 'Combining Skinned Meshes' video my model only animates one of the original (any of the four) 'Skinned Mesh Renderer's is enabled. Otherwise it will sit in its last animated pose. I've tried changing everything I can think of though I'm not very experienced Unitys animation systems etc. Any idea what might be wrong?
     
  29. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    What is the best way to do this? Yes, I've read the manual.

    I've got a map generated from instantiated prefabs. Since these are separate GameOjbects, there are an insane number of are draw calls.

    I've got it partially working by procedurally combining the hexes, although for some reason it will lose the textures as I try to scale it up. Generating the textures is also too slow.

    I'd like to generate the textures in the editor, but generate the meshes during runtime.

    Should I set up another scene with the prefabs instantiated and use that to generate the textures? Should I set up the objects in my base scene and generate the textures there in the editor? Also, how can I do that for textures with multiple shaders(AKA Trees)? I didn't see an obvious way to generate the textures for those in the editor?

    Am I missing something in how I should approach this problem?

    Thanks,
    Ralph
     
  30. Mantra-Games

    Mantra-Games

    Joined:
    Nov 27, 2012
    Posts:
    169
    Hey there,

    I'm having a hard time getting this to work...

    Question - When I'm going through the step of 'Object to be combined', I have over 50 trees in my scene with 2 materials/2 textures. Do I need to manually drag each and every tree over from my scene into the list or is there an easier way?

    Question - I'm trying to bake the mesh and textures of a lot of things in my scene. So I have a gas station that has about 20 meshes and 10 materials. Which of the 3 options do I use when going to Game Object/Create Other...? And then what are my steps from there? I had a hard time following your 2 tutorials when it came to my own project.

    Cheers!
     
  31. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Most likely the problem is the "Culling" setting in the various animation components. These are probably set to "Render Bounds". Try setting them to "Always Animate".
     
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    The TextureBaker and MeshBaker components are loosely coupled. They only communicate through the "Combined Material" asset. You can click on this asset in the project and its fields show up in the inspector its fairly simple, basically a list of materials mapping to UV rectangles. So you can do all your texture baking in a separate scene and use the generated "Combined Material" asset in a different scene.

    I would create a separate scene. Instantiate one of each prefab and bake the textures. You can even use placeholder cubes in place of your prefabs as long as they have the correct material on them. Once this has been done you can MeshBake anything that has that material.

    There is a section in the manual explaining how to set up bakes for objects with multiple materials. There are also a couple of youtube videos using trees specifically.

    http://youtu.be/fvNY9fjhsR8

    http://youtu.be/XCYnNkJ3DSw
     
  33. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    There is a button in the inspector "show tools for adding objects". It opens a window with some tools for adding things. Basically it is a search filter. It has some fields which are the search criteria. On of these is "material". You can drag one of your materials to that field, select all objects in your scene and click "Add". It will add all the objects in the selection that use that material.

    • Material Baker is for baking the materials in one scene and baking the meshes in another scene
    • Mesh and Material Baker is for baking meshes and materials in the same scene.
    • Multi-mesh and material baker is for huge meshes when the combined mesh will exceed the 64k limit.

    99% of the time you will use the "Mesh and Material Baker".

    I would first run the "list shaders in scene report" on the gas station and look at what shaders/materials are being used and which meshes use tiling. Based on this I would plan what to combine. You may need to use several "Mesh and Material Bakers". It is easiest to start with meshes that don't use multiple materials and tiling then add more meshes. It is safe to experiment, if you don't like something just change the settings an re-bake.
     
  34. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    *Never mind, I just downloaded the latest version and I don't see the issues now ;)

    *Second Edit: Actually, I was using the wrong material :( For some reason that are two versions of the material, one upper case and one lower case. I was using the wrong one so of course it was creating the wrong material.

    Thanks,
    Ralph
     
    Last edited: Jul 4, 2013
  35. Zaffer

    Zaffer

    Joined:
    Oct 21, 2010
    Posts:
    266
    Hi Phong,

    I made a large, detailed landscape which has lots of optimization problems. It averages over 3000 draw calls (Ouch) and has lots of different problems, but I’d like to focus on two to start with – rocks and trees. Not knowing what I was doing when I built this landscape, I made 3 different rock shapes times 7+ different rock sizes times 6 different rock materials (see attached). I made prefabs from Blender files for all of these rocks which are still in my Project folder (never exported those rocks to FBX). Unity apparently does not batch any of these rocks (see attached). Would Mesh Baker be able to do something about combining these rock meshes and textures?

    My second question is about trees. I made all my trees in Tree Creator and they are all terrain trees. If I were to replace the terrain trees with object trees by dragging individual Tree Creator trees into my scene and getting rid of the terrain trees, would Mesh Baker be able to bake these tree creator trees?

    As it stands, my FPS increases by about 10 FPS when I drop the rocks out of my landscape and the drawcalls drop by about 200. Trees on the other hand are much more dramatic. When I change the Max Mesh Trees setting in the Terrain Inspector from 1000 to zero, the drawcalls drop from about 3400 to 1400 and the FPS increases from about 30 to 100.

    It sound like Mesh Baker might help me really optimize my landscape. I am eager to try it. What do you think? Thanks.

    Barbara Parkman (Zaffer)

    $rocks2.JPG $rocks4.JPG
     
  36. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    Zaffer,
    I love what you've done so far!

    I'm just getting started with Unity and MeshBaker, so take what I'm going to say with a grain of salt ;) I could easily be wrong about some of the things I'm going to say.

    It can help, and I would definitely try it, but there are some things you need to be aware of.

    The good.
    The developer is extremely active and helpful from everything I've seen so far. That's a huge plus for me. I'm using some other systems that have been abandoned, and being able to ask questions has been extremely helpful.

    I'd watch this video. He goes through what needs to be done in a landscape to create atlases and combine meshes. It works pretty well with that, I've got a tile based game and it's reduced the draw calls from 5000 to 50, so there can be a dramatic improvement in some abnormal cases like mine where I've got a bunch of very small objects.

    http://youtu.be/XCYnNkJ3DSw

    If you can program, the API is easy to use, you can walk through your scene, grab the appropriate objects and tell it to create a mesh. I'm doing procedurally generated tiles so I have to do that, and it's pretty simple.

    Now for the ugly.

    I believe that it doesn't currently pull over the shader parameters, so you will have to adjust them manually for the textures. Not a big deal, it's got to be done once when creating the texture atlases, just annoying. Multi-textured objects like trees may take a bit of fiddling to get right. He shows that in the video.

    Because everything is a big mesh, automatic culling is not going to work. even objects outside of the view frustum will be sent to the video card. For instance, normally you would see your frame rate change when looking down at the ground or when close to a cliff face. If you have a large area, you're going to have to do the culling manually, either by setting up smaller squares using the editor that can be culled or by some other technique. This has nothing to do with meshbaker, but with how the graphics card works. If you can get 60 FPS and aren't going to make the area any bigger, you may not care ;)

    I'd definitely recommend that you try it, if you set the atlas size to 2048 or 4096, there is a good chance that it will drop the draw calls for your rocks down to 1 or at most, a couple. That's probably worth doing even if that's all you use it for.

    Good Luck,
    Ralph
     
  37. Zaffer

    Zaffer

    Joined:
    Oct 21, 2010
    Posts:
    266
    Thanks for the compliments Ralph and for the detailed rundown on Mesh Baker. Glad to hear the developer is active with the project. Sounds like Mesh Baker is going to help me very much. 60 FPS sounds like heaven!
     
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    RalphTrickey did a great job of answering these questions. MeshBaker can bake trees and rocks but the baked tiling can be tricky. Tree creator uses tiling for trunks. It is best if you combine all trees that use the same set of textures together. You can combine different textures but it has to bake the tiling which can eat up space in atlases fast. Also as Ralph mentions you may loose Frustum Culling. For this reason it is best to bake your landscape into clusters.

    Let me know if you have any further questions.
     
  39. Zaffer

    Zaffer

    Joined:
    Oct 21, 2010
    Posts:
    266
    Thanks Phong,

    I was planning on baking oak with oak, birch with birch etc, so that should work out. It's going to take me some time to replace all those terrain trees with object trees, so I'll start with the rocks. Just downloaded Mesh Baker and I'm looking forward to trying it out. Thanks for making it!
     
  40. yano_123

    yano_123

    Joined:
    Aug 24, 2012
    Posts:
    41
    Hi there,

    I used Mesh Baker with level making asset "_ makeYOURlevel _", but I had one problem.

    I baked two meshes below.
    $beforeBaking.jpg

    And here is the result. Black lines between the combined meshes are appeared.
    $afterBaking2.jpg

    I'd like to use MashBaker with makeYOURlevel, if possible.
    Any suggestions?
     
  41. nution

    nution

    Joined:
    Nov 7, 2012
    Posts:
    10
    Quick question. Im running into issues with the quality output of the texture / material. When I bake my assets into a single mesh, that part all seems well and good, however the resulting texture is pretty low quality. It dumbs it down quite a bit from their original textures. I looked into changing the atlas size to a high number before baking the material, but that didnt effect the outcome. It produced the same atlas as before. Are there some specific settings to adjust quality settings or possibly let it use multiple atlases for a large mesh bake? Thank you.
     
  42. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    It looks like there is tiling and the padding is getting included. If you are baking like with like so that there is only one texture in each atlas then try setting the padding to 0. Let me know if that solves the problem.
     
  43. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    This is from the FAQ let me know if any of it helps

    1) Unity may be re-sizing the atlas texture. When baking the baked atlas size is printed in the console. Look at the “Maximum Image Size” field on the atlas texture. Sometimes unity sets the Maximum Image Size to a low number. If you change the “Maximum Image Size” in the inspector to match the actual atlas size it may eliminate your quality loss. Hopefully this is your problem as it is easy to fix.

    2) Another place you may be loosing quality is baked tiling. If you look in the console at the output you should see a warning if MeshBaker is baking tiling. If the baked tiling exceeds “Max Tiling Bake Size” then the baked texture is being shrunk to fit and there could be quality loss. Not much that can be done about this one. You may be able to bake all the meshes that share the tiled texture together and you could tile the combined mesh.

    3) Another place quality can be lost is texture packing. Each platform has a maximum texture size. iOS = 2048, PC = 4096. If your combined atlas exceeds this then textures will be shrunk as they are added. You should be able to get an idea from the report in the console if this has happened. Not much can be done other than splitting the combined mesh into several combined meshes or sharing more textures.

    4) MeshBaker has a “Resize Power of Two” textures option. This shrinks textures as they are being added so they have a border of “padding” around them. The reason for this is so power-of-two textures can be packed efficiently into an atlas that is also a power of two. Without this feature packing can be very inefficient (almost 75% wasted space). It is possible although unlikely that this is causing the quality loss. Try baking with and without “Resize Power of Two” to see.
     
  44. yano_123

    yano_123

    Joined:
    Aug 24, 2012
    Posts:
    41
    Hi,

    Thank you for the reply. The problem was solved. It's my mistake. I didn't set Multiple Combined Materials Settings.
    This mesh Includes three materials (Ground, Ceiling, Wall).
    So I set Combined Mapping Settings like this:
    $multipleCombinedMaterials.png

    Setting the padding to 0 also works fine. Thank you for the perfect asset!!
     
  45. Crazy Robot

    Crazy Robot

    Joined:
    Apr 18, 2009
    Posts:
    921
    I'm having some major with this tool after the last update.

    It won't add any meshes to the "Objects to combine", all it states is:

    Added 0 objects. Make sure some or all objects are selected in the hierarchy view. Also check ths 'Only Static Objects', 'Using Material' and 'Using Shader' settings

    I looked at all settings and Mesh Baker just refuses to add any objects to bake. When I manually add them and it bake, it acts like it's baking and creating an atlas, but at the end NOTHING...

    UPDATE:

    I finally got it working. Not sure how...
     
    Last edited: Jul 10, 2013
  46. Crazy Robot

    Crazy Robot

    Joined:
    Apr 18, 2009
    Posts:
    921
    I have a 27 meshes that all share 5 textures. I want to combine then all in to one atlas. When I bake the 27 meshes, they all bake into one atlas, but the same textures is repeated over and over again.

    As an example, if all 27 meshes use texture number 2, then texture number 2 is created in the atlas 27 times.

    How can I bake an atlas without having this happen?

    Thanks.
     
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    MeshBaker treats each distinct (Texture + unique tiling settings) as a distinct item to be packed. So check that the textures have the same tiling settings. If the tiling settings are the same then the texture should only appear once in the atlas. Note that if your models use out of bounds UVs and fix out of bounds UVs is checked that counts as tiling as well. The only other thing that could trip this up is if your texture assets are duplicated then meshbaker won't recognize the texture assets as the same.
     
  48. TomBeatnik

    TomBeatnik

    Joined:
    Mar 1, 2013
    Posts:
    1
    Hi guys, does anyone know if you can actually dynamically combine meshes and textures at runtime on iOS and Android devices.
    Currently using the trial trying to build to an Android device gives me a dll error.

    ArgumentException: The Assembly UnityEditor is referenced by MeshBakerCore. But the dll is not allowed to be included or could not be found.
     
  49. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    This is a known limitation of the evaluation version. The full version provides full source code and definitely works on Android and iOS.
     
  50. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    I just updated to 2.8.1 today, and after doing so I am no longer able to dynamically update baked an array of baked meshes in a scene. The code didn't change at all - I only updated from an older version (from a few months ago, not sure the exact version number).

    Here's what I'm doing. I start by adding everything to the baker:
    void addAudienceObjectToBaker(GameObject newObject)
    {
    GameObject[] addList = new GameObject[1];
    addList[0] = newObject.GetComponentInChildren<MeshRenderer>().gameObject;

    objsInCombined.Add(addList[0]);
    bakedObjectsUpdatedThisPass.Add(addList[0]);

    addList[0].renderer.enabled = false;

    meshBaker.AddDeleteGameObjects(addList, null);
    meshBaker.Apply(true, true, true, true, true, false, false, false, true);
    }

    Then I go through, position the objects, and for each object that is changed it's added to the list bakedObjectsUpdatedThisPass. Then then on each frame I do this:
    void updateBakedAudienceObjects()
    {
    meshBaker.UpdateGameObjects(bakedObjectsUpdatedThisPass.ToArray(), false);
    meshBaker.Apply(true, true, true, true, true, false, false, false, true);
    }

    However the objects no longer move at all from their initial point. Same code, but no longer works. Is there anything you can find that I may have missed that has changed, or something I need to now adjust to support the latest version?

    Thanks!