Skip to content

SirKioi/UnityUFBXImporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ufbx Importer Tools for Unity

Unity's FBX importer is bad at blend shape normals. This package fixes that part without trying to replace Unity's whole importer.

On FBX import, Unity still does the normal model import. After that, this tool runs a native converter built on ufbx, reads the converted mesh data from a temporary binary file, and swaps Unity's imported mesh data with the ufbx version. The rest of the import stays Unity's.

The main reason this exists is blend shape normals. Unity either doesen't import them properly or recalculates them without taking into account custom normals causing obvious shading artifacts. The native converter can recalculate them from the actual mesh topology using control-point based, angle-weighted normals, which preserves hard edges and seams and custom normals properly.

What It Does

  • Replaces imported mesh data inside Unity's FBX import with mesh data parsed by ufbx
  • Preserves normals, tangents, vertex colors, submeshes, skinning, bind poses, blend shapes, and all UV sets (up to 8 because of unity limitations)
  • Supports blend shape normal recalculation in the native converter
  • Lets you whitelist blend shapes that keep normal deltas, stored by blend shape name
  • Defaults to stripping blend shape normals unless you explicitly keep them (default unity legacy blendshape normals behaviour)
  • Can zero tiny blend shape position and normal deltas with configurable thresholds for optimizing memory
  • Can strip all-white vertex colors
  • Can generate tangents in Unity if the FBX did not provide them
  • Stores per-asset overrides in the FBX .meta file so they travel with exported packages

Settings Window

Open Tools > ufbx Importer.

The window gives you:

  • A searchable list of FBX files
  • Global import settings
  • Per-asset overrides
  • Per-blend-shape normal selection with search
  • Batch reimport for checked FBXs or the whole list
  • An import log with mesh counts, verts, tris, blend shapes, memory estimate, duration, and result

Per-asset overrides are written into AssetImporter.userData, which means they live in the .meta file of the FBX and can be exported in a unity package, FBX with this data will also be automatically imported with this tool if it is available.

Installation

Use whichever packaging route you want:

  • Copy unity/Packages/com.ufbx-importer.tools into a Unity project's Packages/ folder
  • Export it as a .unitypackage
  • Wrap it as a VCC/VPM package and publish it through your own listing

This repo itself is just the package and native converter source. It does not include a published VCC listing.

Building

The package looks for ufbx2unitymesh.exe in Editor/NativeBin~.

ufbx is included as a git submodule. When cloning, use:

git clone --recursive <repo-url>

Or if you already cloned without --recursive:

git submodule update --init

To build, open a Visual Studio Developer PowerShell (or Developer Command Prompt) and run:

cmake -S native -B native/build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build native/build --config Release

The CMake build copies the executable into the Unity package automatically.

Requirements

  • Unity 2022.3+
  • Windows

License

Uses ufbx under MIT.

About

A Unity Importer post process tool that imports meshes using ufbx with controll for better blendshape normals

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors