diff --git a/CUE4Parse b/CUE4Parse index 57e63513..2f5fbe8a 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 57e63513cacfcf784396030367c2243347b2800a +Subproject commit 2f5fbe8a852a4c91d19616d45b784b62efca4753 diff --git a/FModel/Creator/Bases/FN/BaseOfferDisplayData.cs b/FModel/Creator/Bases/FN/BaseOfferDisplayData.cs index 250a6ab3..721c53fe 100644 --- a/FModel/Creator/Bases/FN/BaseOfferDisplayData.cs +++ b/FModel/Creator/Bases/FN/BaseOfferDisplayData.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using CUE4Parse.UE4.Assets.Exports; using CUE4Parse.UE4.Assets.Exports.Material; using CUE4Parse.UE4.Assets.Objects; @@ -8,10 +9,11 @@ namespace FModel.Creator.Bases.FN; public class BaseOfferDisplayData : UCreator { - private BaseMaterialInstance[] _offerImages; + private readonly List _offerImages; public BaseOfferDisplayData(UObject uObject, EIconStyle style) : base(uObject, style) { + _offerImages = new List(); } public override void ParseForInfo() @@ -19,24 +21,23 @@ public class BaseOfferDisplayData : UCreator if (!Object.TryGetValue(out FStructFallback[] contextualPresentations, "ContextualPresentations")) return; - _offerImages = new BaseMaterialInstance[contextualPresentations.Length]; - for (var i = 0; i < _offerImages.Length; i++) + for (var i = 0; i < contextualPresentations.Length; i++) { if (!contextualPresentations[i].TryGetValue(out FSoftObjectPath material, "Material") || !material.TryLoad(out UMaterialInterface presentation)) continue; var offerImage = new BaseMaterialInstance(presentation, Style); offerImage.ParseForInfo(); - _offerImages[i] = offerImage; + _offerImages.Add(offerImage); } } public override SKBitmap[] Draw() { - var ret = new SKBitmap[_offerImages.Length]; + var ret = new SKBitmap[_offerImages.Count]; for (var i = 0; i < ret.Length; i++) { - ret[i] = _offerImages[i].Draw()[0]; + ret[i] = _offerImages[i]?.Draw()[0]; } return ret; diff --git a/FModel/Views/Snooper/Shading/Texture.cs b/FModel/Views/Snooper/Shading/Texture.cs index 1ec41a28..e5d37d29 100644 --- a/FModel/Views/Snooper/Shading/Texture.cs +++ b/FModel/Views/Snooper/Shading/Texture.cs @@ -92,7 +92,19 @@ public class Texture : IDisposable Height = bitmap.Height; Bind(TextureUnit.Texture0); - GL.TexImage2D(_target, 0, texture2D.SRGB ? PixelInternalFormat.Srgb : PixelInternalFormat.Rgb, Width, Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, bitmap.Bytes); + var internalFormat = Format switch + { + EPixelFormat.PF_G8 => PixelInternalFormat.R8, + _ => texture2D.SRGB ? PixelInternalFormat.Srgb : PixelInternalFormat.Rgb + }; + + var pixelFormat = Format switch + { + EPixelFormat.PF_G8 => PixelFormat.Red, + _ => PixelFormat.Rgba + }; + + GL.TexImage2D(_target, 0, internalFormat, Width, Height, 0, pixelFormat, PixelType.UnsignedByte, bitmap.Bytes); GL.TexParameter(_target, TextureParameterName.TextureMinFilter, (int) TextureMinFilter.LinearMipmapLinear); GL.TexParameter(_target, TextureParameterName.TextureMagFilter, (int) TextureMagFilter.Linear); GL.TexParameter(_target, TextureParameterName.TextureBaseLevel, 0);