godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.32k stars 20.24k forks source link

MultiMeshInstance2D draws textures upside down #44347

Closed godotdot closed 3 years ago

godotdot commented 3 years ago

Godot version: Godot_v3.2.3-stable_mono_win64

OS/device including version: Windows 10 / Desktop

AMD Radeon RX580 Driver: 20.9.1 Backend: GLES3

Issue description:

Using a MultiMeshInstance2D with a texture and quad mesh, the texture renders upside down. I expected the texture to render in an upright fashion.

Steps to reproduce: 1 - Create a Node2D scene. 2 - Add a MultiMeshInstance2D to the scene. 3 - Assign a texture to the MultiMeshInstance2D's texture property. 4 - Assign a new MultiMesh to the multimesh property. 5 - Set the MultiMesh's transform_format mode to 2D 6 - Assign a new quad mesh to the multimesh's mesh property. 7 - Increase the MultiMesh's instance count. 8 - Use set_instance_transform_2d to position instances.

9 - (Optional) Add a Camera2D to the scene.

10 - Run the scene, notice the texture is upside down. Also notice, by adjusting the instance count, that the instances are positioned correctly; it is only the texture that is upside down.

Minimal reproduction project: UpsideDownMultiMesh2D.zip

clayjohn commented 3 years ago

I ran your example project. The issue isn't with the MultiMeshInstance2D. The issue is that you are using a 3D QuadMesh instead of a 2D mesh. The QuadMesh has different UVs than a regular Sprite which results in your textures drawing upside down from what you expected.

I suggest using a 2D mesh that matches the orientation that you expect.

You can either create your own with the ArrayMesh API, or you can create one from a Sprite. Creating a mesh from a Sprite is much simpler, you 1) create a Sprite, 2) assign the texture you want to use to the Sprite, 3) click on "Sprite" in the upper toolbar, 4) click "convert to Mesh" 5) copy the resulting Mesh into your MultiMesh.