Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OSM Map city, 65k vertex, normals problem

Discussion in 'Formats & External Tools' started by davidezanin, Apr 19, 2016.

  1. davidezanin

    davidezanin

    Joined:
    Aug 24, 2015
    Posts:
    10
    Hi, I modeled a city in blender using Open street map data. I have only buildings (so cube, no steets or others), 27k vertex and 46k tris, in one big mesh (In this way I use only one big 4k texture, perfection is not needed but I need a lot of cities, one for each level/scene).
    I need to develop a game in unity with these buildings, but when I export fbx file unity says:

    Meshes may not have more than 65534 vertices or triangles at the moment. Mesh '82739575' will be split into 2 parts: '82739575_MeshPart0', '82739575_MeshPart1'.
    UnityEditorInternal.InternalEditorUtility:projectW indowDrag(HierarchyProperty, Boolean)
    UnityEditor.DockArea:OnGUI()

    Which is the problem? I haven't 65k vertex in blender, unity uses more tris?
    How can I solve this issue? I read that unity import also normals that increase the number of vertex.

    In blender I already check "selected objects", uncheck animation and apply modifiers. I have only cubes, 1 for each building but it's a map so there are a lot of cubes.
    In unity I have one mesh only if I set "none" instead of "import"/"calcuate" in the import fbx menu.
    I'm not a ninja in CG, and I usually import models with all it's needed (normals/materials).
    So question 1: there is a way to import also normals without increase the number of vertex?

    What happens without normals? (My idea of normals is vector of 90 degree that go inside or outside a face in the cube, so I think that are needed; for example to apply texture outside the cube and not inside, or for physic properties, or also to know if a face of the cube is visible or not. It's a stupid resume but is it right?) If are needed, there is way to recalculate normals in unity? (calculate in fbx import menu also cause the split of the mesh)
     
  2. _GimbalLock_

    _GimbalLock_

    Joined:
    Feb 26, 2013
    Posts:
    137
    Long story short, when exporting meshes from Blender any two adjacent faces that have their normal blending set to hard. The vertex is split between those 2 polygons. If the normal are set to smooth then these 2 faces continue to share the same vert. So having a lot of faces set to hard will increase the vert count. Your meshes will almost always need normal, but you could disable importing of normal and let Unity generate them. Adjust the smoothing angle for them in the import setting, that might help. But for me I would with one of the other options below.

    You could split your cityscape into 2, 4, 6, etc parts. A bit more work inside Unity but gives you control over how the mesh is being split instead of leaving it to Unity. Another option is to create a fewer number of unique buildings in Blender and use them as prefabs in Unity. You would have to rebuild the cityscape in Unity but this can be more efficient in how system resources are used. But it also depends on a few other variables.

    The easiest solution is probably to split to cityscape up into smaller grid part and import into Unity using the existing normal from Blender.
     
  3. davidezanin

    davidezanin

    Joined:
    Aug 24, 2015
    Posts:
    10
    The best practice will be using prefabs, but the city use OSM data, and these make the project harder (I need a parser etc because add-on are not mature at now) and I need to create a lot of map.
    With a blender plugin I import OSM building, I extruded and I applied one big texture. It's not the best results but it's ok. But this issue makes me crazy because if 1 cube in unity has 24 vertex instead of 8 as blender I don't know how to do.
    I don't understand 2 things, is not possible to set normals smooth?(I see the apply modifiers-smoothing-normal only function in the export fbx menu, I thought this apply modifiers increase the number of vertex, Is not right?)
    If I don't import normal, and I set calculate in unity, what change? I hope this solve the issue but the mesh is splitted also in this case.
    If there are no other solution, I need to split the map, but this is the worst solution so if there is other options please tell me!

    Thanks
     
  4. _GimbalLock_

    _GimbalLock_

    Joined:
    Feb 26, 2013
    Posts:
    137
    Sorry for the confusion, setting "smooth" can me a few different things :). In your 3D view, in the tools panel, under shading. You have the option to smooth or flatten normal. The default setting for normal is flat... Setting them to smooth blends the surface shading. It will add no geometry. That being said, smooth shading probably isn't what you want to use on the buildings. But test it out to see what I mean.

    If you don't import the normal Unity will calculate them for you. The angle value Unity provides essentially toggles between hard or smooth shading. Anything above the angle uses hard shading, below, smooth.

    Aside from the 2 previous options of either splitting the mesh into part, or rebuilding using prefabs. There are a few plugin options you could try. Map-ity & BuildR could probably help you pull off what you are trying to achieve much more efficiently. The trick being you need to have a few bucks to spend.
     
  5. davidezanin

    davidezanin

    Joined:
    Aug 24, 2015
    Posts:
    10
    Thanks!Tested, and now I understand what happened in practice! but in any case also with smooth shading unity vertex are 2*(blender vertex) why?

    My OSM map consists only in buildings: I extruded the square, so my model consist in a lot of simple cube. All the cubes are 1 single object. In this way with a big texture I have a decent and fast model of a city. I need a lot of cities, one for each scene in unity, and the programming part is more important at now. So I think this is the simplest and most efficient way for this. In any case:

    In blender
    26303vertex 17582faces 45858tris

    In unity with fbx and Normals: calculate
    Mesh1:65532vertex 39260 tris uv
    Mesh2:12864vertex 6836tris uv


    In unity with obj and Normals: calculate
    Mesh1:65532vertex 37504tris
    Mesh2:13216vertex 8354tris

    So FBX seems more efficient.

    With smooth shading (and not flat) the unity mesh is only 1 with

    57395vertex 45858tris (in any case 2*(blender vertex) and in this case I don't know why).Anyone?
    But in unity import menu I set import normals (If I set calculate the buildings became flat but I still have 2 mesh, so the trick don't work :mad:! )
    I take into account to create the city with prefab but at now I don't have time for it, and I prefer to not use paid plugins because is a project for university!;)

    Other suggests? Can I have some issue if I work with a single object splitted in 2 mesh? Is only one object so I can use 1 UV e 1big texture or I need one for each mesh?

    Thanks so much!
     
  6. davidezanin

    davidezanin

    Joined:
    Aug 24, 2015
    Posts:
    10
    If a use smooth shading I have another error, so I need flat shading. But in any case I have unity vertex= 2*(blender vertex). Normals are flip correctly so I though that the issue could be the double sided issue of a cube. I need only a single side, so in blender I enable backface culling that: Only show the front side of faces. Use this to find faces flipped the wrong way, especially when exporting to programs that use single sided drawing". But I don't see any changes in the number of vertex and I don't know why.
    Unity reconvert in double sided? Is not this the issue?

    thanks
     
  7. Birdao_Gwra

    Birdao_Gwra

    Joined:
    Oct 23, 2012
    Posts:
    29
    Just a little input, blender backface culling has nothing to do with unity. Don't export one single huge map else later you might face optimization problem. Split into separate small meshes.
     
  8. _GimbalLock_

    _GimbalLock_

    Joined:
    Feb 26, 2013
    Posts:
    137
    Polygons don't have any thickness. A normal tells the render which side of the polygon is the front. Backface culling hide polygon facing away from the camera, but it is not removing them from the mesh.
     
  9. davidezanin

    davidezanin

    Joined:
    Aug 24, 2015
    Posts:
    10
    I'm going with smooth shading at now (Even if I prefer buildings with flat shading)with splitting (Even if I prefer to use one big texture and so only one mesh). In any case my vertex in unity are 2*blender vertex. It's better than 3*, but it still 2*. With smooth shading the edges are not hard edges, so what is this last problem? Thanks for all the help. I'd like to optimize the use of vertex, because this project is for a mobile app