godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 97 forks source link

Add a glTF2 scene exporter #885

Closed fire closed 3 years ago

fire commented 6 years ago

Describe the project you are working on: 3d multiplayer game

Describe the problem or limitation you are having in your project: I wish to export my scene to a standardized exchange format.

Describe the feature / enhancement and how it helps to overcome the problem or limitation: It would be useful to expose an engine api for a scene exporter. The ideal case is that we can click on a scene and then export it as a gltf2 file.

It may not be possible to be lossless exporting from scene to gltf2 and back to scene, but it would be helpful for these cases:

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

This is a description of the architecture of the gltf plugin at https://github.com/godot-extended-libraries/gltf.

I split the importer into a glTF2 document and an importer. This allows us to modify the document to be a exporter.

This also allows for extensions through https://github.com/godotengine/godot-proposals/issues/1463 for import and export.

PRs:

If this enhancement will not be used often, can it be worked around with a few lines of script?:

Have to port 3000 lines of core module code to gdnative because it includes the importer code too.

Is there a reason why this should be core and not an add-on in the asset library?: Core code is large and I do not want to duplicate it. This moves the gltf2 importer into a doument and two plugins (import and export). If I make the gltf2 exporter a GDNative plugin which is possible, I can't do this without duplication. glTF runtime import is also a requested feature from the community and also export.

Older Proposal

Click for the old proposal.

@reduz I require a Scene Exporter api exposed to gdnative. Importing scenes has a large dialog of options, so would exporting scenes. ``` reduz: is roundtrip from godot to gltf2 part of the roadmap? iFire: not really why would you want to export glTF from a game engine? unless we get a level editor… Calinou: why not? then it would start making *some* sense (and not that much) Calinou: well it just feels more proper to import any format and then export as gltf2. A) I can then put it in sketchfab B) Save a copy of the scene in gltf format because it's changed now C) move the scene to another game engine ;) again, it's not relevant until we get a level editor I thought the scene editor is a level editor once we have that, it has one main use: making renders in Blender or similar. Only really high-end games can afford this, so it is probably not a priority at all it is not quite one. it doesn't let you create actual geometry using a GUI (CSG or similar) I don't care about, that's a workflow thing also, remember that Godot and Blender materials are not fully compatible anyway some people use csg others use models Eevee should be mostly similar, but you're going to have to wait 5 years until most people use it :/ Calinou: but gltf is a workable process for standardizing the import there are blender import pipelines for gltf2 how good are the importers, too? https://github.com/ksons/gltf-blender-importer <- apparently the importer and exporter are different projects Calinou: anyways for my use case I don't need to go all the way to blender Well I think it would be nice to have a gltf2 export feature as a plugin, someone just needs to write it Akien: Can you expose the apis? There is no huge use case, but it's still nice to have. I like the idea to export a 3.1 scene as gltf2 and import it against in Godot 8 I don't know what I need iFire: Then how would I know? :p Best would be to start and see what you are missing. GDScript would be too slow for this, probably (for large scenes) I don't think so. Blender's plugins are in python :) Akien: I was able to get a fbx importer but the gdnative interace has a bug with the import plugin and scanning for the fbx extension. karroffel is on it. do remember that Godot isn't a 3D DCC, it stores vertices and everything differently Calinou: I don't see how it's impossible those are only things that make it more difficult is it worth spending time on right now? I might spend time for fun :) or I can make a game lol I don't find that task particularly fun I'd find new renderer features funnier or, you know, a 3D level editor ```

reduz commented 6 years ago

I would provide it as a GDNative addon via asset library

On Sat, Dec 16, 2017 at 5:17 PM, K. S. Ernest (iFire) Lee < notifications@github.com> wrote:

Godot master Issue description: It would be useful to expose an engine api for a scene exporter. The ideal case is that we can click on a scene and then export it as a gltf2 file.

It may not be possible to be lossless exporting from scene to gltf2 and back to scene, but it would be helpful for these cases:

  • Easy export to sketchfab
  • Easy export to blender
  • Storing scenes in a standard format that can be sent to another engine / renderer / future godot version.

@reduz https://github.com/reduz I require a Scene Exporter api exposed to gdnative. Importing scenes has a large dialog of options, so would exporting scenes.

Steps to reproduce:

  • Click on scene
  • Export as gltf2

** Irc Log ***

