glTF-Blender-IO icon indicating copy to clipboard operation
glTF-Blender-IO copied to clipboard

Support exporting Blender scene collection hierarchy in glTF

Open julienduroure opened this issue 3 years ago • 19 comments

¿Will the resolution of this issue fix the fact that the current glTF export flattens all of Blender's collections into a single level?

For example, this .blend scene graph:

Becomes this single-tiered structure after a round-trip through the glb export/import process:

If this issue fixes that problem, I would like to put a little ETH on it through Gitcoin. The scene graph is so handy for describing nested relationships, and I really wish we could get access to it when rendering glTF files.

Originally posted by @dysbulic in https://github.com/KhronosGroup/glTF-Blender-IO/issues/1378#issuecomment-895474682

julienduroure avatar Aug 25 '21 05:08 julienduroure

Some quick notes:

  • An object can be linked into several collection, so this is not as simple as adding some root nodes. So checks need to be done to avoid exporting a given object multiple time
  • Another solution is to export scene collections as glTF scenes. Not sure this is the way to go. I have the feeling that some tools don't manage glTF scene correctly

julienduroure avatar Aug 25 '21 05:08 julienduroure

  • An object can be linked into several collection, so this is not as simple as adding some root nodes. So checks need to be done to avoid exporting a given object multiple time

Ok, so it is objects appearing multiple places in the hierarchy that glTF doesn't support and Blender does through linking.

The scene hierarchy is flattened to remove the collections and put the objects in a common group so that all objects exist only a single time?

glTF requires that nodes have unique parents. The materials and meshes that those nodes reference, however, don't have that restriction. Can we create nodes for the scene graph with extension information marking it as a link? It seems like that is necessary to distinguish links from nodes that are simply copies of other nodes.

  • Another solution is to export scene collections as glTF scenes. Not sure this is the way to go. I have the feeling that some tools don't manage glTF scene correctly

I've been looking at the scenes JSON schema, and it is just a list of node ids. There is no place for children, so I don't understand how you would use the scene information to encode Blender's scene collection.

dysbulic avatar Aug 30 '21 06:08 dysbulic

Could we rename this issue "Support exporting Blender scene collection hierarchy in glTF"?

I want to create a GitCoin bounty for it and I don't fully understand what "export scene collection as first level of nodes" means. I understand "export scene collection", but "as the first level of nodes" sounds to me like you're discussing flattening the hierarchy which is what I'm trying to avoid.

dysbulic avatar Aug 30 '21 06:08 dysbulic

Can we create nodes for the scene graph with extension information marking it as a link

The global rule here (in IO Blender addon) is to avoid any specific or non official extensions, so I don't think this is the way to go.

julienduroure avatar Aug 30 '21 08:08 julienduroure

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.2 ETH (631.53 USD @ $3157.67/ETH) attached to it as part of the MetaFam fund.

gitcoinbot avatar Aug 30 '21 11:08 gitcoinbot

Agreed on not needing any tooling specific extensions. I do, however see the need for exporting the full scene hierarchy when you're using collections if it can be done.

If we're talking about preserving the collection data itself, I don't think that's in the scope of glTF. It's intended to be a transmission format, not an authoring format, and I think the base exporter Addon should stick to that.

robertlong avatar Aug 30 '21 15:08 robertlong

Btw @julienduroure how do you feel about the Gitcoin, bounty for this issue? Is it ok or distracting? I think it's coming from a good place, people just want to see their workflows supported in Blender and lack the skills or time to contribute. Funding these features is their best way to get involved.

I'm asking because this is being brought up in the Open Metaverse Interoperability Group. We have a subgroup working on glTF extensions, most recently an Audio Emitter extension. We're also building an Addon to support these extensions using the extension API. This feature has been talked about on our Discord and I wanted to make sure you were aware.

Thanks for your great work!

robertlong avatar Aug 30 '21 15:08 robertlong

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 265 years, 2 months from now. Please review their action plans below:

1) madenci23 has applied to start work (Funders only: approve worker | reject worker).

Bana acil lazım eth benim işimi görün sonra hesablaşırız

Learn more on the Gitcoin Issue Details page.

gitcoinbot avatar Aug 30 '21 16:08 gitcoinbot

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 265 years, 2 months from now. Please review their action plans below:

1) sumandey4372 has applied to start work (Funders only: approve worker | reject worker).

I am beginner. I always support the development team to the moon,🚀🚀 thanks for giving us a good opportunity to receive a great gift🎁🤘

Learn more on the Gitcoin Issue Details page.

gitcoinbot avatar Aug 30 '21 17:08 gitcoinbot

@christiancfifi, I apologize for the delay on reviewing your proposal. I had a family medical emergency that took me offline for a week.

So far as your proposal, it is important that the work be accepted by Khronos Group and eventually merged into Blender. ¿Would you mind putting your proposal here and see if it gets feedback?

