Giter Site home page Giter Site logo

gltfast's Introduction

glTFast

codecov

Unity and glTF logos side by side

openupm

NOTE: It's recommended to switch to Unity glTFast, a fork of this package that is developed and supported by Unity. Consult the upgrade guide for details.

glTFast enables use of glTF™ (GL Transmission Format) asset files in Unity®.

It focuses on speed, memory efficiency and a small build footprint while also providing:

  • 100% glTF 2.0 specification compliance
  • Ease of use
  • Robustness and Stability
  • Customization and extensibility for advanced users

Features

glTFast supports the full glTF 2.0 specification and many extensions. It works with Universal, High Definition and the Built-In Render Pipelines on all platforms.

See the comprehensive list of supported features and extensions.

Workflows

There are four use-cases for glTF within Unity

Schematic diagram of the four glTF workflows

Read more about the workflows in the documentation.

Installing

NOTE: Consider switching to Unity glTFast, a fork of this package that is developed and supported by Unity. Consult the upgrade guide for details.

Installation instruction for the original glTFast.

Usage

You can load a glTF asset from an URL or a file path.

Runtime Loading via Component

Add a GltfAsset component to a GameObject.

GltfAsset component

Runtime Loading via Script

var gltf = gameObject.AddComponent<GLTFast.GltfAsset>();
gltf.url = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF/Duck.gltf";

See Runtime Loading via Script in the documentation for more details and instructions how to customize the loading behavior via script.

Editor Import

Move or copy glTF files into your project's Assets folder, similar to other 3D formats:

Editor Import

Unity glTFast will import them to native Unity prefabs and add them to the asset database.

See Editor Import in the documentation for details.

Editor Export

The main menu has a couple of entries for glTF export under File > Export and glTFs can also be created via script.

Project Setup

Materials and Shader Variants

❗ IMPORTANT ❗

Unity glTFast uses custom shader graphs that you have to include in builds in order to make materials work. If materials are fine in the Unity Editor but not in builds, chances are some shaders (or variants) are missing.

Read the section Materials and Shader Variants in the Documentation for details.

Contribution

See CONTRIBUTING.md.

License

Copyright 2023 Unity Technologies and the Unity glTFast authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use files in this repository except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Trademarks

Unity® is a registered trademark of Unity Technologies.

Khronos® is a registered trademark and glTF™ is a trademark of The Khronos Group Inc.

gltfast's People

Contributors

alex-huot avatar atteneder avatar aurorahcx avatar avseoul avatar bersaelor avatar camnewnham avatar chrisdjali-wrld3d avatar dandovi avatar dhasl002 avatar ericbeetsofficial-opuscope avatar gauthial avatar holo-krzysztof avatar hybridherbst avatar jdebelle-unity avatar jf-gagnon avatar jiangboyu13 avatar jonathanb-vobling avatar mikejurka avatar nickconstantinidis avatar nyxstudio avatar querielo avatar rt-nikowiss avatar samuel-proulx avatar stephengower avatar wonkee-kim avatar zharry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gltfast's Issues

Performance on ios

The (impressive) speed of this library in the editor gets lost when building for ios. The loading duration increases by 400%. Switching from .glb to .gltf does not affect the duration.

Camera support

Optional camera import support. Default should be to not import cameras (or at least not activate them).

Loading of draco file fails

I'm getting a decoding error when trying to load draco compressed files.

Failed: Decoding error.
UnityEngine.Debug:LogError(Object)
GLTFast.PrimitiveDracoCreateContext:CreatePrimitive() (at Library/PackageCache/com.atteneder.gltfast@64f3c1b978d7139af3da6d9c48b02ae06a375d90/Runtime/Scripts/GltFast.cs:159)
GLTFast.<Prepare>d__43:MoveNext() (at Library/PackageCache/com.atteneder.gltfast@64f3c1b978d7139af3da6d9c48b02ae06a375d90/Runtime/Scripts/GltFast.cs:545)
GLTFast.<LoadContent>d__8:MoveNext() (at Library/PackageCache/com.atteneder.gltfast@64f3c1b978d7139af3da6d9c48b02ae06a375d90/Runtime/Scripts/GltfAsset.cs:77)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

I tried running with 2019.2 as well as 2019.3 on windows 10, git as well as lsf are up to date.
Packages appear to also be in order and up to date:

{
  "dependencies": {
    "com.atteneder.draco": "https://gitlab.com/atteneder/DracoUnity.git",
    "com.atteneder.gltfast": "https://github.com/atteneder/glTFast.git",
    "com.unity.ext.nunit": "1.0.0",
    "com.unity.ide.vscode": "1.1.2",
    "com.unity.test-framework": "1.1.1",
    "com.unity.modules.imageconversion": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unitywebrequesttexture": "1.0.0"
  },
  "testables": [
    "com.atteneder.gltfast"
  ],
  "lock": {
    "com.atteneder.draco": {
      "revision": "HEAD",
      "hash": "b04c2d09ff4d4889e68e0cdfe6b3dc47f4a58a29"
    },
    "com.atteneder.gltfast": {
      "revision": "HEAD",
      "hash": "64f3c1b978d7139af3da6d9c48b02ae06a375d90"
    }
  }
}

