Search Unity

Blender to Unity

Discussion in 'Asset Importing & Exporting' started by Gnaws, Aug 30, 2008.

  1. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    I'm trying to export .FBXs created in Blender to Unity. I converted the mesh to tri's before exporting. The .FBX file name corresponds with its respective texture file, but Unity says it's an "unrenderable mesh".

    ?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Don't export to FBX; just save the .blend file and use that. Also not necessary to convert to triangles, unless you're using curves or other non-polygon objects.

    --Eric
     
  3. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    I understand what you're saying. And that is exactly how we bring in our normal game assests.

    However, from what I understand, we're trying to make custom "tree" brushes. The examples given from Unity were .blend meshes converted to tri's and used PSDs with alpha channels. I believe it's for some sort of terrain generator allowing one to paint on trees, rocks, etc.

    This is what I'm trying to accomplish...with little luck.
     
  4. donjuan

    donjuan

    Joined:
    Dec 21, 2007
    Posts:
    67
    Hi, I successfully imported blender trees to the unity terrain. First, I create the meshes using the excellent NGPlant. The models were exported to blender as .OBJ Second, I textured the leaves and bark just opening the texture in the UV Layout (some adjustments were needed). Then, all the different meshes of the model were assembled in a single mesh using ALT + J. Everything was imported to unity in the ambient occlusion folder. The tricky part was figuring out what file use to add the tree in the terrain. Here is a picture showing the right file. I think this is all what I did and everything went smooth...
     

    Attached Files:

  5. donjuan

    donjuan

    Joined:
    Dec 21, 2007
    Posts:
    67
    Ahh, forgot to tell that was not necessary neither to convert to triangles nor to export as .FBX
     
  6. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    Thank you very much, donjuan! We'll give this a try and will let you know the results.
     
  7. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    Well that sent us in a direction that seems to work. It appears that we require a separate PSD, and corresponding UV for each texture. IOW, a tree with two textures needs 2 UVs, one for the leaves and one for the trunk. The .blend files are then imported into Maya and exported as an .fbx.

    If there's a faster way to achieve the same result, we'd love to hear it.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not sure why you're importing/exporting...just use the .blend files directly in Unity.

    --Eric
     
  9. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    Hi Eric - we can indeed open .blend files fine in Unity when used for conventional game assets. But we'd like to make custom brushes(?) that allow us to "paint" trees, rocks, etc. Apparently there are other provisions one needs to make when using .blend files to create these brushes. Hence, all the import/exporting.
     
  10. GusM

    GusM

    Joined:
    Aug 27, 2005
    Posts:
    585
    You need two UVs for the two materials a tree brush needs, one for the transparent leaves and other for the trunk. This can be easily done in Blender. And you can use the blend file directly inside Unity, no need to use Maya at all. Just remember the file you should select as a brush, as mentioned earlier in this same thread.
     
  11. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    So two separate meshes (in the blend file) each with its own UV map and texture? The meshes don't need to be joined?
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Nope...one mesh, with two UV sets and two textures. There's nothing special about tree meshes compared to any other game assets that use more than one material.

    --Eric
     
  13. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    Well I guess this is what was/is messing me up. I wasn't aware that a single mesh could have multiple UV maps.

    ...edit....

    when you say "two UV sets" do you mean 2 different UV materials?
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Actually you don't physically need to add another UV set (though it can be done, usually for lightmapping). Just use two textures on the mesh.

    --Eric
     
  15. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    Thanks Eric. I'll give that a try.

    Can you give me a clue on how I would duplicate(?) the UV set?

    Thanks so much!
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Really, you don't need to do this. :) Getting stuff from Blender to Unity is so trivially easy that I think maybe some people overthink the process. On the tree mesh, select all the vertices that you want to have the bark texture, then load in the bark texture in the UV map screen, then repeat for the leaf texture. If the trees were made in Blender, this should already have been done as part of the UV mapping process. Personally, I keep the two as separate meshes for ease of dealing with them initially, then combine the two meshes into one (although it's simple to select faces by texture too). Save the .blend file in the appropriate place, and you're done, except to make sure that the materials in Unity are using the nature/soft occlusion shader. Also make sure to use the correct file as donjuan pointed out.

    --Eric
     
  17. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    This is what I get (and what puzzles me about) joining 2 meshes. Each with it's own, unique UV map.



    It renders fine in Blender, and this won't be a problem for Unity? Even tho now the new combined texture has the same name?
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    In this case the UV map doesn't actually matter...it's not like lightmapping where you need two separate and distinct UV maps. The only thing that matters is having two textures.

    You shouldn't have a combined texture. You want one texture for the bark and another for the leaves; load them from where they are saved in the textures folder in the trees-ambient occlusion folder.

    --Eric
     

    Attached Files:

  19. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    yet

    I guess I'm completely lost.
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You're just combining the meshes...there's no combined texture. Try it, it just works. :)

    --Eric
     
  21. donjuan

    donjuan

    Joined:
    Dec 21, 2007
    Posts:
    67
    Hi, maybe this tree from my project can help you
    Juan
     

    Attached Files:

  22. GusM

    GusM

    Joined:
    Aug 27, 2005
    Posts:
    585
    Beginning with two diferent meshes, each one with his own UVmap and his own texture, join them together in only one mesh. Then select this single mesh and enter edit mode, deselect all and select just the leaves polygons: you should see they are still referencing the leaves texture you added them when they were a separate mesh. Then deselect all again, and select only the trunk polygons: you should see how they are still UVmapped to their original trunk texture.

    If you then select all the mesh, you will see again the same effect you showed: Blender displays the 2 UV map sets, one over the other, and only shows one texture. Ignore this, it is just an effect of Blender not being able to show the two pictures at once (I guess), but it will not be shown this way once corectly settle up inside Unity.

    Just open the file from the Ambient Occlusion Folder in your proyect, it should have two materials. Load the two textures from the same folder and make sure you use the two tree shaders with them as needed.

    I hope this helps.
     
  23. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    Thank you SO much, Gus. This now makes sense. I was banging my head trying to figure out how to "duplicate the UVs"!?! It did seem odd to join the meshes like that and yet still have it render properly in Blender. But that's what it seemed like everyone was suggesting. But now I know to just ignore all that over lapping mess...I MEAN...mesh.

    Thanks again.

    @donjuan - thanks for the tree. :wink:
     
  24. polytropoi

    polytropoi

    Joined:
    Aug 16, 2006
    Posts:
    681
    For large scenes, try the same technique of joining separate objects after they've been UV mapped - this speeds things up in unity (one big mesh is faster than lots of smaller ones) and each mesh's material will show up in the inspector. You can also assign new materials to the same mesh in Blender using vertex groups and material indices.

    Also, now that you've got your arms around Blender's UV system, try the Texture Baking utility - great for procedural textures and lightmaps. Lightmapping is important: makes things run faster and it looks better.

    Good to know there are more Blender + Unity folk in Austin! Maybe we need to make a Centex UUG (Unity User Group)...
     
  25. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    gyack! I've only been using Blender for about 6 weeks. Obviously there's still much to learn.

    At Stubb's!!!
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Just to nitpick here, having one object with multiple materials isn't particularly faster than having separate objects; essentially it's the same thing when rendering. You only get real speed improvements when joining separate objects if they share the same material.

    --Eric
     
  27. polytropoi

    polytropoi

    Joined:
    Aug 16, 2006
    Posts:
    681
    good to know, thanks Eric!
     
  28. e1

    e1

    Joined:
    Feb 9, 2009
    Posts:
    8
    Why are simple things so difficult
    I export a blend file with just one simple mesh into my unity assets folder. Unity updates the new asset and I can see my object nested underneath the scene name node.

    I drag the object into the scene and try to load it up as a tree. It loads even though no icon shows up in the terrain paint palette. When I paint my object/tree onto the terrain my object is lying horizontal instead of upright

    Any ideas / Thanks
     
  29. Digitalos

    Digitalos

    Joined:
    Jun 1, 2009
    Posts:
    112
    This^^

    Also I get the same problem where the object is nested under the scene name node, how do I use that in the terrain editor, since it complains there is no mesh renderer on it - which is of course correct.

    All the Unity trees have the root object with everything on it, and only the physical mesh nested under that. >_>

    EDIT:
    Wow, sorted it out as soon as I posted this. >_<

    So, for future reference for people who are also stuck:

    1) Blender's y axis is not Unity's y axis. Make sure you rotate your trees in Blender and scale them to the right size, and then select your object and hit CTRL+A in order to apply scaling/rotating to the object - else Unity will pretend to know nothing about it.
    2) You can't select the trees from the normal list like you do with the Unity trees, so you need to click on Edit Trees/Add Tree as per normal and then drag the file that the earlier poster indicated into the little window that pops up.

    I would still like to know how to get that working properly - it's obviously possible as Unity have it working with their trees, so why do trees in blender export with an extra parent compared to theirs?
     
  30. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
    I got my tree from Blender 249b into Unity O.K. it was standing
    vertical. I had to 'export fbx' because I had a lot of extra stuff in
    my blend file I didn't want saved in the /assets folder. But I'm
    getting that 'no valid mesh renderer' when I try to make it an
    instance for the tree painter. I can only add them 1 by 1.
     
  31. undiluted

    undiluted

    Joined:
    Mar 23, 2010
    Posts:
    2
    I'm having the same problem as hike1.

    I've tried both an FBX and a .blend file. They're inside a folder titled "Trees Ambient-Occlusion". They have two texture setups in both the FBX and the Blender file. They are correctly scaled for import. I've tried using PNG and PSD for my bark and leaves textures. I've tried reimporting stuff. I've also tried making a prefab out of these, and having the tree editor use the prefab.

    And yet, despite all this, I still get "The tree couldn't be instanced because the prefab contains no valid mesh renderer."

    I've also tried slapping extra mesh-renderers onto frickin' everything, one at a time, in hopes it would work...but no luck.

    Why isn't this working? Please help!!!