mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix ambient light cubemap (#535)
It was unintentionally flipped before.
This commit is contained in:
commit
5fc8c842b3
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
ManifestFileVersion: 0
|
||||
CRC: 192875128
|
||||
CRC: 3537427957
|
||||
Hashes:
|
||||
AssetFileHash:
|
||||
serializedVersion: 2
|
||||
Hash: bd3accfa8245e7e8c1fe0bf8cfa04eb1
|
||||
Hash: c4d8f41970054074bb375ac5cbe82855
|
||||
TypeTreeHash:
|
||||
serializedVersion: 2
|
||||
Hash: de71b9c55befb829b1640ea21774b932
|
||||
@ -171,7 +171,7 @@ ClassTypes:
|
||||
Script: {instanceID: 0}
|
||||
SerializeReferenceClassIdentifiers: []
|
||||
Assets:
|
||||
- Assets/AmbientLight_QM.png
|
||||
- Assets/BrambleCollision.prefab
|
||||
- Assets/Vessel_Body.prefab
|
||||
- Assets/AmbientLight_QM.png
|
||||
Dependencies: []
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using UnityEngine;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.External.Modules;
|
||||
using System;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
public static class AmbientLightBuilder
|
||||
@ -32,30 +34,25 @@ namespace NewHorizons.Builder.General
|
||||
if (config.tint != null)
|
||||
{
|
||||
var tint = config.tint.ToColor();
|
||||
var cubemap = Main.NHPrivateAssetBundle.LoadAsset<Cubemap>("AmbientLight_QM");
|
||||
var cubemapFace = CubemapFace.Unknown;
|
||||
var baseCubemap = Main.NHPrivateAssetBundle.LoadAsset<Cubemap>("AmbientLight_QM");
|
||||
var cubemap = new Cubemap(baseCubemap.width, baseCubemap.format, baseCubemap.mipmapCount != 1);
|
||||
cubemap.name = baseCubemap.name + "Tinted";
|
||||
cubemap.wrapMode = baseCubemap.wrapMode;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: cubemapFace = CubemapFace.PositiveX; break;
|
||||
case 1: cubemapFace = CubemapFace.NegativeX; break;
|
||||
case 2: cubemapFace = CubemapFace.PositiveY; break;
|
||||
case 3: cubemapFace = CubemapFace.NegativeY; break;
|
||||
case 4: cubemapFace = CubemapFace.PositiveZ; break;
|
||||
case 5: cubemapFace = CubemapFace.NegativeZ; break;
|
||||
default: break;
|
||||
}
|
||||
var sourceColors = cubemap.GetPixels(cubemapFace, 0);
|
||||
var cubemapFace = (CubemapFace)i;
|
||||
var sourceColors = baseCubemap.GetPixels(cubemapFace);
|
||||
var newColors = new Color[sourceColors.Length];
|
||||
for (int j = 0; j < sourceColors.Length; j++)
|
||||
{
|
||||
var grey = sourceColors[j].grayscale * 2;
|
||||
newColors[j] = tint * new Color(grey, grey, grey);
|
||||
var grey = sourceColors[j].grayscale * 2; // looks nicer with multiplier
|
||||
newColors[j] = new Color(grey, grey, grey) * tint;
|
||||
}
|
||||
cubemap.SetPixels(newColors, cubemapFace);
|
||||
}
|
||||
cubemap.Apply();
|
||||
ImageUtilities.TrackGeneratedTexture(cubemap);
|
||||
|
||||
light.cookie = cubemap;
|
||||
}
|
||||
|
||||
|
||||
@ -7,14 +7,19 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace NewHorizons.Utility
|
||||
{
|
||||
public static class ImageUtilities
|
||||
{
|
||||
private static Dictionary<string, Texture2D> _loadedTextures = new Dictionary<string, Texture2D>();
|
||||
private static List<Texture2D> _generatedTextures = new List<Texture2D>();
|
||||
private static readonly Dictionary<string, Texture2D> _loadedTextures = new();
|
||||
private static readonly List<Texture> _generatedTextures = new();
|
||||
|
||||
/// <summary>
|
||||
/// Track textures generated outside of this file so they can be cleaned up on scene unload
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
public static void TrackGeneratedTexture(Texture texture) => _generatedTextures.Add(texture);
|
||||
|
||||
public static bool IsTextureLoaded(IModBehaviour mod, string filename)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user