reduz: is roundtrip from godot to gltf2 part of the roadmap? iFire: not really why would you want to export glTF from a game engine? unless we get a level editor… Calinou: why not? then it would start making *some* sense (and not that much) Calinou: well it just feels more proper to import any format and then export as gltf2. A) I can then put it in sketchfab B) Save a copy of the scene in gltf format because it's changed now C) move the scene to another game engine ;) again, it's not relevant until we get a level editor I thought the scene editor is a level editor once we have that, it has one main use: making renders in Blender or similar. Only really high-end games can afford this, so it is probably not a priority at all it is not quite one. it doesn't let you create actual geometry using a GUI (CSG or similar) I don't care about, that's a workflow thing also, remember that Godot and Blender materials are not fully compatible anyway some people use csg others use models Eevee should be mostly similar, but you're going to have to wait 5 years until most people use it :/ Calinou: but gltf is a workable process for standardizing the import there are blender import pipelines for gltf2 how good are the importers, too? https://github.com/ksons/gltf-blender-importer <- apparently the importer and exporter are different projects Calinou: anyways for my use case I don't need to go all the way to blender Well I think it would be nice to have a gltf2 export feature as a plugin, someone just needs to write it Akien: Can you expose the apis? There is no huge use case, but it's still nice to have. I like the idea to export a 3.1 scene as gltf2 and import it against in Godot 8 I don't know what I need iFire: Then how would I know? :p Best would be to start and see what you are missing. GDScript would be too slow for this, probably (for large scenes) I don't think so. Blender's plugins are in python :) Akien: I was able to get a fbx importer but the gdnative interace has a bug with the import plugin and scanning for the fbx extension. karroffel is on it. do remember that Godot isn't a 3D DCC, it stores vertices and everything differently Calinou: I don't see how it's impossible those are only things that make it more difficult is it worth spending time on right now? I might spend time for fun :) or I can make a game lol I don't find that task particularly fun I'd find new renderer features funnier or, you know, a 3D level editor — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .
Gibbz commented 6 years ago

it could be handy to be able to export snapshots of the game in progress scene as a gltf scene also for artists

garyo commented 6 years ago

I'd be interested in this. @fire, did you make any progress on it?

fire commented 6 years ago

I have not done any work feel free to take over. Wanted to write down the concept.

garyo commented 6 years ago

Just FYI, I'm working on this now. Doing it in python. No glTF lib, just creating a big python dict and saving as JSON, with binary blobs coming from int/float python arrays. Textures are a hangup due to godotengine/godot#18109 and there are lots of little details to get worked out before it's done.

supagu commented 6 years ago

Any progress on this? Would be super handy to be able to bring a in game scene into blender for some beauty/marketing renders!

garyo commented 6 years ago

My python version is at https://github.com/garyo/godot-export-gltf, in case it's useful to anyone.

Zireael07 commented 6 years ago

Bump, any news on this?

jonbonazza commented 5 years ago

I think doing this in gdscript vs godot-python would be better. Making someone install godot-python seems a bit ridiculous.

fire commented 5 years ago

I was able to complete work exporting GLTF2:

  1. MeshInstances
  2. GridMaps
  3. CSGShapes

Materials don't work, neither do animations or skeletons.

https://github.com/godotengine/godot/issues/19232#issuecomment-485044353

The GLTF2 scene exporter code needs to be extracted into a module before it is mergable into Godot.

This is all the time I can spend it on this weekend.

Looking for contributors.

fire commented 5 years ago

Here's the github branch:

https://github.com/fire/godot/tree/mesh_export

fire commented 5 years ago

2019-04-20_07-19-01

Here's a picture of the TPS scene exported to GLTF.

Toshiwoz commented 5 years ago

Thank you for this really desirable feature. Awesome that you included also gridmaps.

golddotasksquestions commented 4 years ago
There is no huge use case, but it's still nice to have.

I'd like to state that there is indeed a huge usecase for this for all level designers. It would mean they could test and block out levels within Godot using primitives and CSG Meshes and only once they are happy how it plays in game export it to a 3D modeling package for refinement. It would also mean anything generated in realtime could be used outside of Godot. I'm actually surprised it's considered just a "nice to have".

eon-s commented 4 years ago

@golddotasksquestions you are quoting something from 2 years ago, now if you check the WIP PRs, there is work towards more than just CSG, full scenes may be able to be exported soon to a couple of formats.

And this issue may need to be closed and a another opened on the proposals repository with a summary of the current state of the PRs.

hansagames commented 4 years ago

Any progress on this ? :)

fire commented 4 years ago

I've updated the proposal and started a pr chain on Godot Engine master.

wajrou commented 3 years ago

Any progress on exporting to blender through glTF2? :-)

Calinou commented 3 years ago

Any progress on exporting to blender through glTF2? :-)

This is now implemented: https://godotengine.org/article/introducing-the-godot-gltf-2-0-scene-exporter

The feature will only be available in Godot 4.0, not 3.2.x. Edit: The gltf module was backported from 4.0 to 3.x, making the feature available in Godot 3.4 and later. Check the Project > Tools menu at the top of the editor :slightly_smiling_face: