Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditorSceneImporterMesh does not support default blend shape weights. #49005

Open
Tracked by #63198
lyuma opened this issue May 23, 2021 · 2 comments
Open
Tracked by #63198

EditorSceneImporterMesh does not support default blend shape weights. #49005

lyuma opened this issue May 23, 2021 · 2 comments

Comments

@lyuma
Copy link
Contributor

lyuma commented May 23, 2021

Godot version:
4.0.dev 45d3b96

OS/device including version:
Windows 10.0.19041.985

Issue description:
glTF 2.0 permits meshes to assign "weights" to set blend shapes at a default value.

However, EditorSceneImporterMesh does not have an API to assign weights. This problem affects at least glTF. It could also affect COLLADA or FBX if those store the default blend weights.

The code in GLTFDocument::_generate_mesh_instance does the following to assign the blend shape weights onto the mesh:

	Ref<EditorSceneImporterMesh> import_mesh = mesh->get_mesh();
	if (import_mesh.is_null()) {
		return mi;
	}
	mi->set_mesh(import_mesh);
	for (int i = 0; i < mesh->get_blend_weights().size(); i++) {
		mi->set("blend_shapes/" + mesh->get_mesh()->get_blend_shape_name(i), mesh->get_blend_weights()[i]);
	}

I have verified with a debugger that this code all works. However, mi is an EditorSceneImporterMesh, which does not define properties for blend_shapes/... so that set() call is ignored.

The sample glTF model uses the following JSON:

  "meshes": [
    {
      "weights": [
        0.5
      ],
      "name": "mesh",
      "primitives": [
        {
          "attributes": {
            "NORMAL": 1,
            "POSITION": 2,
            "TEXCOORD_0": 3
          },
          "indices": 0,
          "material": 0,
          "targets": [
            {
              "POSITION": 4
            }
          ],
          "mode": 4
        },
        {
          "attributes": {
            "POSITION": 7,
            "NORMAL": 6,
            "TEXCOORD_0": 8
          },
          "indices": 5,
          "material": 1,
          "targets": [
            {
              "POSITION": 9
            }
          ],
          "mode": 4
        }
      ]
    }
  ],

Steps to reproduce:

  1. Open the attached process.
  2. Check the MorphPrimitivesTest model.
  3. Compare it against the screenshot. It is supposed to be bumpy (weight = 0.5).
  4. However, in master branch, the plane will be completely flat (weight = 0.0)

Minimal reproduction project:
gltf_khronos_morph_primitives.zip

@KoBeWi
Copy link
Member

KoBeWi commented May 25, 2022

Still valid in 2ec379e
Why is this labelled as regression though?

@lyuma
Copy link
Contributor Author

lyuma commented May 25, 2022

It's a regression because the initial blend weights set by imported glTF files, such as the 0.5 in the example, are being ignored, while it used to work with the old ArrayMesh api.

Without fixing ImporterMeshInstance3D, there isn't an obvious way to store the default blend weights during the import process, up until the final ArrayMesh is generated. ImporterMeshInstance3D is the place that makes sense.

@clayjohn clayjohn modified the milestones: 4.0, 4.x Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants