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. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi Rod,

    The answer is partially. Mesh Baker can bake the mesh assets generated by Automatic LOD, but it won't integrate automatically with Automatic LOD's mesh switching system. It is fairly tricky to efficiently integrate Mesh Baking and LOD. It is probably possible to enhance Automatic LOD but would be difficult.
     
  3. Zenchuck

    Zenchuck

    Joined:
    Jun 2, 2010
    Posts:
    297
    First off, congratulations on creating the best plugin on the asset store. I followed the tutorials on youtube but feel like I am missing a key bit of information around making the created mesh instances persist in the scene. It is a little bit tedious to set up 20+ prefabs to accept the baked data. It would be nice to multi-edit the Mesh Bakers auto-generated by the grouper feature. Other than that small quibble this plugin is pure genius.
     
    Last edited: May 17, 2016
  4. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Thanks for the kind words Zenchuck.

    It is important to understand the difference between 'instances' and 'assets'. A mesh can be an asset which exists as a file somewhere in the project folders. A mesh asset can be referenced in an inspector from any scene. Prefabs, which are another kind of asset can reference the mesh assets. These references will work when the prefab is used in any scene.

    A mesh 'instance' exists in Memory. It will get saved (serialized) somewhere in a scene file when that scene is saved as long as something in the scene uses it. When that scene is loaded the mesh will be loaded with the rest of the scene. References to that mesh will work within the scene, but another 'asset' such as a prefab in the project folder will loose its reference to the mesh as soon as a scene is closed.

    In Mesh Baker when you bake a mesh it can either "bake into prefab" or "bake into scene object". If you choose bake into prefab then the mesh is saved as an asset in the project folder. This only works in the editor, not at runtime. If you choose 'bake into scene object". Then the created mesh is an instance in the scene memory. This mesh cannot be referenced from prefab assets (the reference will be lost).

    Let me know if this clears things up.

    Thanks for the request on the multi-edit feature. I will try to add it.
     
  5. Zenchuck

    Zenchuck

    Joined:
    Jun 2, 2010
    Posts:
    297
    Cheers for the info. I'm not sure why I was losing the mesh saved to the scene. I prefer to have a file sitting in the project folder anyways, it feels more secure for some reason. I'll share a few other thoughts with you about ways that this tool set could be extended. A quick toggle for setting normals on and off would be nice in some instances. For example if you had a scene with baked lighting you would need the normals for a lightmap bake, but then could discard them before exporting - I'm not sure how much memory that could save. My other thought is that sometimes artists intentionally place mirrored UVs outside of the 0-1 space. This is often helpful to bake image data in a 3d editor. This is traditionally on the 1-2 space of the U (x) direction and would require shifting this data found in the 1-2,0-1 UV space back into the 0-1,0-1 space, finding the new atlas coords and then moving the 1-2 data by the width of the atlas in the U (x) axis. I know this is primarily a normal map related thing but it would be useful in some cases. I'm sure you have already thought of ways to generate a diffuse and normal atlas that could be synced.

    No pressure on any of these ideas - the current version is perfect as is. Auto-generating an atlas while retaining UV and combining mesh in zones is basically the holy grail of mobile art IMHO (at this moment of my life anyways).
     
    Last edited: May 17, 2016
  6. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi Zenchuck,

    Thanks for the feedback. One thing I don't like about the asset store is that I cannot directly connect with my customers. This forum is my main channel for feedback. Communication such as this is very, very valuable for me.

    I was not aware that artists sometimes use the 1..2 range of the UV channel for baking. I wonder what the benefit is of using that rather than the 0..1 range?
     
  7. Zenchuck

    Zenchuck

    Joined:
    Jun 2, 2010
    Posts:
    297
    This is related to mirrored UVs. Let's say for example you wanted to bake light information from a sculpt into a mirrored low polygon mesh. If you have the mirrored UVs occupying the same space in 0-1 you will have baking errors as both sides of the mirror attempt to write over each other. Most textures in 3d apps are set to repeat, so if you move mirrored UVs 1 unit along the U(x) axis you will end up reading the correct data. I can imagine this would work in an atlas as well if you moved the mirrored UV's back into the 0-1 space and then shifted by the width of the atlas. This would be useful in unique instances where this method of laying out UVs was employed. The artist could alternatively bake and then move the uv's back into the 0-1 space but this is less ideal because often times the UV in the 0-1 space is chosen specifically for yielding better bake results.

    Not all UV outside of the 0-1 space is relying on continuous repeating pattern.
    http://wiki.polycount.com/wiki/Texture_Baking#UV_Coordinates
     
    Last edited: May 17, 2016
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Ahh, that make sense now. Thanks for the linke.
     
  9. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi there!
    I need to combine materials of all melee weapons. And it's works fine. But i need to add some detail texture(and detail normal) for blood effect and some blood textures work very strange and ugly with combined material. Can i somehow bake them or may be there is a way to get it works properly?
    I'am using different blood textures with random tiling (for each weapon)
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi justtime,

    You will need to bake an atlas for the detail diffuse and bump textures. You can bake the detail textures just like another texture, as long as you set the detail texture to use UV Set UV0. The tiling will get baked into the atlas.

    Give every weapon a bloody set of detail textures for the bake. At runtime you can leave the detail texture slot empty initially, then add the baked detail texture and normal when you want to make the weapon bloody.
     
    justtime likes this.
  11. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    Phong,

    I see that the material combiner is combining the same textures many times(resulting in poor quality).
    Any idea why it would do this and how to stop it from doing it?

    P.S. There are many game object that use the same maps but use different materials(because of detail colors).
    I would think MB would reuse the existing textures even if it is on a different material.
     
  12. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi katasteel,

    One possibility is that the material is tiled on the source object and Mesh Baker is baking the tiling.

    I think in your case what is happening is that the the objects don't use the same set of textures. Think of the result material as a set of atlases. One for maintex, one for bump, one for spec, one for detail etc... These are overlayed on top of each other and must line up. The UVs of the mesh define which sub-rectangle of the atlas gets used. For each object its the same rectangle for all atlases. Because each object uses a different detail texture then it needs a different sub-rectangle and Mesh Baker needs to duplicate the other textures to make it work. Unfortunately it is wasteful. I will give it some thought on approaches to deal with this situation.
     
  13. rafaelmfernandez

    rafaelmfernandez

    Joined:
    Aug 11, 2013
    Posts:
    62
    Hey Phong, I have used your product successfully in the past a few times, mostly for buildings. However Im having issues using it now Im not sure maybe I am forgetting something. However here is what I am trying to accomplish and maybe you can help me.

    I have several firetrucks for a game I am developing, the only problem is that theyre all split into hundreds of individual parts. Now that they are setup properly I want to bake most of the meshes into one big one. I get an error in the console when doing this: (Which is the right way I think to do what I am trying to do, please correct me.)



    1. For organization purposes I placed objects under parents see image below
    https://gyazo.com/38f872e00e06a5f3791eaa668e844f74

    2. I create a multimesh and material baker

    3. Open tools for adding objects and select a folder for combined material assets

    4. I deactivate everything but what I am baking in the scene and press list shaders in scene
    https://gyazo.com/ff4e110c9704275d3ee9eb39691d7f02

    5. then search for meshes to add and select the body bake parent that selects everything under it. Result is 148 Objects.

    6. I create my empty asset for combined material

    7. Here is my console so far: https://gyazo.com/64c8fb3d6ad1f459f39d9a7dd60a3626

    8. Im gonna go ahead and add the meshes that were excluded for Out of bounds UVs
    Now: https://gyazo.com/8bc631f13829b28253634831aad4750c

    9. https://gyazo.com/2d180ce8fdce01474cd33cad1453a91d

    I built source to combined blah blah and came out with around 10 materials. Which is weird cause the first time I tried I only got 2.


    10. So now I press generate every mesh baker in scene.
    Shows the progress bar saying collecting textures combining meshes etc.

    11. Heres the log after thats done https://gyazo.com/d34865027fa9b338640b501cd254d6f3

    12.
    ====== There are possible problems with these meshes that may prevent them from combining well. TREATMENT SUGGESTIONS (copy and paste to text editor if too big) =====

    Object Object022.002 (2) uses 2 materials. Possible treatments:
    1) Collapse the submeshes together into one submesh in the combined mesh. Each of the original submesh materials will map to a different UV rectangle in the atlas(es) used by the combined material.
    2) Use the multiple materials feature to map submeshes in the source mesh to submeshes in the combined mesh.

    Object Object117 (1) (UnityEngine.GameObject) submesh=0 material=Chrome (UnityEngine.ProceduralMaterial) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box 0.0076,0 .. 1.028,1. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Box021 (1) (UnityEngine.GameObject) submesh=0 material=Chrome (UnityEngine.ProceduralMaterial) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -0.8553,-8.822 .. 1.927,1.432. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Circle001 (1) (UnityEngine.GameObject) submesh=0 material=Chrome (UnityEngine.ProceduralMaterial) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box 0,-1.602 .. 99.61,6.993. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Object030 (1) (UnityEngine.GameObject) submesh=0 material=Chrome (UnityEngine.ProceduralMaterial) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -62.24,-12.45 .. -45.24,12.29. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Bumper (UnityEngine.GameObject) submesh=0 material=Chrome (UnityEngine.ProceduralMaterial) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -0.01899,0.3289 .. 0.5178,0.5659. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Object022.001 (2) uses 4 materials. Possible treatments:
    1) Collapse the submeshes together into one submesh in the combined mesh. Each of the original submesh materials will map to a different UV rectangle in the atlas(es) used by the combined material.
    2) Use the multiple materials feature to map submeshes in the source mesh to submeshes in the combined mesh.

    Object Object022.001 (2) (UnityEngine.GameObject) submesh=0 material=Chrome (UnityEngine.ProceduralMaterial) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box 0.007596,0 .. 78.14,79.86. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Bumper (UnityEngine.GameObject) submesh=0 material=metal_s (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -1.329,-6.848 .. 2.329,7.848. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Roof (UnityEngine.GameObject) submesh=0 material=metal_s (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -4.685,-1.571 .. 5.685,1.906. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this subme1sh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Roof (UnityEngine.GameObject) submesh=0 material=metal_s (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -3.661,-3.661 .. 4.803,4.803. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Back (UnityEngine.GameObject) submesh=0 material=metal_s (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -3.202,-2.959 .. 4.146,4.031. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Vents (UnityEngine.GameObject) submesh=0 material=chrome (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -83.99,-27.26 .. 27.26,27.26. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Poles (UnityEngine.GameObject) submesh=0 material=No Name (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -3.25,-1.9 .. 328.6,1.9. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Roof (UnityEngine.GameObject) submesh=0 material=metal_s (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -2.788,-2.227 .. 3.376,3.154. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Object113.004 (1) (UnityEngine.GameObject) submesh=0 material=metal_s (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -2.596,-7.927 .. 3.596,8.927. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Cylinder005 (1) (UnityEngine.GameObject) submesh=0 material=Black (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box 0.0076,0 .. 1.028,1. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Circle009.003 (1) (UnityEngine.GameObject) submesh=0 material=Black (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -7.499,-32.82 .. 55.06,9.697. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bounds UVs' feature to bake the tiling and scale the UVs to fit in the 0,0 .. 1,1 rectangle.
    3) Use the Multiple Materials feature to map the material on this submesh to its own submesh in the combined mesh. No other materials should map to this submesh. This will result in only one texture in the atlas(es) and the UVs should tile correctly.
    4) Combine only meshes that use the same (or subset of) the set of materials on this mesh. The original material(s) can be applied to the result

    Object Box030 (1) (UnityEngine.GameObject) submesh=0 material=Healmet_glass (UnityEngine.Material) uses UVs outside the range 0,0 .. 1,1 to create tiling that tiles the box -1.335,0 .. 1.623,1. This is a problem because the UVs outside the 0,0 .. 1,1 rectangle will pick up neighboring textures in the atlas. Possible Treatments:
    1) Ignore the problem. The tiling may not affect result significantly.
    2) Use the 'fix out of bou<message truncated>

    13. More of the debug log https://gyazo.com/0f54ad67808ce4d04df0d15bd3a42026

    14. Heres my screen so far https://gyazo.com/da760befbbb99e825d5d9187e37a59be
    15. So I think now I just bake the meshes here is where I think im messing up I dont know. So I click generate mesh bakers and then bake all child mesh bakers

    16. And here is the issue I always have been getting since I have tried over a dozen times: https://gyazo.com/245e1dad25208d74a7686105778adf36

    17. Trying to remove the previous mesh baker and trying again.

    18. Tried again here is the error: https://gyazo.com/d884c684b84b80b58b27e2ceb8aed3ce

    https://gyazo.com/859a773a4bbd8817d4cfd5a389c4b4f8

    those are my options for the mesh baker, pretty default.

    If you have any idea what the problem is please help. Thanks! Other than this, mesh baker has worked pretty well.
     
  14. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    rafaelmfernande:

    By the look of it your "Grill" texture is not a 2DTexture so my guess is that the textures are never atlased.


    Phong:
    I'm sorry to hear about that. If I was to go about trying to update the code where should I start?

    I would store a dictionary of all the texture names that have been added to the atlas so far.
    Then check to see if the new material uses a existing texture before adding it to the atlas.

    The part I'm getting caught up on is how to tell the material to look at a specified index(offset) within the texture.
    I don't see that you are setting that anywhere.
     
  15. rafaelmfernandez

    rafaelmfernandez

    Joined:
    Aug 11, 2013
    Posts:
    62
    Yeah I know that much, but when I removed all of the chrome I still got the error.
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Try to bake the Mesh Bakers one at a time to see which one is causing the error. Note that Mesh Bakers can have a different list of objects from the texture baker. First check to see if the Mesh Baker is using its custom list of objects to combine. If so make sure it is not using any materials with textures that are not Texture2D.
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi katasteel,

    I think the index(offset) you are referring to (if I understand you correctly) is baked into the UVs as they are being added to the combined mesh. The problem is that if you change these UVs so that the detail texture changes then the other textures (maintex, bump, etc...) will be affected as well.

    One possibility might be to use the UV4 channel for the detail texture. Each of the objects that you are adding could have an extra copy of the UVs in UV4. Configure the shaders to use UV4 for detail instead of UV. You could build an atlas with all your detail textures in it, then scale and offset the UV4 of each mesh to use a different sub-rectangle of the detail atlas. This way the detail atlas is completely independent of the atlas for the rest of the materials. When the meshes are baked if you include UV4 as is and put your atlas in the detail texture slot it should work. I haven't actually tested this, just thinking out loud. Mesh Baker won't help you setting up the UV4 that would need to be a script you write yourself.

    Re-reading your original post, you mention "detail colors". Are you talking about a "Detail Albedo" texture or the color tint box beside the Albedo texture. If its a color tint that is the only difference then that is easier to deal with. One could use vertex colors in the mesh (requires tweaking the shader to sample vertex color instead of the color tint).
     
  18. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    I mean Detail Albedo x2.

    I will try a couple different things.
    If I get anywhere with it I will let you know.

    For right now I am just using two materials instead of one(That way the quality loss is reduced).
    Thanks for your help.
     
  19. devstudent14

    devstudent14

    Joined:
    Feb 18, 2014
    Posts:
    133
    I'm making a top-down building game so all the vegetation (including grass) can be removed by units. I have a script attached to each object that handles it's hitpoints, destruction etc.

    My question is, once I've baked all the hundreds of instances of grass and trees into single gameobjects, will I still be able to remove single objects? If so, how?
     
  20. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Yes you can remove single objects.

    1) If you baked the objects in the editor make sure the "clear buffers after bake" is disabled.

    1) When you want to delete grass you can

    Code (CSharp):
    1. //collect game objects to be deleted.
    2. //Or collect just the InstanceIDs of these game objects
    3. GameObject[] objsToDelete = ...
    4. myMeshBaker.AddDeleteGameObjects(null,objsToDelete);
    5. myMeshBaker.Apply();
    Instead of using a GameObject array you can also use an int array of InstanceIDs. Do this if the GameObjects have already been destroyed and might be null.

    There are some example scripts in the example scenes. The RuntimeExample shows some simple scripts adding and deleting. Also the SkinnedMeshRenderer.
     
    devstudent14 likes this.
  21. devstudent14

    devstudent14

    Joined:
    Feb 18, 2014
    Posts:
    133
    @Phong This is working extremely well! I'm making a faux voxel game as a learning exercise. I'm able to add and remove voxels to the combined mesh quite easily. My only issue now is the 64k limit on meshes. Can you add multi-meshes dynamically?

    Also, I know you must be busy, but could you take a look at my script to see if I'm implementing the dynamic add/remove function optimally?
     
  22. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Yes the MultiMeshBaker's work at runtime just like the regular Mesh Bakers. Mesh Baker LOD uses them heavily. Sure I can look at your script if you want.
     
    devstudent14 likes this.
  23. devstudent14

    devstudent14

    Joined:
    Feb 18, 2014
    Posts:
    133
    That's good news about multi-mesh. I'll try and implement it.

    With meshbaker, I wonder if my faux voxel game could actually be a legitimate solution? I'm aiming for a finite map size of 300x300x20 standard Unity cubes. Would performance be that much better with a standard voxel solution? I prefer gameObjects to voxels as I understand them a lot better and it would be easy for me to attach scripts, particle effects etc.

    Anyway thanks for agreeing to have a look at my script! I couldn't upload it here so here's the link: http://hostcode.sourceforge.net/view/6022

    I'd like to give credit to this youtuber for the base script: https://www.youtube.com/channel/UCp_SOgsRYdLfIEWLjM62ZJg. The script has been heavily modified though, so any craziness is solely due to me :)

    It works until I reach 64k, so I must be doing something right! But my big question is whether it could be optimized further by utilizing meshbaker more effectively.
     
  24. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Had a look. From the Mesh Baker side the initial creation looks correct. For destruction it is best to collect all the blocks first, then call AddDelete once. This is because it is just as efficient to delete and add many blocks as it is to do one. You can add and delete in the same call. This is the most efficient way to do it.

    You probably won't be able to store your whole world in memory at once unless it is quite small. You will probably need a chunking system to divide it up into chunks and only store say 5 rings of chunks around the player's current position chunk. As the player moves to a new chunk you destroy chunks behind the player and create chunks ahead. You wan't to spread the load for this across frames so as not to hit the CPU.

    Note that baking time is linear with Mesh Size. it may be worth limiting the mesh size to 34k or 20k so that updating the mesh doesn't take too long.

    I have a couple of other thoughts:
    • Cache references to "Blocks" and "MeshBaker" so you arn't FindGameObjectWithTag them
    • It looks like a lot of the geometry that is hidden underground is being stored in the mesh. It would be much lighter (although more complicated) to just store the skin. Calculating this would make the system a lot more complex though.
     
    devstudent14 likes this.
  25. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    Phong,

    For some reason when I click "Open Tools For Adding Objects" a window never opens(or so it seems).
    I have tried deleting the MeshBaker folder and re-downloading and importing it.
    I also tried a fresh scene with a new meshbaker gameobject.

    P.S. This used to work for me.
     
  26. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Is there an error in the console? What version of Unity are you using?
     
  27. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    I am using the newest version of Unity and there is no error.
    I think Unity's windows don't play well with Window's 10's display scaling.
    I have 2 monitors 30" and a 27".
    The 30" was set to scale the display at 150% and the 27" was 100%.
    It seems the window got lost somewhere.
    When I played with the scaling on the 27" I found the window.

    You may want to reset the window positon when the window is opened so it can't get lost.
     
  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Interesting. I will add it to the todo.
     
  29. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134

    after click generate baker this error show up
    Material Bake Result already set to PROPS
     
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Looks like this is a bug that happens when the group has multiple materials. I fixed it adding two lines to file MB3_MeshBakerEditorWindow.cs line 748

    Code (CSharp):
    1.        
    2.         if (gaws[0].numMaterials > 1){
    3.             tb.doMultiMaterial = true;
    4.             SerializedObject tbr = new SerializedObject(tb);
    5.             SerializedProperty resultMaterials = tbr.FindProperty("resultMaterials");
    6.             MB3_TextureBakerEditorInternal.ConfigureMutiMaterialsFromObjsToCombine (tb,resultMaterials,tbr);
    7.         } else {
    8.             string pthMat = AssetDatabase.GenerateUniqueAssetPath( pthRoot + newMeshBaker.name + ".asset" );
    9.             MB3_TextureBakerEditorInternal.CreateCombinedMaterialAssets(tb, pthMat);
    10.         }
    11.  
    should be:

    Code (CSharp):
    1.  
    2. if (gaws[0].numMaterials > 1){
    3.  string pthMat = AssetDatabase.GenerateUniqueAssetPath(pthRoot + newMeshBaker.name + ".asset");
    4.  MB3_TextureBakerEditorInternal.CreateCombinedMaterialAssets(tb, pthMat);
    5.  tb.doMultiMaterial = true;
    6. SerializedObject tbr = new SerializedObject(tb);
    7. SerializedProperty resultMaterials = tbr.FindProperty("resultMaterials");
    8. MB3_TextureBakerEditorInternal.ConfigureMutiMaterialsFromObjsToCombine (tb,resultMaterials,tbr);
    9. } else {
    10. string pthMat = AssetDatabase.GenerateUniqueAssetPath( pthRoot + newMeshBaker.name + ".asset" );
    11. MB3_TextureBakerEditorInternal.CreateCombinedMaterialAssets(tb, pthMat);
    12. }
    13.  
     
    xxhaissamxx likes this.
  31. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134
    this asset is awesome i love it's best asset ever convert batches from 169 to 14 my only problem is there way to reduce verts and tries
    thanks
     
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    The best strategy is to avoid grouping objects that will never be on screen together and to group meshes that are close together. Sometimes it is better to have a few extra drawcalls if it means a lot of verts can be culled most of the time. The MB3_MeshBakerGrouper can help to group meshes that are close together.
     
    xxhaissamxx likes this.
  33. Zenchuck

    Zenchuck

    Joined:
    Jun 2, 2010
    Posts:
    297
    ^grouper is great per the above comment.

    I am still have issues getting the "bake into scene object" selection to persist the instanced mesh data. I reimport the scene and all my baked mesh data is gone. It might be a problem related to the specific way in which scene files are saved in the project? I'm at a loss.

    In the meantime is there an easy way to save the baked mesh into a project asset (for dozens of grouped meshbakers)
     
  34. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    I was not aware of this problem. If I understand correctly, you are saying that if you save a scene the meshes are there, but if you reimport they are gone? Is that correct?

    I suspect this is happening because the meshes are assets that only exist in the scene, not as separate assets. I will try it on my end to see if I can reproduce the problem.
     
  35. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,760
    I've been using the Meshbaker atlas creator to generate texture atlases for my scene.
    However, everytime that I try to generate the atlas, the MainTex atlas is tiles correctly, but the BumpMap is not tiled.
    Ive attached the two atlases. You can see the Normal maps atlas is not tiled.

    I can't quite figure out what I am doing wrong here.
    Thank you
     

    Attached Files:

  36. Zenchuck

    Zenchuck

    Joined:
    Jun 2, 2010
    Posts:
    297
    I am creating dozens (per scene) of MeshBakers and individually setting the lightmap UV option and connecting prefabs to store mesh data. If you do any further updates on this tool I would cast my vote in the pile of improving this workflow (totally selfish I know).
     
  37. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Thanks for the feedback. It is on the todo list to enable Multiobject editing.

    BTW nice work on the RGBA addon for Blender. I have been working on an Blender addon for visualizing momentum. Never seem to get time to work on it. Perhaps I should throw it up in github in case anyone else wants to work on it.
     
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Looking into the problem.

    What is the shader used by the Result Material? First thing to check is that this result material is using a shader that has a BumpMap. If not then MeshBaker is not generating the bump map.

    Check the timestamps on the generated atlases or delete the bump map and re-bake to verify that Mesh Baker is actually baking the bumpmap. Are there any errors in the console?

    Is the tiling in the UVs or is it in the Material tiling settings? Is 'Consider UV Mesh UVs' checked?
     
    Last edited: Jun 23, 2016
  39. angelsm85

    angelsm85

    Joined:
    Oct 27, 2015
    Posts:
    63
    Hi! I'm thinking of buying your asset and I need to know if it's possible to combine multiple meshes with multiple materials each one in only one mesh with one material. Thanks!
     
  40. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi Angelsm85,

    I am not completely clear on what you want to do:

    It is possible to combine all the materials on multiple objects each of which has multiple materials into a single mesh with a single material. This works best when the materials are reasonably compatible (bump diffuse with diffuse for example).

    It is also possible to combine all the materials on multiple objects each one of which has multiple materials, into multiple meshes each of which has a single material.

    Does this answer the question?
     
  41. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134
    i tried to use this code to set prefabs from other code
    Code (CSharp):
    1. GameObject.Find("BatchPrefabBaker0").GetComponent<MB3_BatchPrefabBaker>().prefabRows = prefabs;
    put prefabRows is use customer class is there way to set it
    Code (CSharp):
    1. public class MB3_PrefabBakerRow{
    2.         public GameObject sourcePrefab;
    3.         public GameObject resultPrefab;
    4.     }
    5.  
    6.     public MB3_PrefabBakerRow[] prefabRows;
     
  42. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Here is the code that I use to create the result prefab rows when 'Create Empty Result Prefabs' is clicked. You should be able to modify it to make it work:

    Code (CSharp):
    1. void _createEmptyOutputPrefabs()
    2.     {
    3.         if (outputFolder.stringValue == null)
    4.         {
    5.             Debug.LogError("Output folder must be set");
    6.             return;
    7.         }
    8.         if (outputFolder.stringValue.StartsWith(Application.dataPath))
    9.         {
    10.             string relativePath = "Assets" + outputFolder.stringValue.Substring(Application.dataPath.Length);
    11.             string gid = AssetDatabase.AssetPathToGUID(relativePath);
    12.             if (gid == null)
    13.             {
    14.                 Debug.LogError("Output folder must be a folder in the Unity project Asset folder");
    15.                 return;
    16.             }
    17.         }
    18.         else {
    19.             Debug.LogError("Output folder must be a folder in the Unity project Asset folder");
    20.             return;
    21.         }
    22.  
    23.         int numCreated = 0;
    24.         int numSkippedSrcNull = 0;
    25.         int numSkippedAlreadyExisted = 0;
    26.         MB3_BatchPrefabBaker prefabBaker = (MB3_BatchPrefabBaker)target;
    27.         for (int i = 0; i < prefabBaker.prefabRows.Length; i++)
    28.         {
    29.             if (prefabBaker.prefabRows[i].sourcePrefab != null)
    30.             {
    31.                 if (prefabBaker.prefabRows[i].resultPrefab == null) {
    32.                     string outName = outputFolder.stringValue + "/" + prefabBaker.prefabRows[i].sourcePrefab.name + ".prefab";
    33.                     outName = outName.Replace(Application.dataPath, "");
    34.                     outName = "Assets" + outName;
    35.                     //GameObject go = PrefabUtility.CreatePrefab(outputFolder.stringValue + "/" + outName + ".prefab", new GameObject(outName));
    36.                     GameObject go = new GameObject(prefabBaker.prefabRows[i].sourcePrefab.name);
    37.                     prefabBaker.prefabRows[i].resultPrefab = PrefabUtility.CreatePrefab(outName, go);
    38.                     DestroyImmediate(go);
    39.                     numCreated++;
    40.                 } else
    41.                 {
    42.                     numSkippedAlreadyExisted++;
    43.                 }
    44.             } else
    45.             {
    46.                 numSkippedSrcNull++;
    47.             }
    48.         }
    49.         Debug.Log(String.Format("Created {0} prefabs. Skipped {1} because source prefab was null. Skipped {2} because the result prefab was already assigned", numCreated, numSkippedSrcNull, numSkippedAlreadyExisted));
    50.     }
     
  43. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134
    i don't like to add prefab one by one so what i did i putted all my prefabs that i want to add in Resource
    Code (CSharp):
    1.  GameObject[] prefabs;
    2.  
    3.     void Start () {
    4.         prefabs = Resources.LoadAll<GameObject>("");
    5.         print("NewBehaviourScript " + prefabs.Length);
    6.         GameObject.Find("BatchPrefabBaker0").GetComponent<MB3_BatchPrefabBaker>().setthem(prefabs);
    7.     }
    and in MB3_BatchPrefabBaker

    Code (CSharp):
    1. public void setthem(GameObject[] ob)
    2.     {
    3.         print("Comming" + ob.Length);
    4.         prefabRows = new MB3_PrefabBakerRow[ob.Length];
    5.         print("MB3_BatchPrefabBaker " + prefabRows.Length);
    6.         for (int x = 0; x < ob.Length; x++)
    7.             prefabRows[x].sourcePrefab = ob[x];
    8.     }
    it's correctly set numbers of prefabRows but didn't set GameObject

    and here the error
    NullReferenceException: Object reference not set to an instance of an object
    MB3_BatchPrefabBaker.setthem (UnityEngine.GameObject[] ob) (at Assets/MeshBaker/scripts/MB3_BatchPrefabBaker.cs:21)
    prefabRows[x].sourcePrefab = ob[x];
     
  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    I think for each prefab row you need to create the MB3_PrefabBakerRow

    Code (CSharp):
    1. public void setthem(GameObject[] ob)
    2.     {
    3.         print("Comming" + ob.Length);
    4.         prefabRows = new MB3_PrefabBakerRow[ob.Length];
    5.         print("MB3_BatchPrefabBaker " + prefabRows.Length);
    6.         for (int x = 0; x < ob.Length; x++)
    7.             if (prefabRows[x] == null){
    8.                         prefabRows[x] = new MB3_PrefabBakerRow();
    9.             }
    10.             prefabRows[x].sourcePrefab = ob[x];
    11.     }
     
    xxhaissamxx likes this.
  45. angelsm85

    angelsm85

    Joined:
    Oct 27, 2015
    Posts:
    63
    Yes. I have multiple objects each of which has multiple materials and i want combine them into a single mesh with a single material to obtain few drawcalls. How can I do it? I've seen your video tutorial but it shows how to combine meshes with one material but not with multiple materials. Congratulations for your work!!
     
    Last edited: Jun 24, 2016
  46. dimmduh

    dimmduh

    Joined:
    Oct 13, 2013
    Posts:
    6
    Hi!

    Thank you for great MeshBaker.
    Is there any solution for fixed uvs and tiled textures?

    In final atlas tiled textures can duplicates many many times, but I guess you can just change uvs for object use the tile texture and put tiled texture only one time to final atlas.

    I hope I wrote clear :)
     
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    The default settings will merge all the submeshes and meshes. If there is tiling involved then you may need to use the multiple materials feature.

    This video explains how the multiple materials works:


    This video explains the tiling and multiple materials issues more thoroughly and how to deal with them:
     
  48. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    When the meshes are baked the UVs are adjusted to handle whatever was baked. This video has a good explanation of the process:

     
  49. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134
    i love this asset it's best thing i have but i have lot of problems first of all i always bake as prefabs
    1- Max item's to bake per once ? (i backed 300 prefabs and material looks bad)
    2- What if i want to bake all same shaders like mobile / Diffuse ? (what i did Open tools for adding Objects ==> Search For mesh To add ===> using shader (added mobile / Diffuse material ) than add Selected mesh than bake some object looks great and some look like that )

    3- this is always my setting when i bake


    thanks
     
  50. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    This is a guess, but I think the problem is that the source object has multiple materials & tiling. There are usually warnings in the console if this is the case. There should also be a message with suggestions. Is there anything there?

    If this is the case then you will need to use the multiple materials feature. This video explains what is happening and how to deal with it. Let me know if this is not the case for your meshes.

     
    xxhaissamxx likes this.