I suggested earlier adding extensions to the nodes with information about the collections. This was frowned upon for adding plugin specific information to the glTF file. You can store hierarchical information in the nodes structure, but the problem is that a node may be included in multiple places and that is not allowed in glTF.

It has been suggested that the scenes collection would allow storing the hierarchy, though I didn't see how that was possible from the documentation.

dysbulic avatar Sep 15 '21 21:09 dysbulic

@dysbulic I just submitted a proposal based on 3 different parts:

  • A system for user extension during import (in a branch of this repo for now)
  • A user extension for exporting extension information
  • A user extension for import extension information

For both user extension, see https://github.com/julienduroure/extension_collection

With this solution, custom parts (using non official extension) are not in official glTF-Blender-IO repo.

julienduroure avatar Oct 06 '21 19:10 julienduroure

@julienduroure, I'm trying to get a sense of how far this leaves me from my goal.

I am wanting to use 3D models of living spaces as the source of truth for a reservations system. I want for the collections tree to represent nestings of partitions of the space. A set of beds is within a room is on a floor is in a building is on a property.

A reservation is placed in the tree and is effective for a node and all its descendants. I want one person to be able to reserve a property and then act as the responsible party for renting the rooms.

¿Are you saying that this code won't be included as part of Khronos’ export plugin?

¿Installing a plugin is relatively simple, correct? It would just mean anyone wanting to add a space to the system would have to do some extra work…

The other issue is how far this leaves me from being able to interact with the model within a web browser. ¿It will still require changes to a rendering engine like three.js, right?

dysbulic avatar Oct 12 '21 03:10 dysbulic

@julienduroure, I just saw your submission on Gitcoin. The video looks like exactly what I was hoping for. I'll make sure I can operate it & release the bounty shortly.

dysbulic avatar Oct 12 '21 03:10 dysbulic

@dysbulic Any news on that?

julienduroure avatar Nov 20 '21 15:11 julienduroure

Any news on that?

I have been absolutely buried for the last few weeks. I'm getting close to pushing a working product, but it's going to be another week or so.

dysbulic avatar Nov 23 '21 08:11 dysbulic

@dysbulic Any news?

julienduroure avatar Jan 23 '22 15:01 julienduroure

@dysbulic Any news?

@julienduroure, I apologize MetaGame is trying to get MyMeta to a launchable state, so that we can seek funding, and keep our token's value out of the toilet. I've been working full time trying to get that out the door.

I really want to dig into this, but it's going to be just a bit longer…

dysbulic avatar Feb 08 '22 03:02 dysbulic

@julienduroure, Christ, I'm sorry. I finally cleared a little time to look into this about two months ago, but when I got ready the build that was given as having the code was no longer available. I hunted for the bounty in Gitcoin's site & GitHub, but couldn't find it, got frustrated, & pushed it way to the back of the priorities list.

I want to make good on my bounty. How can I run this code?

Is it merged into Blender? I tried looking for it in a recent build & didn't see anything.

dysbulic avatar Jun 01 '22 23:06 dysbulic

@dysbulic Hello, Hooks are merged in master branch. You now have to install manually these extensions : https://github.com/julienduroure/extension_collection

julienduroure avatar Jun 09 '22 08:06 julienduroure

Hey @julienduroure and @dysbulic,

I was just running into the same issue of exporting a rather complex scene as .glb for further use in three.js. A workaround for automatically having objects of a scene grouped in the final .glb-file is to parent the objects to an empty mesh object within Blender: Just add a random mesh (cube, cone whatever), delete all vertices in edit-mode and then parent objects to it you want to be in a group together.

Works like a charm and is manageable if you don't need hundreds of groups.

herr-meier avatar Dec 02 '22 11:12 herr-meier

This last workaround worked for me in a small scene. But for my project, the scene is quite large, with dozens of Collections and more than 10,000 objects. This workaround did not work and was impractical for this large scenario. That's why this requested enhancement would still be valuable, even though a workaround can suffice for certain projects.

The workaound I used for a large project is to output multiple GLBs grouped by Categories. For example, my project had 5 different categories of objects, so I turned on visibility and render for one category at a time and output. The result is 5 GLBs that comprise the entire project. It is important to Include> Limit> Visible and Renderable (select both). Include selection

tonygr1 avatar May 13 '23 12:05 tonygr1

Closing this ticket, as there is now an option to export collections as empty node

julienduroure avatar Feb 24 '24 19:02 julienduroure

Closing this ticket, as there is now an option to export collections as empty node

Sorry, where is this option?

bjck21 avatar Mar 09 '24 11:03 bjck21

Hello, This option is available in Blender 4.1 (beta) : "Full Collection Hierarchy"

image

julienduroure avatar Mar 09 '24 14:03 julienduroure