[Addon] Blend2Unity

Hi,

I came up with this addon while working on my recent project.

“Export to FBX” button allows to export models to FBX with proper transformation and preserved smoothing groups. It also sets the pivot on the lowest vertex and provides the possibility to export as one file or multiple files.

“Convert map only” button converts Roughness map to Smoothness as Base Color or Metallic alpha channel.
“Export unitypackage” allows to export model with textures (converted roughness to smoothness as alpha) to single *.unitypackage file

Limitations:

  • To properly export Unity Package file you have to use Blender in version 2.79 and Principled BSDF shader. You will get best results with textures connected directly to Prinsipled BSDF node (without rgb curves, color ramp etc., normal map is an exception). The addon searches for maps connected into following inputs: Base Color, Metallic, Roughness, Normal
  • Converting Roughness to Smoothness requiers a lot of calculations and it’s a time consuming task (approximately 30 seconds for 4k texture) so don’t worry if Blender will look like it stuck.

Addon can be downloaded here:

https://i.imgur.com/yOZipIu.gif





Wow
this is incredible!

Man, firstable, congratulations for this addon, looks really great.
But sadlly i was unable to use. I setup the model, materials and textures. And i get this error:


I’ll be really glad if you could help me!

Thanks for your feedback! I’ll get into this problem and post here with update on the addon :slight_smile:

I’ve updated Blend2Unity addin support for materials without roughness and metallic maps. It should solve the error you’ve posted.

Perfect!I saw that you’ve updated. And I already downloaded, it works very well now! Thank you for your quick support and attention.

This looks interesting even though there is no need to ever convert anything to fbx when working with Unity if you just know how to fix the outdated Blender conversion script that comes with Unity.

With this addon, can I also just export textures? It’s the feature I am most interested in.
(Or is there perhaps another addon that does only that?)

Thanks. We use thes FBX Exporting feature to generate large number of separate model files with fixed somoothing groups, etc. which is requirement in my companys pipeline. Maybe someone else will find it usefull although as you mentioned it’s not necessery when working with Unity.

Yes, you can export textures as addition to your model using “Export unitypackage” button. Unfortunately textures will be packed in *.unitypackage file. You can also export only Albedo+smoothness or Metallic+smoothness maps with “Convert map only”. Both features requires Principled BSDF shader. I’ll take your note into consideration and prepare function that will export entire set of textures without packing them into *.unitypackage.

That would be great. Thanks. (How hard is it for a non-coder like me to learn how to script an addon like this?)

Hi,
I’ve added the feature you’ve requested for. Now you are able to export set of maps (Albedo+Smoothness, Metallic, Normal) without the necessity of packing them into *.unitypackage.

Answering your question. Hard to tell, as I’ve been into programming in different languages for a long time. Ofcourse i believe that if youre serious about it and youre willing to spend some time on learning, you’ll be able to achieve desired skill. Also in my opinion python is one of the easiest and fastest languages to learn.

If only I could have this addon a several month ago.
Good job, man, you’re my hero)

Basically the automatic conversion that unity does is calling blender with a the Unity-BlenderToFBX.py file as parameter. If you modify the python file to call this exporter instead of the standard one, it should work.
For me the file is in C:\Program Files (x86)\Unity\Editor\Data\Tools

However be sure to also have the file somewhere else as every subsequent update of Unity will overwrite the file.

Great to know. I’ll definitely check it out.

hi, would you be interested in submitting your addon here:
https://developer.blender.org/maniphest/task/edit/form/3/
we already have https://developer.blender.org/T52622 proposed for unreal
maybe these type addons can help reduce software specific workflow issues with .fbx

Oh this sounds like you were not even familiar with this file being there and doing what it does. I mentioned it in one of my earlier posts, and since you didn’t ask I was sure you’d already know all about it.

Really the only workflow problem that Blender currently still has with Unity is this conversion file (Unity-BlenderToFBX.py) that comes with every version of Unity.
It’s still based on pre 2.5 Blender and converts blend files to fbx really poorly. (It doesn’t even fix the axis problem which is rather ridiculous.)
We’re using a heavily modified version of this python script at our company, and auto-conversion of blend files inside of Unity is 100% perfect for us. Not a single thing that doesn’t work, no need to ever export anything to fbx manually. Additionally every developer should have a custom editor script in their Unity project to control how Unity handels Blender materials on import. And then all matters should be taken care of.

None of these things can be handled through a Blender addon though.
So the best I am getting out of your addon is really the PBR texture set generation.
It’s up to the Unity developers to fix the rest.

1 Like

Yup, that would be great if Unity developers would fix that. As I said before, exporting to fbx (as multiple files) was required and specific to workflow in our company (which considers also another software in addition to Blender and Unity), I left this as an additional function to this addon but if it confuses it’s users I can remove it. The proper conversion of PBR textures and managing material settings in different setups are my main focus in development of this addon.

I haven’t forgotten. I just wanted to elaborate on that import script that comes with Unity.

Even though it is not possible now, do you have any plans to make color manipulation nodes (RGB Curves, Color Ramp, MixRGB etc.) work in the future?
I don’t know the first thing about addon coding, but shouldn’t Blender be able to compute and export whatever goes into the Base Color input of the BSDF regardless of what nodes are involved? After all, Blender’s standard Bake function does just that if set to “Diffuse”. Just asking.

PS: Shouldn’t the addon be able to create the export folder by itself in case it doesn’t exist, instead of throwing an error as it does now? Or is that simply a limitation of addons in general? Blender’s render output can do it.

PPS: The Blender version in your script is still set to (2, 7, 8).

It requiers different approach but it’s possible and yes - I do plan to add this functionality.

Thank’s, I’ll correct it.

Fixed those and updated addon on gumroad. I’ve also created a github repository: https://github.com/JohnnieWooker/Blend2Unity

Hi,

I’ve updated the addon providing the ability to change the exported texture resolution.
You can choose “Relative” to export the same resolution as the parent teture or “Absolute” to set fixed resolution of exported texture.
Latest version also works with color manipulation nodes but it slows down the process of texture export. To recalulate the nodes for the new texture you need to check checkbox in “Recalulate” panel.