New glTF Model Importer - Beta Test

It’s time to beta test the new model importer!

In this update, we’ve added support for glTF format.

Notes:

  • We support both .glb and .gltf formats.
  • We currently only export max one skeleton per file
  • It supports skinning and animating meshes.
  • It now supports multiple meshes per model
  • Currently still uses one material for all meshes in a model
  • Currently still only support world space vertices for skinned models
  • Each file should still only contain one animation
  • Added support for tanget space uv’s

We don’t support:

  • multifile glTF files (i.e. no external buffers!)
  • embedded textures (we have our own way of handling textures)

Breaking change

The .animationset file format now requires you to select a skeleton.
This allows us to keep all our internal bone indices optimized.

:warning: Note that if you save your files with this editor version, it won’t open in an older editor. It is a single line change in the format though, so it’s easy to revert any changed files.

Near future updates:

  • Allowing more than one material per model (it’s in design phase)

Model Wishlist

We also have some other useful items on our wishlist for 3D models:

  • Frustum culling
    • Calculate AABB’s based on current pose
  • Suppport skinning + instancing on GPU
  • Animation retargeting
  • Add basic animation compression.
  • Add support for external compression (e.g. https://github.com/nfrechette/acl)
  • Preview animations in the editor
  • Support IK
  • Increased support for material properties (e.g. import PBR settings from .gltf)

Code details:
For the interested, and perhaps future contributors, we’ve created a new modelimporter.jar that we use both in Bob.jar and in the Editor. This plugin will makes easier for us to add new formats using C++ libraries, and then present it through our pipeline. See our internal library modelc for code details.

For the glTf support, we’ve used the same importer as Roblox uses, by Johannes Kuhlmann (Twitter: @j66k) cgltf.h.

Testing

Collada support

Although we now consider the colada support deprecated, we still need it to function as before.
If you have a project using colada models, then it would be good if you could test it to see that everything still works as expected.

glTF support

Everything should work as before, but we’ve just added another file format.
Note the limitation of only currently only using one material on all the meshes in the model.

Links

Here are the links to the current beta version:

Update 2022-09-25:

  • Fixed issue where the animation set wasn’t detected

Update 2022-09-12:

  • Fixed issue with missing selectable animation in drop down menu for single animations
  • Fixed crash when blending no animation with a new animation

Update 2022-09-03:

  • Fixed rendering of models in the editor
  • Fixed issue of top transform for imported model
  • Fixed issue of an animated model affecting other models

Update 2022-08-31:

  • Fixed issue with editing the .animationset resource
  • Added tangent, color and texcoord1 to vertex format. (WIP. Not used in default shader)

Update 2022-08-27:

  • Added a fix for Collada models not showing correctly
  • Added a fix for non-animated models not showing correctly
  • Fixed a crash
19 Likes

The house model in the RenderCam demo does not load.

glTF version


latest release

I don’t see anything in the log complaining about it.

Editor still sees it.

2022-08-23 01_23_45-Rendercam - Defold Editor 2.0

I imported the dae in RenderCam into Blender. Looks like this just for reference.

Exported scene to glb. Enabled it in Defold. Model in editor suddenly looks like this:

But in engine this is also not displayed / no obvious complaining about it in the editor.

Here’s the exported glb of that scene, you can put it in the RenderCam project to reproduce.

voxel_house.zip (17.6 KB)

2 Likes

Thanks! I’ll try it out!

1 Like

Also make note of that the gilt format has Y-up, just like Defold, while blender has Z-up. You should click the checkbox in blender when exporting, to fix the rotation.

3 Likes

Tested a few 3d projects that use the collada format and getting some strange results in animations and models without skeleton animations seem to not render in builds , but render in editor just fine. Set the appropriate skeleton property in animationset and results = Blinking / stretching / warping during play. Seems the vertices or vertex weights are not translating correctly. My animated 3d example on github can be used to see the issues I am describing.

results:

4 Likes

Thanks for the info.
I really appreciate the testdata as it seems my own data didn’t catch enough collada issues.
I’m currently travelling so I probably won’t have a fix in the next few days.

5 Likes

image
Nice!, first time I can import my own model to Defold! :partying_face:
But there some things that maybe I don’t understand.

What failed: Same model converted by Sketfab, it was in two parts .glTF and .bin, is that what external buffers means that it’s not supported?

What works: Exporting from 3ds Max 2022 using Babylon exporter as .glB

Now since I never passed the importing step with .dae I just give up and I have zero experience with 3D in Defold. How I can make the animation work?
On model properties I simply set Skeleton and Animations pointing to the same .glb file. Is that correct?
Then I get the material skinning error that I have no idea how or where to fix.

(I’m very rusty… almost 2 years without using Defold)

The model:
animated_fish_BabylonExp_glB.zip (51.3 KB)

1 Like

Ok, I’ve found the Vertex Space option :slight_smile:
image

Error gone.
Still looking for how to apply the animation.

Ok, this is really great, animation applied!!
fishDefold

Found the animation set settings :partying_face:
image

8 Likes

Correct! (We may support it in the future)

For the animations, there are two ways.

  1. Simply set a single animation to the animation property.
    or
  2. Create an animation set (no need if you only have one animation)

As mentioned above, we currently only support world space skinning (i.e. on the CPU).
To use that, copy the model.material into your project (from the builtins folder), and change
the space property from local to world.

Hehe, wrote the reply before I realised you had already solved it.
I’ll leave my note here though, if it’s helpful for anyone else ^^

3 Likes

I have a single file, a model with animation, so I set as animation property a reference to the same model file and it doesn’t work, or still I need some more step on code?. I don’t see anything to choose from the Default Animation list.

While creating an AnimationSet it works perfectly fine.
Test #2 :partying_face: :

robotModel_glb.zip (118.6 KB)

5 Likes

Nice!
When using the single file animation, did you also set a skeleton on the model? :thinking:

I think yes, look like this:
image

1 Like

I updated Defender to support gltf loading (will try out glb on weekend) and well. It works well. Really well.

The normals and textures seem to be much nicer. I suspect I was losing normal precision with the conversions being done.

Really good work with the loader. I’ll run some anim and multi object hierarchy stuff through Defender on the weekend. Defender automatically splits up objects into single materials, and so it should make a bunch of gltf files.

I have made Defender have an option to use old or GLTF method on the meshes. This way it still works for current builds as normal. I hope to get a release up on the weekend too.
Really awesome stuff.

< edit > A little extra note. Gltf export also supports tangents and some other fancy features. Will be interesting if we can get that data :slight_smile:

9 Likes

Another nice thing. Is I can remove a root transform node that I used to get a model into the same alignment as the Defold coord space. Woot! Consistent coords!!!

3 Likes

Good stuff! Yes the plan is to expose tangent data, but I’ll let Mathias expand on that. We want to support a full PBR workflow so tangents and more texcoord channels will be needed.

7 Likes

Im assuming multi texcoord channels are not yet being loaded?

2 Likes

I did some more tinkering, and it looks like the editor has some problems with perspective mode when displaying gltf/glb files? If I switch between ortho and persp the object disappears. But it actually doesnt disappear, it just gets extremely small. Then the camera bounds do some weird things.
Not really sure what is happening here. I’ll attach a video to show whats happening.

4 Likes

More tests. Did some hierarchy checks. And looks like its all exports properly (I need to refactor my go and collection transforms). Really looking forward to this feature being a permanent addition :slight_smile:

Oh another note. This was using glb and it was surprisingly slow for Defold to ingest these objects. They are not huge polys or complex materials, so its a little puzzling. The largest glb was 338KB. Kinda odd.
Admittedly there are 30 cars and 120 wheels :slight_smile: But still… took a few minutes. I expected maybe 20 secs tops?

7 Likes

Interesting. I wonder where that time is spent.
Would it be possible to share the test project with me?

1 Like