Fix slide colors (#986)

## Bug fixes

- fix bug where projected slides look too bright
This commit is contained in:
Will Corby 2024-10-31 12:59:19 -07:00 committed by GitHub
commit d7f0fd493f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,8 +102,8 @@ namespace NewHorizons.Utility.Files
} }
/// <summary> /// <summary>
/// used specifically for projected slides. /// used to fix projection slides
/// also adds a border (to prevent weird visual bug) and makes the texture linear (otherwise the projected image is too bright). /// adds a border (to prevent weird visual bug) and does some magic with gamma correction and inverting
/// </summary> /// </summary>
public static Texture2D InvertSlideReel(IModBehaviour mod, Texture2D texture, string originalPath) public static Texture2D InvertSlideReel(IModBehaviour mod, Texture2D texture, string originalPath)
{ {
@ -136,13 +136,20 @@ namespace NewHorizons.Utility.Files
} }
else else
{ {
pixels[i].r = 1f - pixels[i].r; // convert gamma to linear, then invert
pixels[i].g = 1f - pixels[i].g; // outer wilds will invert, then convert linear to gamma (reversing the process)
pixels[i].b = 1f - pixels[i].b; pixels[i].r = 1f - Mathf.GammaToLinearSpace(pixels[i].r);
pixels[i].g = 1f - Mathf.GammaToLinearSpace(pixels[i].g);
pixels[i].b = 1f - Mathf.GammaToLinearSpace(pixels[i].b);
} }
} }
var newTexture = new Texture2D(texture.width, texture.height, texture.format, texture.mipmapCount != 1, true); // making this linear makes vanilla reel atlas match vanilla reels.
// however, it also makes it darker than the source image.
// for custom slides this is unintuitive.
// people will be like "wtf why is it darker than my image?"
// see https://github.com/Outer-Wilds-New-Horizons/new-horizons/pull/986#issuecomment-2449223761 for comparisons
var newTexture = new Texture2D(texture.width, texture.height, texture.format, texture.mipmapCount != 1);
newTexture.name = key; newTexture.name = key;
newTexture.SetPixels(pixels); newTexture.SetPixels(pixels);
newTexture.Apply(); newTexture.Apply();