- Home /
Blender 2.78 Unity 5.5 the correct way to retain material/textures on import?
2017/04/20
[edit for clarification] I am not trying to import blend files into unity. As per my list of steps I'm taking, my last step was to export FBX. This is what I am using, not the blender file itself :) [/end edit]
I've done searching for this in google and here for a while now and everyone seems to say the same things, that the texture has to be saved separately in blender and placed into the material manually in unity. As well, most posts I find are for older version of unity or blender.
Now, I know I can import a model made in Blender with textures/materials intact w/o having to save a separate image. How do I know? I've done it twice, somehow. I don't know exactly what I've done that made it work. But, generally, I can't reproduce this, and it's frustrating. I'm looking for help from someone using the current version of blender (2.78) and unity (5.5 in my case), that also knows the correct steps to make this happen.
Here's what I'm doing :
Make model in blender.
Add new Material to the object (w/ object selected, in Properties->material - assuming one hasn't already been assigned)
Add new Texture to the object (Properties->texture, click on empty slot, click new, then under image mapping->coordinates: UV)
In edit mode, mark appropriate edges as seams
In UV/image edit pane, make new texture
Select all of model, then UVUnwrap
In UV/image edit pane, go to paint mode and paint texture
Under UVs, pack as PNG.
Back in properties->textures, under the Image section, I click the browse image to be linked, and select my newly painted texture.
Export to FBX.
After import in unity, no texture :( I really don't know what I did those two times I got it to work. I've been trying for about a month to get this to work again, where I can reproduce it, and no go.
Hi @AnOrdinarySandwitch, packing textures is saving texture to blend file, not to exported file.
Hi $$anonymous$$amil! Thanks for the comment :) I know that packing saves the image in the blend file, what I'm looking for is retaining it in the exported fbx.
I see lots and lots of older posts that say oh you can't there's no way but I beg to differ as I have somehow managed to do it twice! :) And if it can't be done at all as those posts suggest, then $$anonymous$$aya couldn't do it either. As well, in Unity, I can preview fbx imports that show their textures, while others don't.
Oh, and there's no 't' in my name :)
Sorry for T :D From my experience I can say you just saved image in your asset folder when it was working.
Answer by AnOrdinarySandwich · Apr 26, 2017 at 04:11 PM
Well, I guess this is the best I'll get. For everyone out there asking this question time and time again, and getting the same old tired responses, I logically thought there has to be more to it, but I guess not.
Anyway, thanks to the two who took the time to reply.
[update 2017/04/26]
I made a discovery today that answered my question and will give everyone seeking this solution a REAL answer for importing textures to Unity from FBX made in Blender. No you don't have to save out separate image files.
Here's how to do it:
After making your model and assigning materials/textures, make sure it looks good in texture mode, then:
Go to export -> FBX.
Make sure FBX 7.4 Binary is selected
Look towards the bottom of the "Export FBX" options, and locate "Path Mode". Set path mode to "Copy", and then click the little icon to its right, so that its background is darker (a little page icon will appear on it). This copies the texture data and embeds it into the FBX file.
Save the exported file.
Now, when you import this into unity, the model.fbm folder will be generated, and the textures will be intact on the model. I just tested this with a new model in a new project and it worked like a charm! No separate image files needed!
And the textures get imported to Unity as well? Can you verify on an empty project?
I did that before I wrote the reply :) (for clarification, a new empty project is what I meant by "new project" above)
There is an option in Blender to pack textures anyway. You find that option in UV window menus. Have you tried this? In Conjunction with selecting the correct data storage mode (object/block etc), you may not need the copy option. 'Path $$anonymous$$ode' seems to be a previous missing link in making this work. Others also mention that Baking in Cycles also works. +1'd for excellent work.
Also it should be mentioned, that this only works on Blender Render engine, not on Cycles Render as of now (2018/09/09)
Answer by AnOrdinarySandwich · Apr 21, 2017 at 11:12 AM
I've been thinking, trying to remember everything I did and tried when I got it to work with an FBX. I don't recall saving out the image file, but I can't say definitely I didn't either.
I hate to admit defeat when I've been so sure it was possible! lol But at least not having to manually assign textures to albedo's for every model import is a step in the right direction.
Thanks, Zilppuri, I'll contemplate this and see if I can't find my old project files for comparison.
Answer by ambareeshsrja16 · Jul 17, 2019 at 05:52 PM
@dansopanso Did you figure it out with the latest Unity? I'm not able to do it either!
I am not able to read the comment replies here, is there a setting I need to activate?
Answer by Zilppuri · Apr 21, 2017 at 10:25 AM
You can't embed image data in .blend file and import it to Unity.
You can have a Texture/Material name in a .blend file that corresponds to a image file in a subfolder. Unity will automatically create a material with the Texture/Material name in the .blend and create .mat files to match. If a corresponding image file is found, it will also auto assign that.
So: 1. Unity searches for a .mat file with matching name as .blend files texture/material 2. If no .mat file is found, it creates one. If image matching the material/texture is found, it is used when creating this material
So if you simply match your texture/material names and have the image files in correct folders (or adjust the import settings), then the textures will be retained.
What you might have done, is exported an fbx file, where the correct images have been exported to filename.fbm folder, where Unity could have looked them up when creating the necessary material files.
@Zilppuri & @$$anonymous$$amil1064,
Through my current research, I came across a post about this topic from around 2011 (sorry, I can't find that post anymore) where someone much later casually commented (in 2014) that FBX added embedded media support into the file itself. To support this, according to this older version of blender's fbx export documentation, the fbx format does indeed store texture data in it, as well as material<->texture connection. Additionally, from the video link I posted in a comment above, $$anonymous$$aya can do this as well. And, user $$anonymous$$ in this blender stack exchange post answers a slightly different question by saying the fbx exporter packs textures used by the model, indicating that yes FBX files exported from blender can include not just materials, but textures as well. And one more bit of evidence that FBX can include textures that get imported in another program/engine, this older post from 2014 about FBX importing into Unreal Development $$anonymous$$it (Unreal 3 Engine), $$anonymous$$itchell Stokes says "Just confir$$anonymous$$g that the Embed Texture option works with packed textures []" (in regards to exported FBX from blender into UD$$anonymous$$ with textures intact).
So, where lies the issue? Has blender's modern version of export FBX broken the embed media? Does Unity just not understand the embedded media? Is it embedding the wrong format of texture? I still say it should work, based on all this!
Answer by dansopanso · Jan 03, 2019 at 04:40 PM
Is this still working in with Unity 2018? For some reason there is no materials folder generated when I import the fbx. I followed the steps accordingly to the post :/
Hi! To be honest, I don't know! :( I haven't had any time - since Unity 2018 came out - to do much work with fbx imports. I'll try to make time to see about this, but if someone active in 2018 could test it and post their results, that'd be awesome!
@Extrumus Does the Rendering Engine make a difference when doing the fbx export? Didn't know that... I think I'm in cycles but do you suggest to use blender render ins$$anonymous$$d?
Cycles looks better and more realistic, but takes longer to export it into unity (uses image baking), blender render looks rough, but is easy to export. Pick your poison
I don't have any problems importing textures and materials from blender-exported fbx files in 2018. I do a lot of import/edit/export on models I purchase too. Oh and I wanted to give a little something-something here for anyone who works with importation of fbx files into blender and doesn't have a way to multi-import. I've taken a script I found online and got it to work using a set path where the fbx files are stored. The script:
import os
import bpy
import sys
import logging
vImportPath='C:/Full/Path/To/Location/Of/FBX/Files'
bIsPath=os.path.isdir(vImportPath)
if not bIsPath:
logging.warning('invalid path')
logging.warning(vImportPath)
exit()
vFileList = sorted(os.listdir(vImportPath))
for vItem in vFileList:
if not (vItem.endswith('.FBX') or vItem.endswith('.fbx') ):
continue
fullFilename = os.path.join(vImportPath, vItem)
logging.warning('importing'+vItem)
bpy.ops.import_scene.fbx(filepath = fullFilename)
How to use it:
In blender, open a text editor area/window. Then, paste this code in. Then, set the variable 'vImportPath' to the location where your fbx files are located. Then click the 'run script' button at the bottom. It may take a while if there are a bunch!