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

TEXCOORD_1 は export しない #2172

Merged
merged 1 commit into from
Oct 23, 2023
Merged

Conversation

ousttrue
Copy link
Contributor

@ousttrue ousttrue commented Oct 20, 2023

fixed #2167

現状、Unity 上で2番目以降の UV を正しく反映する実装が無いのでエクスポートしない。

正しく反映 するには glTF と互換性のある shader にする必要があるのだが、
Unity の Standard と glTF の仕様が違うので対応予定無し。

  • glTF は TextureInfo 毎に UV のチャンネルを指定することができる

https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/textureInfo.schema.json#L13

@ousttrue ousttrue requested a review from Santarh October 23, 2023 05:03
@ousttrue ousttrue changed the title add ExportUvSecondary.ExportUvSecondary. but always false TEXCOORD_1 は export しない Oct 23, 2023
/// <summary>
/// Export TEXCOORD_1
/// </summary>
public bool ExportUvSecondary;
Copy link
Contributor

Choose a reason for hiding this comment

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

将来的に uv 3 番目、4 番目…となる可能性はあると思うが、じゃあ bool[] とかにするかというとそれも違うなあとは思うので、そうなったら愚直に追加でいいか。

/// </summary>
public bool KeepVertexColor;
public bool ExportVertexColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

ついでに Rename?

@@ -43,12 +43,16 @@ public static class MeshExporter_SharedVertexBuffer
}

var uvAccessorIndex0 = data.ExtendBufferAndGetAccessorIndex(mesh.uv.Select(y => y.ReverseUV()).ToArray(), glBufferTarget.ARRAY_BUFFER);
var uvAccessorIndex1 = data.ExtendBufferAndGetAccessorIndex(mesh.uv2.Select(y => y.ReverseUV()).ToArray(), glBufferTarget.ARRAY_BUFFER);
Copy link
Contributor

Choose a reason for hiding this comment

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

従来はデフォルトで UV2 を出力していた

Copy link
Contributor Author

@ousttrue ousttrue Oct 23, 2023

Choose a reason for hiding this comment

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

おそらく、#1798 を契機に mesh.uv2 が null にならなくなったと思われます。

で mesh エクスポートの経路が glbとvrm0(shared / divided) + vrm1 で3種類あって、
今回修正した glb/vrm0 shared だけ uv2 が漏れ出るようになってしまった。
他の2本は、あとで作ったときに最初から uv2 をオミットしているぽい。

vertexbuffer(shared) が歴史的経緯により一番古い。

var uvAccessorIndex1 = -1;
if (settings.ExportUvSecondary)
{
uvAccessorIndex1 = data.ExtendBufferAndGetAccessorIndex(mesh.uv2.Select(y => y.ReverseUV()).ToArray(), glBufferTarget.ARRAY_BUFFER);
Copy link
Contributor

Choose a reason for hiding this comment

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

具体的な出力実装は変えず、出力するかどうかを選択式にした

@ousttrue ousttrue merged commit c43f86b into vrm-c:master Oct 23, 2023
1 check passed
@ousttrue ousttrue deleted the fix/not_export_uv2 branch January 24, 2024 06:13
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.

[Exporter] エクスポート時に uv2 の未使用チェックを追加する
2 participants