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

Blender, Importing and SUBMESHES?!

Discussion in 'Asset Importing & Exporting' started by The-Spaniard, May 21, 2012.

  1. The-Spaniard

    The-Spaniard

    Joined:
    Jan 7, 2012
    Posts:
    149
    Hi all, probably a really irritatingly novice question here, but I can't seem to find any answer to it with google.

    I'm importing a model from blender into unity, (which I export from blender as an fbx first, as I like to keep the modelling separate from unity whilst I'm experimenting) which consists of 3 meshes, each with different materials, and therefore different objects in blender (the floor, the pillars and the ceiling). However, the issue is with the ceiling: I want it all to have the same material, but for some reason when I import it to unity this mesh is broken into 3 submeshes, each with their own material (which is the same) and presumable increases the draw calls needlessly. (Specifically, the ceiling proper, and 2 bits of vaulting)

    How do I get rid of these submeshes and merge them into one mesh? I can't seem to find an option in either unity's fbx importer or in blender. In fact, there's nothing to suggest that there actually are submeshes in my blender file: there are no materials set, no vertex groups set up.

    Is it because I modelled these different parts separately, and then joined the meshes together into one? If so, is it possible to join them properly, into a single mesh rather than submeshes? I've attached the file - please take a look at it and tell me what I'm doing wrong! View attachment $4m3mVaultNew2.zip

    Thank you!

    The Spaniard
     
  2. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    Hi,

    The solution to the issue you pose is slightly complicated.

    First of all, to simply join multiple objects in Blender, you will have to select the objects by right clicking and then hit Ctrl+J

    However, this will most likely give you a new single Object with a single Mesh but three different materials.

    I am no expert on Blender, but as per the knowledge I have, I think the way to go would be like this

    1. First Create Duplicates of your original three Objects by pressing Shift+D. Then Combine the duplicates(NOT the originals) into one Merged Object by selecting and Ctrl+J as explained above
    2. With the Merged Object selected, go into edit mode, select all the faces, then go to the materials tab create a new material and assign this material to all the faces using the Assign button. Now, in the Materials Tab, delete all materials except the new material you just created and assigned
    3. Then with the Merged Object selected, do UV unwrapping to get an UV Map as per your needs. Then make sure that a New Image is assigned to your UV Map and SAVED.
    4. Now. go into Object everything, unselect everything. Now, select your original three objects FIRST, and then select your Merged Object. Go into the Render Tab on the right hand side, then go to the Baking Panel, check selected to active, then hit Bake.
    5. Once Baking is over you will have to save the Image.
    6. Now you can export your Merged object to an FBX. I usually then import the fbx and the image separately into unity and assign the image to the FBX's material.

    What I have described above is to the best of MY knowledge. There are possibly easier ways to do it. If we are lucky a Blender expert might be reading this right now and might suggest something easier :p
     
    Last edited: May 21, 2012
    pikachuxxx likes this.
  3. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Note that even with one mesh you may end in three different materials when there are three different textures in use. One texture gives one material in Unity. Your unwrap points into that direction.

    When you want one material in Unity then you have to make sure that just one texture is used.
     
    Last edited by a moderator: May 21, 2012
  4. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    Here is the blend file created after modification from your original blend file.
    I have added the Merged Object as described above and a Camera.

    EDIT: I seem to have added too much Ambient Occlusion while Baking. You can always correct that by changing the settings in the World Tab before Baking. I was in a hurry so please excuse :p
     

    Attached Files:

    Last edited: May 21, 2012
  5. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    After tweaking settings in the World Tab such as Ambient Occlusion, Ambient Color etc You can have better bakes and thus better renders as shown below

    $Vault 2.png
     
  6. The-Spaniard

    The-Spaniard

    Joined:
    Jan 7, 2012
    Posts:
    149
    Thank you both very much for your help - indeed Mr.T, importing your modified blend file to unity results in a single mesh in unity: but what I really wanted was for the three objects to be three separate meshes (as they were) but without any submeshing. It is the ceiling mesh that is the problem: $Untitled.jpg

    Also, is there any way to keep my original UV mapping for the merged object? Currently, on the ceiling mesh, there are regions which overlap in order to share parts of the same texture, but I doubt that this is causing the submeshing, as other meshes with overlapping UVs are still all the same mesh (without any submeshes).

    I'm not sure if I've been clear enough with what I need: The blend file consists of 3 objects (floor, pillars, ceiling) which all have different UVs and textures (and therefore different materials in unity). That I'm fine with. The problem is that the ceiling object appears split into 3 submeshes when imported to unity, and therefore uses 3 materials, even though I want it to use the same material for the entire ceiling mesh.
     
  7. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    As told, you use three textures here. One texture is one material. That`s the way it is. Use just one texture for the whole geometry, and you will get just one material. And most probably just a single submesh too.
     
  8. The-Spaniard

    The-Spaniard

    Joined:
    Jan 7, 2012
    Posts:
    149
    That's the thing. I am only using one texture for the ceiling. But yet it is split into 3 submeshes, each with the same material. And I can't seem to work out why it's doing this.
     
  9. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    That might be possible but that is beyond the scope of my knowledge.

    I looked at YOUR Blend file. I see a total of 3 Objects and 3 meshes corresponding to your three objects. The mesh corresponding to your Ceiling Object appears to be Circle.040 . So, Circle.040 appears to be one single mesh. I am not exactly clear on what you mean by 'submesh'.

    From what I know, if you want all the faces in your object to use a single material, you have to select the object, go into edit mode, then make sure all the faces are selected by pressing A, then go to the material tab and assign this single material to all the faces by clicking the Assign Button.

    EDIT: One more thing. You are right in that in the Merged object that I posted, the Ceiling appears to have its faces normals facing the wrong direction. A quick fix that I can think of is to select all the faces of the ceiling object and do 'Flip Normals' then export as FBX
     
    Last edited: May 21, 2012
  10. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    If we were to forget this 'submesh' business for now,

    One Ceiling Object with One Material - Is that what you seek?
     
  11. The-Spaniard

    The-Spaniard

    Joined:
    Jan 7, 2012
    Posts:
    149
    This is exactly the problem - in blender the ceiling appears as a single mesh, but when I import it into UNITY it appears as one mesh with 3 "submeshes". (see the image last post) I don't know why, or even what "submeshes" are, other than they each can use another material, and there is an extra drawcall for each, which I don't want at all. This is a screenshot from unity, where I've given all the submeshes different materials so that they're easy to see. But if I delete an element from the array, one of the submeshes will just go invisible. $Untitled2.jpg

    Yup, exactly. With the same UVs if possible.
     
  12. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    Ok, I understand your problem much better now.
    And I notice what you are pointing out in Blender as well. Frankly I am also somewhat confused as to why that is happening.

    Since I am busy now, I will take a look at it later on, work on it and if I can produce the result you are looking for, I will be sure to post them here
     
  13. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    And again, no, you use three textures for this ceiling. So you get three materials. You have assigned different meshparts of the ceiling to different textures at one point. Proof? Export your ceiling as Obj. Open the mtl file, and you will see that three textures gets used: untitled, UV Test.jpg, and 0 Uv test.jpg. It should be one.

    Solution: Add a material. Add a new texture. Select this texture in the Image editor. Now enter the edit mode of your object. The whole mesh should be selected, and the mesh should be assigned to this texture and this material now.

    Blender material system is simply nasty and cluttered. That`s why i don`t really like to use it. Such things here happens too easy, and you don`t even notice it.
     
  14. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    EDIT: What Tiles said ;-)

    you have separate textures assigned to separate parts of the mesh of the top object. if you select faces in edit mode and open a image editor, you will see that you have assigned "uvtest.jpg" to some parts, "untitled" to other parts and nothing to the rest. that makes your three submeshes. to fix it, simply select all faces of the top object and remove or assign one of those textures to all faces in the mesh.
     
  15. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    Tiles is right.
     
  16. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    Look what I have done in the Blend file below. I think that is what Tiles and woodln mean
     

    Attached Files:

  17. The-Spaniard

    The-Spaniard

    Joined:
    Jan 7, 2012
    Posts:
    149
    Thank you! This worked! I didn't even realise that different faces were using different textures - it doesn't say anywhere obvious (to me at least, what would be the best way to see the textures used by different faces in future?) And I don't remember setting textures to any faces purposely.

    Agreed - I find blender to be incredibly infuriating: I know it's a powerful tool, but the interface, even with the 2.5 series, never makes it clear what you must do. I've lost count of the number of times that I've accidentally pressed a button on the keyboard and caused blender to do something unintentional, with no obvious indication to what it was, or how to undo it! I try to avoid using it as much as possible, but it seems to be the only free and widely supported modelling software I can find.
     
  18. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I´m glad you got it sorted now :)
     
  19. Zaffer

    Zaffer

    Joined:
    Oct 21, 2010
    Posts:
    266
    Thanks for this thread. It helped me too!

    Zaffer
     
  20. briose

    briose

    Joined:
    Nov 9, 2012
    Posts:
    1
    Sorry for bumping an old thread but this was very helpful for us also!

    Thanks
     
  21. Ignorant

    Ignorant

    Joined:
    Jan 7, 2013
    Posts:
    6
    Hi

    I was very frustrated with this issue. Thanks a lot. But answer is simpler. Just make sure one material is assigned to your mesh in blender. Nothing more, no need even to assign other one, create third one, work on copies.

    It's quite logical in the end - two materials in Blender two materials expected in Unity :) But it wasn't trivial to find this - at least for me.
     
  22. CraftyMaelyss

    CraftyMaelyss

    Joined:
    Jul 23, 2016
    Posts:
    8
    I'm also experiencing this issue with a bridge I made in blender and trying to import it into Unity turns it into an object with submeshes that are unselectable unless you actually select them from the heirarchy and even then the texture will not align properly. The strange thing is this model is just 1 object so I don't know why it's even doing this.

    Sorry to post on an old thread(still don't know why people get made when you do) but I've been asking around for a while and I cannot find a solution to this issue, here's a screenshot:
    http://sta.sh/0tn6v7f0zzk