-
Notifications
You must be signed in to change notification settings - Fork 430
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
Restrict conditions about using raw texture file bytes while exporting glTF in UnityEditor. #967
Conversation
{ | ||
if (texture is Texture2D texture2D && !string.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(texture2D))) | ||
// Exists as UnityEditor Texture2D Assets ? | ||
if (!TryGetAsEditorTexture2DAsset(texture, out var texture2D, out var textureImporter)) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editor に Asset として存在しない Texture2D は使用しない
if (!TryGetAsEditorTexture2DAsset(texture, out var texture2D, out var textureImporter)) return false; | ||
|
||
// Maintain original width/height ? | ||
if (!IsTextureSizeMaintained(texture2D, textureImporter)) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asset Importer の設定で画像サイズを縮小するように求めている Texture2D は使用しない
if (!IsTextureSizeMaintained(texture2D, textureImporter)) return false; | ||
|
||
// Equals color space ? | ||
if (!IsFileColorSpaceSameWithExportColorSpace(texture2D, textureImporter, exportColorSpace)) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glTF Texture Property と Unity Texture Asset Importer の色空間が異なるときは使用しない
// | ||
case TextureImporterType.Default: | ||
break; | ||
case TextureImporterType.NormalMap: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unity Texture Asset Importer の Texture Type が Normal map であるときは使用しない
} | ||
// NormalMap Property のテクスチャは必ず NormalMap として解釈してコピーする。 | ||
// Texture Asset の設定に依らず、Standard Shader で得られる見た目と同じ結果を得るため。 | ||
var texture2D = NormalConverter.Export(src); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glTF Texture Property が NormalMap であることを求めているときは使用しない
@@ -74,6 +77,42 @@ public void AssignLinearImageToSrgbTextureProperty() | |||
UnityEngine.Object.DestroyImmediate(exportedTex); | |||
} | |||
|
|||
[Test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう
Editor での glTF 出力時、生のテクスチャファイルのデータを使用するか否かの条件を厳しくした。
なぜなら
UnityEngine.Texture2D
が表現するデータと、そのUnityEngine.Texture2D
が参照する画像ファイルのデータは必ずしも一致せず、その一致条件もかなり厳しいからである。具体的には以下の場合に使用しないように変更した。
normalTexture
)Normal map
であるとき