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

同一のMeshとMaterialを参照しているNodeをExportする場合に、重複をチェックして同じMeshIndexを参照するように変更 #899

Merged
merged 1 commit into from
Apr 21, 2021

Conversation

hiroj
Copy link
Contributor

@hiroj hiroj commented Apr 21, 2021

  • Rendererのインスタンス一致でmeshIndexを決定してた部分を、MeshインスタンスとMaterialインスタンスを見てmeshIndexを決定するように変更
    image

  • Cube_1とCube_2はそれぞれRendererコンポーネントが付いている状態

  • 両方とも同じMeshとMaterialインスタンスをRendererが参照している

  • このプルリクの変更を入れてExportした場合、以下のjsonのように両方ともmeshIndex = 0を指し、かつmeshは1つだけexportされる

  • 以下Exportしたglbの中身を一部抜粋

  "nodes": [
    {
      "mesh": 0,
      "name": "Cube_1",
      "rotation": [
        0,
        0,
        0,
        1
      ],
      "scale": [
        1,
        1,
        1
      ],
      "translation": [
        0,
        0,
        0
      ]
    },
    {
      "mesh": 0,
      "name": "Cube_2",
      "rotation": [
        0,
        0,
        0,
        1
      ],
      "scale": [
        1,
        1,
        1
      ],
      "translation": [
        0,
        0,
        0
      ]
    }
  ],
  "meshes": [
    {
      "extras": {
        "targetNames": []
      },
      "name": "Cube",
      "primitives": [
        {
          "attributes": {
            "NORMAL": 1,
            "POSITION": 0,
            "TEXCOORD_0": 2,
            "TEXCOORD_1": 3
          },
          "extras": {
            "targetNames": []
          },
          "indices": 4,
          "material": 0,
          "mode": 4
        }
      ]
    }
  ],

@hiroj hiroj requested a review from ousttrue April 21, 2021 09:35
@@ -205,10 +250,10 @@ public virtual void Export(MeshExportSettings meshExportSettings, Func<Texture,
#endregion

#region Nodes and Skins
var unitySkins = unityMeshes
var unitySkins = uniqueUnityMeshes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スキニングの対処はこれで問題が出ないかどうか見てほしいかもしれない

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

心配であればこの機能を使うオプションを MeshExportSettings に追加して、
デフォルトで false にしてもらえると。

Copy link
Contributor

@ousttrue ousttrue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unity は renderer.materials なのだが、 glTF は mesh.materials なので、mesh と materials 両方が同じなら同じとみなせる

@ousttrue ousttrue merged commit af50e8e into vrm-c:master Apr 21, 2021
hiroj added a commit to hiroj/UniVRM that referenced this pull request Apr 22, 2021
@hiroj hiroj mentioned this pull request Apr 22, 2021
ousttrue added a commit that referenced this pull request Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants