godot-proposals icon indicating copy to clipboard operation
godot-proposals copied to clipboard

Add support for importing 3D scene formats as 2D scenes

Open phymagi opened this issue 8 months ago • 4 comments

Describe the project you are working on

Im developing a 2d game and creating some animations for UI,VFX and characters

Describe the problem or limitation you are having in your project

Import mesh/polygon function almost only works with 3d scene,but it's also useful in 2d scene. Work with meshinstance2d/poloygon2d and skeleton2d in godot is painful,there are two points: 1.Im using meshinstance2d in 2d scene in this way:create mesh in 3d software(blender) and import into godot.But the problem is I cant import animations to 2d scene,which I found works well in 3d scene. Here is a simple mesh deform animation in 3d scene.I create it in blender and import into godot directly,it would be great if we can do the same thing in 2d scene:

Image

Image

Many devolopers use meshes and shaders to create VFX in game.(eg: blade light effect or magic effect,sometimes them need mesh deform animation for better effect)

2.skeleton2d is enough for most animations,but the vertex weight paint system and uv editor are hard to use. You have to manually draw every triangle for meshes . There is not any method to smooth vertex weight,and has not auto-weight tool. Poloygon2d node always change position randomly after edit uv and poloygon.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Import blender file to 2d scene solve all the problem above. UI animations alse benifit from this.We can create vector arts with animation in blender and import as polygon2d ,since some large UI elememts and complex animations may cause perfomance problem(eg:Victory screen ,full screen effects).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Its similar to blender->3d scene importer works,but users should choice a work plane(eg:x-y),then the last axis should be ignored or set to 0 (eg:z-axis). 1.For VFX and UI, just import meshes with baked animations is enough for most situation: - import meshes as poloygon2d/meshinstance2d with texture - convert animations to AnimationPlayer 2.For character animations,its similar to the 3d version that already in godot ,and theres is a difference . - z-index order:maybe we have to split every mesh island to single poloygon2d node ,and order them as the z-height in 3d if the animation is work on x-y-plane.

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

It will be used everyday when users create effects and animtions.

Is there a reason why this should be core and not an add-on in the asset library?

It make creating animation much easier and save a lot of time.Its also a feature that high frequnetly to use.And its alreay a 3d version in godot,why not a 2d version? Thanks for read this proposal.

phymagi avatar Mar 15 '25 09:03 phymagi

Interesting but why not just make 3D game instead?

CarpenterBlue avatar Mar 15 '25 21:03 CarpenterBlue

Interesting but why not just make 3D game instead?

There is many someone might not want to do due to. Chiefly :

  • Performance

  • 2d tooling

  • not dealing with 3d only issues ( z fighting etc)

mk56-spn avatar Mar 15 '25 23:03 mk56-spn

As far as I know you can import arbitrary ArrayMesh from obj file format into the 2d mesh instance.

For animation and interactive ui, we’ve been working on getting lottie fully integrated

fire avatar Mar 22 '25 11:03 fire

I just tested that, it doesn't really work in practice. The mesh gets offset so it's not centered, the scale is all wrong, the UVs gets mangled, shapekeys don't survive the export, the UP and FORWARD axis are incomprehensible, I think I tried every combination of what is up and forward but it is still showing back of the head. I did not bother testing bones.

Furthermore, the mesh is truly 2D, it cannot be rotated or transformed in any other way. But even in this broken state it is showing immense potential, I wish we could just chuck GLTF into it.

If it would just orthographically render the texture as if it was shadeless material with transparency, that would be enough for my usecase. Currently I have to do this with viewports which brings many headaches.

Image Image Image Image

CarpenterBlue avatar Mar 22 '25 12:03 CarpenterBlue

See also https://github.com/godotengine/godot/pull/102028. A PR to make MeshTexture more flexible is welcome, but like I said in that PR, MeshTexture should keep being rendered procedurally in a texture-less manner (i.e. making it truly vector-based).

Calinou avatar Mar 22 '25 18:03 Calinou

As far as I know you can import arbitrary ArrayMesh from obj file format into the 2d mesh instance.

Thanks for your tips.Actually half of the VFXs in my game are created in this way,that's why I found the limitation of MeshInstance2D. The keypoint is mesh with animations,include mesh deform animation(shapekey in blender) and skeleton animation

For animation and interactive ui, we’ve been working on getting lottie fully integrated

Lottie is pretty cool for interactive ui,but seems not enough for game animations.


There are some supplements for my proposal: I think there are 3 level for the importing feature. 1.mesh deform animation,it will improve VFX a lot. Example: Image

2.skeleton2d animations with shadeless material transparency.Maybe we should call it cutout animation in 2D scene,it's enough for most 2d games, a shining point attracts 2d game creators. Many creators hope to keep their artstyle in 2D,so it's necessary to use deform mesh with texture(the artstyle keeps well in this way) and skeleton for animation. Recently,the game "Ender Magnolia: Bloom in the Mist" is animated in this way.(I mean the mesh deform and skeleton,not the tool and pipeline)

And here is a simple example(just a example,it's still not bondinged and animated):

Image

Basically its a 3d model with out y-axis,animators would work with x-z-axis in blender.Rotations only surround y-axis(if the work plane is x-z-axis).So, its no need to deal with 3d mesh problem in godot,just need a way to import in 2d scene and ignore the third axis.

3.full 3d animation in 2d scene,also with shadeless material transparency to keep the artstyle.It's maybe a game changer in 2d game animation,many spine2d animators spend a lot of time on turn-face-animaitons manually which can be finished in 1 second with 3d model. I know nothing about how the 3d object rendered in 2d scene.So nothing useful I can offer in this part. Here is the problem which I mentioned above: Image

The level 3 maybe a unreasonable request,but level 1 and level 2 are absolute useful advices.

And the extra part is about blender: Blender has powerful animation tools,and even better: GeometryNodes! We can create amazing procedural animations(position,rotation,scale and mesh deform) and bake them to basic animations then import in godot directly.I think nobody wants to create huge number animations manually ,either create hundreds tween animation in script. Imagine this:create animations in blender and import into godot directly just like 3d importer does.Simple and elegant,no need to export obj and drag to meshinstance2d's mesh slot for every time creating a new animated object,what a beautiful pipeline!

phymagi avatar Mar 23 '25 10:03 phymagi

Would you be ok if there's importer for gltf into a scene that is a series of node2d and meshinstance2d? It might be doable.

fire avatar Mar 23 '25 22:03 fire

Would you be ok if there's importer for gltf into a scene that is a series of node2d and meshinstance2d? It might be doable.

Of course!Glad to hear that there's a possibility of this proposal .The format of file doesn't matter too much. Thank you very much.I think many creators will benefit from your work.

phymagi avatar Mar 24 '25 04:03 phymagi

Would you be ok if there's importer for gltf into a scene that is a series of node2d and meshinstance2d? It might be doable.

I would be happy for any improvements to mesh instance. Would that mean that it would support GLTF features like shapekeys?

CarpenterBlue avatar Mar 24 '25 12:03 CarpenterBlue

I don't remember MeshInstance2D supporting shapekeys and 2d uses a different skinning system... @clayjohn Any thoughts?

fire avatar Mar 24 '25 14:03 fire