Skip to content

Commit

Permalink
force streaming mip maps, force crunch off, force uncompressed to be …
Browse files Browse the repository at this point in the history
…normal quality compression
  • Loading branch information
I5UCC committed Apr 17, 2024
1 parent fcdac14 commit 0db961d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 18 deletions.
61 changes: 45 additions & 16 deletions I5Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,56 @@ public static void OptimizeTextureFormats()
Debug.LogWarning("Failed to get TextureImporter for asset: " + assetPath);
continue;
}
else if (importer.textureType != TextureImporterType.NormalMap && importer.textureType != TextureImporterType.Default)
TextureImporterPlatformSettings standalone = importer.GetPlatformTextureSettings("Standalone");
if (standalone == null)
{
Debug.LogWarning("Failed to get Standalone TextureImporterPlatformSettings for asset: " + assetPath);
continue;
}
TextureImporterPlatformSettings standalone = importer.GetPlatformTextureSettings("Standalone");

if (importer.textureType == TextureImporterType.NormalMap && (standalone.format != TextureImporterFormat.BC5 || !standalone.overridden))
{
Debug.Log("Normal map not in BC5 format: " + assetPath);
standalone.overridden = true;
standalone.maxTextureSize = importer.maxTextureSize;
standalone.format = TextureImporterFormat.BC5;
importer.SetPlatformTextureSettings(standalone);
changesMade = true;
}
else if (importer.textureType == TextureImporterType.Default && importer.textureCompression != TextureImporterCompression.CompressedHQ && importer.DoesSourceTextureHaveAlpha() && importer.alphaSource != TextureImporterAlphaSource.None && importer.sRGBTexture)
switch (importer.textureType)
{
Debug.Log("Texture with alpha not in BC7 format: " + assetPath);
importer.textureCompression = TextureImporterCompression.CompressedHQ;
importer.alphaIsTransparency = true;
changesMade = true;
case TextureImporterType.Default:
if (!importer.mipmapEnabled || !importer.streamingMipmaps)
{
Debug.Log("Enabling mipmap streaming: " + assetPath);
importer.mipmapEnabled = true;
importer.streamingMipmaps = true;
changesMade = true;
}
if (importer.crunchedCompression)
{
Debug.Log("Uncrunching texture: " + assetPath);
importer.crunchedCompression = false;
changesMade = true;
}
if (importer.textureCompression == TextureImporterCompression.Uncompressed)
{
Debug.Log("Compressing texture: " + assetPath);
importer.textureCompression = TextureImporterCompression.Compressed;
changesMade = true;
}
if (importer.textureCompression != TextureImporterCompression.CompressedHQ && importer.DoesSourceTextureHaveAlpha() && importer.alphaSource != TextureImporterAlphaSource.None && importer.sRGBTexture)
{
Debug.Log("Setting texture compression to BC7: " + assetPath);
importer.textureCompression = TextureImporterCompression.CompressedHQ;
importer.alphaIsTransparency = true;
changesMade = true;
}
break;
case TextureImporterType.NormalMap:
if (standalone.format != TextureImporterFormat.BC5 || !standalone.overridden)
{
Debug.Log("Normal map not in BC5 format: " + assetPath);
standalone.overridden = true;
standalone.maxTextureSize = importer.maxTextureSize;
standalone.format = TextureImporterFormat.BC5;
importer.SetPlatformTextureSettings(standalone);
changesMade = true;
}
break;
default:
break;
}
}

Expand Down
7 changes: 7 additions & 0 deletions LICENSE.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# I5UnityTools [![Github All Releases](https://img.shields.io/github/downloads/i5ucc/I5UnityTools/total.svg)](https://github.com/I5UCC/I5UnityTools/releases/latest) <a href='https://ko-fi.com/i5ucc' target='_blank'><img height='35' style='border:0px;height:25px;' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' />

A set of opinionated tools for VRChat Avatar creation.
Just a few things that make my Avatar Creation workflow a bit easier. I'll add stuff on the go.

All tools located in `Tools/I5Tools`

Expand Down
7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.i5ucc.tools",
"displayName": "I5Tools",
"version": "0.1.2",
"version": "0.1.3",
"description": "Just a few things that make Avatar Creation workflow a bit easier.",
"files": [
"I5Tools.cs",
Expand Down

0 comments on commit 0db961d

Please sign in to comment.