XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Numerics;
using System.Text.Json;

namespace XFEEDToolBox.Core.Rendering;

/// <summary>Original loading-screen EdgeDetection FGM values, shared by every model viewport.</summary>
public sealed record LoadingHologramProfile(Vector4 Sobel,Vector4 TintHigh,Vector4 TintLow,Vector2 ScanlineUvScale,string SourceSha256)
{
    public static LoadingHologramProfile Default{get;}=Read();
    private static LoadingHologramProfile Read()
    {
        using var stream=typeof(LoadingHologramProfile).Assembly.GetManifestResourceStream("XFEEDToolBox.Core.Rendering.loading-hologram-reference.json")!;
        using var document=JsonDocument.Parse(stream);var root=document.RootElement;
        var material=root.GetProperty("materials").GetProperty("edgedetectionplane_m");
        if(material.GetProperty("shader").GetString()!="EdgeDetection")throw new InvalidDataException("Unexpected loading-screen material.");
        var values=material.GetProperty("attributes");
        float F(string key)=>values.GetProperty(key).GetSingle();
        Vector4 Color(string key){var a=values.GetProperty(key);return new(a[0].GetSingle(),a[1].GetSingle(),a[2].GetSingle(),1);}
        var scale=values.GetProperty("pScanlineUVScale");
        return new(new(F("pSobelDistanceScale"),F("pSobelEdgeThickness"),F("pSobelMaxDistance"),F("pSobelPower")),
            Color("pSobelTintHigh"),Color("pSobelTintLow"),new(scale[0].GetSingle(),scale[1].GetSingle()),root.GetProperty("sourceSha256").GetString()!);
    }
}