UnityGLTF
UnityGLTF copied to clipboard
Culmination of two years of fixes, especially for export
The UnityGLTF repo has been stale for around 2 years now. This is approximately the same time when we (prefrontal cortex) started working with glTF extensively, and thus we forked this repository and starting to improve things. There have been more than 300 commits since then, numerous features have been added, and most notably, the package has been used in many productions and battle-tested, especially for exporting glTF files from Unity. Early on, we tried to PR our changes in small chunks, but it soon became clear that the repo was abandoned. This PR moves all of our changes over to the main repository and effectively promotes our fork, so that veryone can benefit from the changes done so far.
State of glTF in Unity
UnityGLTF hasn't received official support since early 2020. However, a number of forks have fixed issues and improved several key areas, especially animation support,export workflows, color spaces and extendibility. These forks have now been merged back into main so that everyone can benefit from then, and to enable further work.
A separate glTF implementation for Unity, glTFast, is on its path towards becoming feature complete, with import already being complete. It leverages modern Unity features such as Burst and Jobs, has better compression support (importing compressed textures and meshes), and also has wider Render Pipeline support, notably supporting URP and HDRP import (and partial export).
glTFast and UnityGLTF can coexist in the same project; you can for example use glTFast for import and UnityGLTF for export, where each of these shine. In fact, we've been contributors to both projects.
- UnityGLTF has very good export support (runtime, editor, animations).
- glTFast has better general import support (compression extensions supported, SRP support).
- If you're playing with custom extensions, UnityGLTF might still be the right choice for import.
Notable changes
- editor animation export support, originally based on a Sketchfab fork but much improved
- runtime animation export through Timeline Recorder Tracks and also via API
- proper colorspace export and import, for colors, vertex colors, textures, emissive, ...
- export of arbitrary textures, readable or not, including RenderTextures
- exporting blend shapes and blend shape animations with sparse accessors
- numerous hooks for custom extension export (still work in progress – the goal is that what's needed for custom extensions is made public)
- support for KHR_lights_punctual, KHR_materials_unlit
- restructured as UPM package (proper repository restructuring and modernization can happen after this PR)
- GLTFSerialization is now an AsmDef, not a separate sln anymore (easier cross-platform development)
- removed embedded Newtonsoft.Json, using the one from Unity's registry now for better compatibility with other packages
- ability for in-memory export of GLB files (relevant for WebGL and other platforms with limited filesystem access)
Notable things that haven't changed
- still not fully spec-compliant (see Known Issues)
- mixed bag of features that are supported on export and import
- no URP/HDRP import support – use glTFast if you need that
- no support for Draco, Meshopt, KTX2 import or export – use glTFast if you need that
How to test this PR
- Open
Window > Package Manager
- In Package Manager, click + and select Add Package from git URL
- Paste the following link to the dev branch of this repository:
https://github.com/KhronosGroup/UnityGLTF.git?path=/UnityGLTF/Assets/UnityGLTF#dev
- Click Add.
Once the PR is approved, the package will be updated on OpenUPM as well for easier consumption (no git installation required).
Example exports
All these projects have been exported with our fork of UnityGLTF:
- https://sketchfab.com/3d-models/biolum-meet-the-giant-isopod-b5cbe237dd554396bf99bdff44601060
- https://gruen.deutschebahn.com/de/dialog/apps/umweltrallye/station2
- https://prefrontalcortex.de/projects/siemensstadt/
- https://bike.needle.tools/
- https://songsofcultures.com/en/ar-collection
and many more.
Next Steps
This PR is now up for feedback. The changes that were made over the last 2 years tried to keep the repository structure the same to make eventual reviewing easier. Whoever has concerns about the general idea of promoting this fork to main: please let me know, now is the time!
Full changelog with ~35 internal releases: https://github.com/prefrontalcortex/UnityGLTF/blob/master/UnityGLTF/Assets/UnityGLTF/CHANGELOG.md
The goal is to merge this PR in ~1-2 weeks.
This PR has been made possible by prefrontal cortex and Needle.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.
:white_check_mark: hybridherbst
:x: pfcDorn
pfcDorn seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.
Added a couple more commits that have fixed issues people brought up (some of them old, some of them introduced by the PR). I'd give it another few days for public testing and then merge back to master and properly set up OpenUPM releases :)
One bigger (kind of unintended) feature that now works is WebGL platform import support (which seems to have never been working before). So now WebGL has runtime import + runtime export, including animations, same as other platforms.
Amazing, so gltFast is included here as well?
P.s. just read more carefully, they are compatible. Still, amazing progress!
Big update that actually brings UnityGLTF back to being state-of-the-art in some areas!
- experimental support for KHR_animation_pointer export
- upon popular request, experimental URP (2020.3+) & BiRP (2021.2+) Shader Graph for export and import,
UnityGLTF/PBRGraph
- approximated support for exporting and importing KHR_materials_transmission, KHR_materials_volume, KHR_materials_ior, KHR_materials_iridescence
- renderer features and post effect for rough refraction / transmission (for URP and BiRP)
Additionally, some more fixes went in for camera/lights export and import, material export heuristics, and helpful things like ProfilerMarkers.
Wow! That is indeed a lot of great work! I just starred this repo a few days ago because I plan to use the GLTF importer in my project. Thank you very much for that contribution @hybridherbst
I notice dev
branch has a lot of activity, is that replacing this PR?
What's the status of this PR. I can see lots of commits to the dev branch by @hybridherbst - does that work duplicate this PR? Should the PR be closed now?
Status is: we're mirroring changes in this PR and the dev branch. The last week have seen another significant push towards compatibility, readme, and documentation, and the plan is to merge the PR next week – finally.
Any upodates?
Yup, we identified a few runtime import/export issues but we're mostly done.