Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Official Unity glTFast package is now available

Discussion in 'Asset Importing & Exporting' started by seth-unity, Dec 14, 2023.

  1. seth-unity

    seth-unity

    Unity Technologies

    Joined:
    Nov 2, 2022
    Posts:
    15
    glTFast-GitHub-social-2.png We’re excited to announce the release of the Unity glTFast (com.unity.cloud.gltfast) package, supporting the import and export of glTF™ 3D files, both at runtime and within the Editor.

    Introduction

    glTF, which stands for Graphics Library Transmission Format (or GL Transmission Format), is a standardized file format used to store and transfer 3D scenes and models. It's like the JPEG of the 3D world, aiming to provide a universal and efficient way to share 3D content across different platforms and applications. glTF is gaining significant popularity as a 3D format, with its open-source nature and versatility contributing to its traction.


    Getting started


    Installation instructions for the package are included in the Unity glTFast package documentation.


    Current state


    The package in itself is not an innovation, but rather a further developed re-release of the original glTFast, an open source Unity package founded by Andreas Atteneder in 2018. Andreas joined Unity in 2020 and continues to drive glTFast’s development. While the packages are identical, here is what has changed:

    What benefits do you get?

    • Official support by Unity.

    • Easy distribution via Unity Package Manager: Scoped registry is not needed anymore and it can easily be installed using the “Add package by name” and com.unity.cloud.gltfast.

    • Teamwork increases development velocity: Unity-internal collaboration removes the bottleneck of depending on one individual maintainer.

    • Proper DevOps for increased quality assurance: Making use of Unity’s internal tools and infrastructure allows us to practice state-of-the-art development processes like continuous integration, automated testing and release management.

    What’s next


    Alongside with Unity glTFast we’ve also released KTX for Unity, a package for loading KTX 2.0 textures, and we’re working on bringing a Unity package offering Google Draco (3D data compression) to you as well. These packages bring additional power-features to glTFast and just like glTFast those packages are re-releases of open source originals.


    How do I report bugs?


    Bug reports and feature requests can be submitted to the Unity glTFast GitHub repository.
    We’ll start to consolidate open issues and PRs from the original repository soon.


    How do I contribute to future development plans?


    You can contribute to development plans by adding your request on https://github.com/Unity-Technologies/glTFast. In order to get your work merged, you’ll have to accept the Contributors License Agreement.


    Open Standards

    Unity is committed to increasing its adoption of Open Standards to help deliver a common foundation for content creation, collaboration and interoperability.

    Alongside the gLTF™ support announced today, Unity has recently released OpenUSD (forum post), three packages for supporting the import and export of USD scenes within the Unity Editor

    We consider gLTF™ and OpenUSD as complementary technologies that help users to build ever more powerful workflows and content pipelines. With these releases, users now have the flexibility to choose the format that best suits their requirements, for example glTF™ for efficient runtime content delivery and OpenUSD for flexible, complex multi-layer content authoring.

    For further details on our USD packages, please see our documentation:

    Common Questions

    Why the rename to “Unity glTFast”?

    So that the officially supported package is distinguishable from the original.

    Is there a public roadmap?
    Not as of now, but we’re considering options to disclose our plans.

    Is Unity glTFast still open-source?
    Yes, the licensing did not change.

    What’s the best practice when it comes to developing glTFast?
    To make development easy and prevent regression issues, we’re using a set of tools, tests and test projects. For now those are not entirely available publically. We’re thinking about making those available to the general public along with documentation and will notify you once we have a plan.
    However, those tools are not required at all, so don’t let that prevent you from development.

    Can I transition from the original to Unity glTFast?
    Yes, in fact that’s recommended. You’ll have to make some adjustments to your projects though, so please read the Upgrade Guide to learn what’s required.

    Can I still use the original glTFast that’s distributed via OpenUPM?
    Yes. Short-term, the original will receive updates from Unity glTFast and releases will be made to OpenUPM as usual. That might change in the future.

    Can I still contribute to the original glTFast?
    Please direct your contributions towards Unity glTFast from now on. While technically it’s still OK to make PRs on the original, responses and merging will be much more convenient and faster on Unity glTFast.

    Can I still use the original glTFast via GIT?
    Note: Unless you are developing the original glTFast, it’s recommended to install it from the OpenUPM scoped registry.
    On the original GIT repository the main branch now also contains the Unity glTFast variant. To keep using the original version (with package identifier com.atteneder.gltfast), switch to/checkout the openupm branch.


    Notices


    “Battle Damaged Sci-fi Helmet” PBR by theblueturtle_, published under a Creative Commons Attribution-NonCommercial license

    Khronos® is a registered trademark and glTF™ is a trademark of The Khronos Group Inc.
     
    Last edited: Jan 8, 2024
  2. kiksunitydev

    kiksunitydev

    Joined:
    Mar 18, 2021
    Posts:
    9
    Great to hear this, expecting for quite a long time now, KHR 2.0 texture support :)
     
    Jairovskaya and d1favero like this.
  3. aras-p

    aras-p

    Joined:
    Feb 17, 2022
    Posts:
    75
    Nice! I am wondering why it starts with "cloud" in the package name though -- like if I'm looking at package names and I see "cloud" I would have never guessed it has to do with asset importing. Other formats, well, have "com.unity.formats" as the name (Alembic, USD, FBX), why not keep that consistent?
     
    andyz, Rowlan, jeromeatunity and 6 others like this.
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 5, 2024
    Posts:
    533
    Will see if I'm right, but if I have to guess I would guess that the Cloud team made it, who makes that new cloud-based Asset Manager on the dashboard. Because we could ask for it for long years and they only develop it when they have opportunity sell yet another cloud-based service.
     
  5. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    Awesome!
     
    Jairovskaya and tteneder like this.
  6. PleaseEnterYourName

    PleaseEnterYourName

    Joined:
    Feb 11, 2015
    Posts:
    11
    Is it just me or are installation instructions missing ?

    edit : nevermind, found it
     
  7. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    490
    Why is it even a package? It should be in core unity's supported file formats.
     
  8. tteneder

    tteneder

    Unity Technologies

    Joined:
    Feb 22, 2011
    Posts:
    175
    Sorry for not adding installation instructions. I'll add them to the docs soon:

    In your Unity project, go to Windows > Package Manager. On the status bar, select the Add (+) button. From the Add menu, select Add + package by name. Name and Version fields appear. In the Name field, enter
    com.unity.cloud.gltfast
    . Select Add. The Editor installs the latest available version of the package and any dependent packages.​
     
    efge, newguy123 and De-Panther like this.
  9. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,285
    This is great, already using a previous version.
    But this KTX texture format also looks exciting - does this mean 1 format that can be converted quickly to any platform-specific compressed GPU format on download?
     
  10. EMOTION-THEORY

    EMOTION-THEORY

    Joined:
    Jul 16, 2013
    Posts:
    83
    I'm trying to export multiple prefabs into separate gltf files.

    Using Assets > Export glTF > glTF, I can export my selected prefab assets, but it saves it into ONE gltf with ALL the prefabs in it.

    Is there a way to bulk-export multiple glTF files, one for each selected prefab?

    Thanks :)
     
  11. mrwellmann

    mrwellmann

    Joined:
    Nov 27, 2015
    Posts:
    39
    tteneder likes this.
  12. Zarbuz

    Zarbuz

    Joined:
    Oct 13, 2015
    Posts:
    45
    This is a great addition to Unity ! The import part is very excellent !

    I have more problems with the export part in runtime. First problem is that we cannot export a previously imported model, we lose all the material properties.
    My second concern is that it lacks skinning support for export. This is something that would be very useful for our project. I hope these 2 points can be resolved in the future.
     
    tteneder likes this.
  13. tteneder

    tteneder

    Unity Technologies

    Joined:
    Feb 22, 2011
    Posts:
    175
    Exactly! To be precise, the KTX 2.0 file containing a Basis Universal super-compressed texture is transcoded into a supported GPU compressed format (e.g. ASTC, PVRTC, DXT) at run-time.
    It's not just threaded and fast (compared to decoding Jpeg/PNG), the resulting texture requires a lot less GPU memory. Really impressive tech!
     
  14. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,566
    This is really nice, thanks!
     
    tteneder likes this.
  15. tteneder

    tteneder

    Unity Technologies

    Joined:
    Feb 22, 2011
    Posts:
    175
    There's no UI option, but it's possible to create a custom script for that. Take a look at the Export method that's used by the menu entries. Instead of passing an array of (root) GameObjects, iterate over that array and call Export for each individual GameObject and you're there.

    Long term there's the vision for an export dialog that offers more settings. Bulk export could be one of them.

    Thanks for the feedback!
     
  16. Neogene

    Neogene

    Joined:
    Dec 29, 2010
    Posts:
    95
    Nice, I was waiting for over three years, some feedbacks:

    1) there is no simple way to extract and make editable materials like other 3d models import settings, the only way I found was to do a copy and paste of the materials from the Project area and replace them manually (or using a script which searches the same material name)

    2) there is no option to set the default import scale like for other 3d models import settings so the only quick way is to drag into hierarchy, change the scale, create a prefab and use it
     
  17. EMOTION-THEORY

    EMOTION-THEORY

    Joined:
    Jul 16, 2013
    Posts:
    83
    Thanks. I got the desired results by looping through the Export function :+1:

    My next questions:

    How can we get this to work for humanoid characters?

    It seems like my exports of human characters don't contain an armature when importing them into blender.

    Also:

    My textures seem to be converting from png to jpg. Is there any way to prevent this and keep them uncompressed as in the original texture?


    Thanks for the help!
     
    Last edited: Jan 23, 2024
  18. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,493
    tteneder likes this.
  19. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,566
    Thanks for posting. Nice to see some alternatives.

    Does anyone happen to know how to resolve the mesh separation when it has multiple materials? While I do prefer the Unity package, this is a significant issue, especially since the file will not contain unique names for those meshes. The Khronos package seems to handle it better by merging the meshes for you (I'll probably have to end up doing this by hand), but I'm curious how others are overcoming it.
     
  20. Lemovision

    Lemovision

    Joined:
    Apr 6, 2020
    Posts:
    39
    Is this package able to export baked lightmaps from Unity along with the lightmap UVmap that comes with it? Or is there any other way at all to export and re-use those baked maps somewhere else?
     
  21. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,285
    Yeah this is a real oddity but is it not down to the gltf format itself separating meshes by material?
    If the Khronos package can combine them then is that supported for runtime loading and is it not a performance issue if used there?
     
  22. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,566
    Yes, but generally if we want to instantiate a specific mesh by name then it's strange because there may be N meshes with the same name in the gltf file. There's clearly a way to access the data and understand their relationship/material mapping in order to merge them, but it's not clear at a glance how to do so. Feels inelegant overall, but it may just be our use-case making me biased. I'm happy to work around it, just not sure how to do so yet.
     
  23. tteneder

    tteneder

    Unity Technologies

    Joined:
    Feb 22, 2011
    Posts:
    175
    I agree that glTFast should do a better job of preserving sub-meshes and since this comes up on a regular basis, it's high on my wish list as well.

    But to set the expectation right, glTF's mesh-primitive concept allows for much more freedom than Unity's Mesh (e.g. different vertex buffer layouts or even different topology). In those cases glTFast (or any glTF importer really) will always split up glTF primitives into Unity Meshes.
     
    JesOb and LaneFox like this.
  24. Angel_Aumenta

    Angel_Aumenta

    Joined:
    Jun 29, 2022
    Posts:
    2
    Hi, I was able to SaveToFileAndDispose the gltf. My final project is to send mesh over WebRTC. Is there a posibility to read the gltf data as a string or bytes ? I'm using RTCDataChannel to send the file.
    Thanks in advance.
    Mycode
    Code (CSharp):
    1. async void GltfExport()
    2.     {
    3.         // Example of gathering GameObjects to be exported (recursively)
    4.         var rootLevelNodes = GameObject.FindGameObjectsWithTag("ExportMe");
    5.  
    6.         // ExportSettings provides generic export settings
    7.         var exportSettings = new ExportSettings
    8.         {
    9.             Format = GltfFormat.Binary,
    10.             FileConflictResolution = FileConflictResolution.Overwrite,
    11.             // Enable Draco compression
    12.             Compression = Compression.Draco,
    13.             // Tweak the Draco compression settings
    14.             DracoSettings = new DracoExportSettings
    15.             {
    16.                 positionQuantization = 12
    17.             }
    18.         };
    19.  
    20.         // GameObjectExport lets you create glTFs from GameObject hierarchies
    21.         var export = new GameObjectExport(exportSettings);
    22.  
    23.         // Add a scene
    24.         export.AddScene(rootLevelNodes);
    25.  
    26.         // Async glTF export
    27.         bool success = await export.SaveToFileAndDispose("C:/AumentaSolutions/_DEMOS/DEMO_WebRTC/glTFast/test.gltf");
    28.  
    29.         if (!success)
    30.         {
    31.             Debug.LogError("Something went wrong exporting a glTF");
    32.         }
    33.  
    34.         if (success)
    35.         {
    36.             Debug.Log("exporting a glTF : " + export.ToString().Length);
    37.             byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(export.ToString()); // Trying to read export as byte array
    38.             string flieString = export.ToString(); // Trying to read export as string
    39.             dataChannel.Send(flieString); // Get "GLTFast.Export.GameObjectExport", not the data file
    40.         }
    41.     }
     
  25. Angel_Aumenta

    Angel_Aumenta

    Joined:
    Jun 29, 2022
    Posts:
    2
    SOLVED : used SaveToStreamAndDispose
     
  26. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    195
    Is it possible to get extra data when importing .glb format?

    Using a custom addon, my nodes are not casting to GLTFast.Newtonsoft.Schema.Node

    ```
    var node = gltf.Nodes[(int)nodeIndex] as GLTFast.Newtonsoft.Schema.Node;
    var extras = node?.extras;
    if ( extras == null )
    return;```
     
  27. dpbillings

    dpbillings

    Joined:
    Sep 20, 2022
    Posts:
    1
    hello,
    is there a setting or method to export shadowmaps with this package? it appears that shadowmaps are not exported with the asset when exporting to glb.
    Or is there a better way to get the shadow maps from out of unity and into a threejs environment? any advice is greatly appreciated!