Skip to content

Commit

Permalink
Export Texture: remove GL.sRGBWrite, set export settings linear first…
Browse files Browse the repository at this point in the history
… before using Texture importer settings for unknown formats
  • Loading branch information
marwie committed Oct 19, 2022
1 parent 916ee39 commit 5c2457b
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ private ImageId ExportImageInternalBuffer(UniqueTexture uniqueTexture, string te

if (!wasAbleToExport)
{
var sRGB = true;
var sRGB = !exportSettings.linear;

#if UNITY_EDITOR
if (textureSlot == TextureMapType.Custom_Unknown)
Expand All @@ -532,11 +532,10 @@ private ImageId ExportImageInternalBuffer(UniqueTexture uniqueTexture, string te
var height = uniqueTexture.GetHeight();

// TODO we could make sure texture size is power-of-two here
var destRenderTexture = RenderTexture.GetTemporary(width, height, 24, RenderTextureFormat.ARGB32, format);
GL.sRGBWrite = sRGB;

if (exportSettings.linear)
GL.sRGBWrite = false;
var destRenderTexture = RenderTexture.GetTemporary(width, height, 24, RenderTextureFormat.Default, format);
// var previousSRGBState = GL.sRGBWrite;
// GL.sRGBWrite = sRGB;

var shader = GetConversionMaterial(exportSettings);
if (shader && shader.HasProperty("_SmoothnessMultiplier"))
Expand Down Expand Up @@ -575,7 +574,7 @@ private ImageId ExportImageInternalBuffer(UniqueTexture uniqueTexture, string te

RenderTexture.ReleaseTemporary(destRenderTexture);

GL.sRGBWrite = false;
// GL.sRGBWrite = previousSRGBState;
if (Application.isEditor)
{
UnityEngine.Object.DestroyImmediate(exportTexture);
Expand Down

0 comments on commit 5c2457b

Please sign in to comment.