I created the file using the fbx2gltf converter 0.9.7 using .\FBX2glTF-windows-x64.exe --input .\Y_Bot.fbx --output Y_Bot.glb --binary --draco (also tried without --binary)

I attached the file in question and would be extremly happy for any pointers where to start debugging / fixing the whole thing!

data.zip

Thread support

Investigate if the loading process can be moved off the main thread and spread accross multiple worker threads.

Support for Universal Render Pipeline (URP)

Currently there's only support for the Built-In render pipeline via DefaultMaterialGenerator. It implements the interface IMaterialGenerator.

To add support for the URP, the corresponding code creating the materials has to go into a new class implementing IMaterialGenerator.

It has to be used in the constructor of GLTFast instead of the default one (ideally dynamically).

        public GLTFast() {
            materialGenerator = new DefaultMaterialGenerator();
        }

Loading glb from Application.persistantdatapath in android.

Hi,
I downloaded the glb files in persistantPath in Android and when I try to load from this path I get an error
Unity: Cannot connect to destination host /storage/emulated/0/Android/data/com.xxx.xxxx/files/C772BCFB-B2FD-406E-8B32-05D3D5DEFAD6.glb

Invalid Package Dependency

I am not incredibly well versed in how Unity's fancy new Package Manager works, but when I follow your instructions on attempting to add glTFast to my manifest.json file, it returns the following error.

An error occurred while resolving packages:
  Package com.atteneder.gltfast@https://github.com/atteneder/glTFast.git has invalid dependencies:
    com.atteneder.draco: Package [[email protected]] cannot be found

So I can't load GLTF files?

Do I need to use another library to convert a GLTF file into GLB in order to use :

var loadModel = new GameObject().AddComponent<GLTFast.GlbAsset>();
loadModel.url = gltf;

Unity Package

Make this project a UnityPackage

  • Easier usage for developers
  • Separation of core and usage/example code

All nodes and meshes are in wrong coordinate space

glTF is right-handed whilst Unity uses a left-handed coordinate system. Initially glTFast simply scaled the root node by -1 in the Z-axis to fix this. Turns out this can have some negative impact on, for example, shader or physics behaviour.

TODO: convert node's transforms and meshes into Unity space

glb import from network share failed

I tried to import a .glb from a network share and got the following error.

HTTP/1.1 502 Bad Gateway \\server\share\file.glb
UnityEngine.Debug:LogErrorFormat(String, Object[])
GLTFast.<LoadRoutine>d__6:MoveNext() (at Assets/GLTFast/GltfAsset.cs:41)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

poor performance on editor/android with large glb file

Hi, i was testing this project and i have very bad performance with "large" glb scene (40mb-100mb) (3d models with lot of objects, ~1M verts ), this was designed just for litle objects? what about performance on mobile devices? what are the limits of this library?

Streamable

Make loading glTFs streamable, so the already received part of the content can be parsed while the rest is loading.

  • Detect Binary/JSON
  • Parse JSON ahead
  • Fill individual BufferViews/Accessors instead of single Buffer
  • Start buffer to data conversion ahead
    • Vertex/Index/Matrix Buffers
    • Textures

Related:

  • #318
  • Streamable instantiation: Instantiate right after parsing but before loading is done and have the content (meshes, textures) appear once they are there.
    • Texture streaming
      • Instantiate first and assign textures once they are ready
      • Mipmap streaming: stream in low levels first and improve resolution on the go

Missing namespaces

I've just cloned the project and opened inside of Unity 2018.3.0 which is causing missing namespaces. These are:

  • TestTools
  • NUnit
  • TestAttribute
  • Unity TestAttribute
  • Unity Test

Is this because i'm using a newer version of Unity or are these carried over from the Kronos project and i'm missed something?

Skin support

Support meshes/rigs with skinning applied.

  • Joints
  • Weights

Load Progress and state reporting

It would be interesting to get a progress (done vs pending percentage) and provide data/interfaces required for progress bars and ETA calculation.

Callbacks for major loading events, like:

  • Geometry is ready
  • Materials are ready
  • Textures are ready
  • Animations are ready
  • Everything is ready

Edit: Since version 4.0.1 you can retrieve warning/error messages via ICodeLogger injection.

Draco compressed files do not load

I receive this error whenever the plugin tries to decode a gltf or glb compressed with draco:

'''
EntryPointNotFoundException: DecodeMeshForUnity
DracoMeshLoader+DracoJob.Execute () (at Library/PackageCache/com.atteneder.draco@b04c2d09ff4d4889e68e0cdfe6b3dc47f4a58a29/Runtime/Scripts/DracoMeshLoader.cs:64)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at /Users/builduser/buildslave/unity/build/Runtime/Jobs/Managed/IJob.cs:30)
'''

I've tried files exported from Blender 2.8 as well as this sample file:
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/CesiumMilkTruck/glTF-Draco

I've also tried Unity 2019.2.3f1 on both Windows 10 and OSX with the same result.

Optimized Shader/Material System

Right now the Unity Standard Shader is utilized which has some downsides:

  • costly texture transformations for occlusion/roughness/metalic textures, since the channel usage differs

  • missing features (like double sidedness or unlit)

An optimized shader (or a derivate of the Standard Shader) could improve speed/size.

Things to consider:
(Scriptable) Render Pipeline compatibility:
Forward/Deferred, Lightweight, HQ, custom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.