Skip to content

Commit

Permalink
fix: normal textures in glTF exported with wrong color space, builtin…
Browse files Browse the repository at this point in the history
… texture paths not correct
  • Loading branch information
hybridherbst committed Jun 1, 2022
1 parent fbccd83 commit 56502fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion UnityGLTF/Assets/UnityGLTF/Editor/Scripts/GLTFExportMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ public static string RetrieveTexturePath(UnityEngine.Texture texture)
{
var path = AssetDatabase.GetAssetPath(texture);
// texture is a subasset
if(AssetDatabase.GetMainAssetTypeAtPath(path) != typeof(Texture2D))
if (AssetDatabase.GetMainAssetTypeAtPath(path) != typeof(Texture2D))
{
var ext = System.IO.Path.GetExtension(path);
if (string.IsNullOrWhiteSpace(ext)) return texture.name + ".png";
path = path.Replace(ext, "-" + texture.name + ext);
}
return path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ private void ExportMetallicGlossTexture(Texture2D texture, string outputPath, bo
/// <param name="outputPath">The location to export the texture</param>
private void ExportNormalTexture(Texture2D texture, string outputPath)
{
var destRenderTexture = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
var destRenderTexture = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
Graphics.Blit(texture, destRenderTexture, _normalChannelMaterial);
WriteRenderTextureToDiskAndRelease(destRenderTexture, outputPath, false);
}
Expand Down

0 comments on commit 56502fa

Please sign in to comment.