Support geometry node in glTF exporter #94953

Closed
opened 2022-01-16 14:45:45 +01:00 by Julien Duroure · 16 comments
Member

This should be possible when API will manage it.
Current code used by glTF exporter:

depsgraph = bpy.context.evaluated_depsgraph_get()
blender_mesh_owner = blender_object.evaluated_get(depsgraph)
blender_mesh = blender_mesh_owner.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph)
This should be possible when API will manage it. Current code used by glTF exporter: ``` depsgraph = bpy.context.evaluated_depsgraph_get() blender_mesh_owner = blender_object.evaluated_get(depsgraph) blender_mesh = blender_mesh_owner.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph) ```
Author
Member

Added subscribers: @JulienDuroure, @lictex_1, @GeorgiaPacific, @JacquesLucke

Added subscribers: @JulienDuroure, @lictex_1, @GeorgiaPacific, @JacquesLucke
Member

I'm not entirely sure what part of geometry nodes you want to support exactly with this task.
There are two main things:

  • Generic attributes. This probably just requires a few more lines in the exporter to export these additional data layers.
  • Instances. I don't know the glTF format very well. Does it support some kind of instancing or can a file only contain one mesh? Either way, we could potentially add a realize_instances option to the to_mesh function.
I'm not entirely sure what part of geometry nodes you want to support exactly with this task. There are two main things: * Generic attributes. This probably just requires a few more lines in the exporter to export these additional data layers. * Instances. I don't know the glTF format very well. Does it support some kind of instancing or can a file only contain one mesh? Either way, we could potentially add a `realize_instances` option to the `to_mesh` function.
Author
Member

Hello Jacques,

My main issue was about retrieving geometry itself in python, because API doesn't return any data if node tree does not have a Realize Instances Node.
Adding an option to to_mesh could be a great solution for any dev that want retrieve geometry with the python API

(Instances are already managed in glTF exporter)

Hello Jacques, My main issue was about retrieving geometry itself in python, because API doesn't return any data if node tree does not have a Realize Instances Node. Adding an option to to_mesh could be a great solution for any dev that want retrieve geometry with the python API (Instances are already managed in glTF exporter)
Member

Instances are already managed in glTF exporter

Can you give some more details to how instances are handled? I couldn't find related code in the exporter when I quickly skimmed over it. A Realize Instances node is only necessary when the tree actually outputs instances. If the file format exports instances, then those should be exported as instances as well probably, instead of being merged into a single mesh.

> Instances are already managed in glTF exporter Can you give some more details to how instances are handled? I couldn't find related code in the exporter when I quickly skimmed over it. A `Realize Instances` node is only necessary when the tree actually outputs instances. If the file format exports instances, then those should be exported as instances as well probably, instead of being merged into a single mesh.
Author
Member

Sorry, I probably misunderstand / use a wrong world. What is currently supported is different object sharing same mesh data.

My request here is more about be able to get mesh data using bpy when there is Geometry Node modifier, and no Realize Instances node in node tree. Seems this is currently not possible (or I didn't find how). (Whatever we want a merge into single mesh or not)

Sorry, I probably misunderstand / use a wrong world. What is currently supported is different object sharing same mesh data. My request here is more about be able to get mesh data using bpy when there is Geometry Node modifier, and no ```Realize Instances``` node in node tree. Seems this is currently not possible (or I didn't find how). (Whatever we want a merge into single mesh or not)
Member

Ah I see, so e.g. dupli objects are not yet exported to glTF either, right?

There is an api that should give you the data you are looking for: https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Python_API#Geometry_Instancing
It may not fit neatly into the current architecture of the exporter, not sure. Maybe you can wrap it to make it fit better.
I hope we can get a better / more direct API in the future, but not sure if we can get it in 3.1.

Ah I see, so e.g. dupli objects are not yet exported to glTF either, right? There is an api that should give you the data you are looking for: https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Python_API#Geometry_Instancing It may not fit neatly into the current architecture of the exporter, not sure. Maybe you can wrap it to make it fit better. I hope we can get a better / more direct API in the future, but not sure if we can get it in 3.1.
Author
Member

Ah I see, so e.g. dupli objects are not yet exported to glTF either, right?

You are right. They are managed in this branch for now: https://github.com/KhronosGroup/glTF-Blender-IO/pull/1378

I will have a look on api you pointed it out. Thanks!

> Ah I see, so e.g. dupli objects are not yet exported to glTF either, right? You are right. They are managed in this branch for now: https://github.com/KhronosGroup/glTF-Blender-IO/pull/1378 I will have a look on api you pointed it out. Thanks!
Member

I think you pasted the branch name incorrectly.

I think you pasted the branch name incorrectly.
Author
Member

I think you pasted the branch name incorrectly.

Fixed, sorry

> I think you pasted the branch name incorrectly. Fixed, sorry
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Member

I read some updates recently and I think this might be finished-- both attributes and geometry instances. Is that right?

I read some updates recently and I think this might be finished-- both attributes and geometry instances. Is that right?

Added subscriber: @Zhen-Dai

Added subscriber: @Zhen-Dai

Same question as Hans but looks like it isn't merged yet: https://github.com/KhronosGroup/glTF-Blender-IO/pull/1786

To make the instancing workflow truly usable it probably need support for EXT_mesh_gpu_instancing also, such as this fork: https://github.com/takahirox/glTF-Blender-IO-EXT-mesh-gpu-instancing

Same question as Hans but looks like it isn't merged yet: https://github.com/KhronosGroup/glTF-Blender-IO/pull/1786 To make the instancing workflow truly usable it probably need support for `EXT_mesh_gpu_instancing` also, such as this fork: https://github.com/takahirox/glTF-Blender-IO-EXT-mesh-gpu-instancing
Author
Member

Hello,

Yes, the PR is not yet merged, and not finished yet. I will close this ticket when PR will be merged.
Implementing EXT_mesh_gpu_instancing is also on the roadmap of the PR.

Hello, Yes, the PR is not yet merged, and not finished yet. I will close this ticket when PR will be merged. Implementing EXT_mesh_gpu_instancing is also on the roadmap of the PR.
Bastien Montagne added this to the Pipeline, Assets & IO project 2023-02-09 15:40:38 +01:00

Hi,
since the last comment on this issue, the EXT_mesh_gpu_instancing gltf extension got ratified, and blender since 4.0 natively supports in the gltf exporter this extension. Only what's missing is this issues. Has there been any progress? Thanks in advance!

Hi, since the last comment on this issue, the `EXT_mesh_gpu_instancing` gltf extension got ratified, and blender since 4.0 natively supports in the gltf exporter this extension. Only what's missing is this issues. Has there been any progress? Thanks in advance!
Author
Member

There will be an experimental GN Instance export on 4.1 (with or without using gpu instancing).
So I think we can close this ticket now.
Thanks!

There will be an experimental GN Instance export on 4.1 (with or without using gpu instancing). So I think we can close this ticket now. Thanks!
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2024-01-05 17:02:32 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#94953
No description provided.