Skip to content

Commit

Permalink
Keep original SRGB usage on .astc replace
Browse files Browse the repository at this point in the history
  • Loading branch information
KillzXGaming committed Oct 22, 2023
1 parent 72286ab commit 0e52ac9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions File_Format_Library/FileFormats/Texture/BNTX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,9 @@ public void Replace(string FileName, uint MaxMipLevel = 0, uint ArrayIndex = 0,
ImageDataCached.Add(sliceData);
}

//Check if current texture is SRGB
bool srgb = Texture != null && Texture.UseSRGB;

switch (ext)
{
case ".bftex":
Expand All @@ -1577,7 +1580,8 @@ public void Replace(string FileName, uint MaxMipLevel = 0, uint ArrayIndex = 0,
break;
case ".astc":
setting.LoadASTC(FileName);
ApplyImportSettings(setting, STCompressionMode.Normal, false);
//Keep original SRGB setting as .astc has no SRGB flags
ApplyImportSettings(setting, STCompressionMode.Normal, false, srgb);
break;
default:
setting.LoadBitMap(FileName);
Expand Down Expand Up @@ -1610,7 +1614,7 @@ public void Replace(string FileName, uint MaxMipLevel = 0, uint ArrayIndex = 0,
Texture.TextureData.Add(ImageDataCached[i]);
}
}
public void ApplyImportSettings(TextureImporterSettings setting,STCompressionMode CompressionMode, bool multiThread)
public void ApplyImportSettings(TextureImporterSettings setting,STCompressionMode CompressionMode, bool multiThread, bool force_srgb = false)
{
Cursor.Current = Cursors.WaitCursor;

Expand All @@ -1627,6 +1631,8 @@ public void ApplyImportSettings(TextureImporterSettings setting,STCompressionMod
}

tex.Name = Text;
if (force_srgb)
tex.UseSRGB = true;

Texture = tex;
Load(tex);
Expand Down

0 comments on commit 0e52ac9

Please sign in to comment.