Search Unity

Blender and textures

Discussion in 'Asset Importing & Exporting' started by atmuc, Dec 23, 2011.

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i use blender 2.61. i packed textures in blend file. i copied my blend file to the unity assets folder. unity can import models and materials. i can not import packed textures.

    i also tried to unpack textures to ./textures folder. blend can use textures from this folder. i copied both blend file and textures folder. unity can import model and materials. i also finds textures in texture folder, but it can not assign my textures to imported materials.

    what can i do?
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If you select the material in Unity, you should see all the textures it needs in the inspector view. In the texture slots of the material, you need to click "Select" and choose the texture it needs. But it somehow sounds as if you already tried that...
     
  3. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    yes i tried this workaround. if i have 20 textures it is problem :) i try to find a way to import textures paired with materials automatically
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It mostly works if you do everything correctly in Blender. You need to set up your material in Blender and assign the texture using relative path I think. I am not sure at the moment how it works correctly, but it does at least for the first texture of your material. (I haven't found a way that automatically uses the second texture automatically as bump map yet.)
     
  5. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I was once told by one of the Blender devs not to use packed textures when exporting from Blender to fbx. But to unpack the textures before exporting. Note that the Obj importer of Unity is faulty. It just supports one material. When you import a Obj file with more than one texture then you will be in trouble. The not assigned textures are the smallest problem then. You will most probably loose a material though. FBX is the way to go with meshes that has more than one material/texture.

    One more thought, i never import the Blendfile. I import the fbx. I change the Blender versions too often, i grab them from Graphicall every two or three days. And then i would need to reconnect the file format with this new version again and again. Anyways, maybe there`s also a problem with the import of blend files.
     
  6. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i tried exporting fbx. there is no info in fbx about texture file. is there any way to export model from blender to unity with texture mapping. i dont want to select each texture for each material on unity.
     
  7. ivanzu

    ivanzu

    Joined:
    Nov 25, 2010
    Posts:
    2,065
    Here:
    1.Drag 2 Textures inside unity.
    2.Export the model from blender in FBX format.
    3.When model is imported unity will auto set the textures to corresponding materials.
     
    Last edited: Dec 24, 2011
  8. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    There should be a link to the textures stored somewhere in the fbx file. The textures are not stored in the fbx file.

    Note, unfortunately you have to tick selected object all the time in the export form. You don`t want to export the camera and the lights too. And blender doesn`t store its settings.
    Note 2, when you export a rigged character, then it`s not enough to select the top hierarchical object, but you also need to add all the meshes in the hierarchy by holding down shift and clicking at them.

    Hm, when you are still in trouble, maybe you could attach an example, with both, the source blender file plus your exported result (don`t forget the textures), and we could have a look what results we get with an export.
     
  9. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    this is my sample project. i used 2 textures and exported fbx in export folder. there is no declaration about my texture in this fbx file. what do i do wrong?

    View attachment $test.zip

    Edit: i also tried to put textures and then this blend file to unity. it cannot set textures automatically.
     
    Last edited: Dec 24, 2011
  10. jake-gr

    jake-gr

    Joined:
    Oct 27, 2011
    Posts:
    93
    This is a sad fact for Blender and Unity, there i no way to copy over textures automatically (that I have yet to find)

    One solution is to manually copy the texture files into unity, then save your .blend in the Assets folder, and assign the textures inside Blender (using the ones from your Asset folder)

    The solution I use myself, is save the .blend file in the Assets folder, then when I assign a texture in Blender (from a folder outside of Unity), immediately after assigning the texture, I pack, then unpack (into the Assets folder)
     
  11. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    @Jake-GR your solution did not work for me. what version of blender do you use?

    do i have to use uv mapping?
     
  12. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You always have to use uv mapping in the Blender to Unity pipeline! There is no way around it.
     
  13. jake-gr

    jake-gr

    Joined:
    Oct 27, 2011
    Posts:
    93
    right, you have to use UV mapping (not blender materials), and im using 2.61 right now, i havent used 2.49 in a long time so not sure if it works the same with that
     
  14. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Same in 2.49. What arrives in Unity is the UV Mapping plus the texture, not the Material. No UV Mapping means nothing arrives in Unity. That counts for every 3D app, not just for Blender.
     
  15. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    then my problem is not using uv. now i set uv map map and it doesn't appear work on unity. i deleted and copied blend file again and it works now. reimport doesnt work. once it create a material it doesnt apply new texture settings to this material.

    also preparing uv map is harder than preparing blender materials. i have to choose the best resolution for my uv map. now i start with default 1024x1024.
     
  16. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Those two things are two different tasks. You cannot compare apples with bananas. I would suggest to learn a bit more about making 3D graphics.
     
  17. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i think i could not express myself :)

    i have a model and materials on blender. when i render it i have a result that i want. then i want to export this model with materials. there is a restriction like UV mapping. then i have to prepare uv mapping file. if unity did accept blender with its material system, my world would be easier.

    saying blender material i mean; "create a material, create a texture, apply this material to selected faces.". using uv mapping is not as easy as this. am i wrong?
     
  18. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    atmuc

    I am a Blender user as well. Let me describe MY workflow.

    1. First I create the model in Blender along with the material and textures MAKING SURE that they are UV MAPPED.
    2. Then I use the fbx exporter provided with Blender to export my model to an fbx file.
    3. Then I open Unity. Usually I create a new folder for the model I am about to export.
    4. Then I import the fbx file into unity.
    5. Then I import my textures separately
    6. Finally what I do is, I go to the Material that Unity creates AUTOMATICALLY while importing the Fbx, then apply my textures to that material

    So far, this works for me 100% of the time
     
  19. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    Unity does NOT accept Blender's material system. (Another way to put it would be to say that Blender Material is not the same thing as Unity Material).
    Unity DOES ACCEPT Blender's UV mapping.

    UV Mapping is not hard at all. Once you learn the basics, you will find that it is way more easier than procedural textures (the one you are doing in blender right now).
     
    Last edited: Dec 26, 2011
  20. Mr.T

    Mr.T

    Joined:
    Jan 1, 2011
    Posts:
    546
    One more thing before I go.

    It is possible to BAKE the procedural textures in blender into an image file.
    Once that is done the model with the baked image applied as the texture after UV mapping will closely resemble model with the procedural textures you used but may not be exactly similar.

    But in order to do that, once again you will first have to learn UV mapping and then also learn how to bake textures. (Both are easy to learn if you are willing to spend one or two weeks time on them. You will pick up the basics and get better with practice)
    So in other words, if you want to create good 3d models, all roads lead to UV mapping.
     
    Last edited: Dec 26, 2011
  21. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Yes. As told. You cannot compare bananas with apples. Material != UV Mapping.

    Unity, like most 3D realtime engines, just accepts UV mapped meshes with textures. Procedural shaders and materials are simply too cpu heavy for realtime. Material does not transfer, from no 3D app. What transfers is the Mesh with its UV mapping, and the information what texture gets used. The by Unity applied diffuse shader is a Unity standard material then.

    When there is no UV mapping, then you will also not see a proper texture. But in best case the colour of one pixel of the texture.
     
    Last edited by a moderator: Dec 26, 2011
  22. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    thanks you all. with your help, now i know what to do.
     
  23. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    now my workflow is like that;
    i prepare my materials and apply them to the faces. then bake texture to uv image. then i set this uv image to my mesh as texture.i copy both blender and uv map file to unity assets folder. it works.

    one question;
    i dont want to loose my material mapped mesh on blender. for changes i want to edit material and bake again.
    i can duplicate my mesh and apply baked uv to this mesh to export. is there any way to keep both materialized and uv mapped except duplicating mesh?
     
  24. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You may have both materials in the same object within Blender and just enable the one you need. As it comes to baking, you still need to duplicate the object, but you can remove it afterwards without loosing anything.

    WARNING: UNTESTED!