Restore Stardust temporal coverage

This commit is contained in:
Meta Vens 2026-07-16 18:16:39 +01:00
commit d8a01339cc
10 changed files with 92 additions and 17 deletions

View file

@ -1,5 +1,7 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using UnityEditor;
using UnityEngine;
namespace Aetheria.Editor
@ -18,6 +20,39 @@ namespace Aetheria.Editor
public float Size;
}
internal static void VerifyTemporalDitherMaterial(Material material, bool requireAuthoredSource)
{
if (material == null || material.shader == null)
throw new ArgumentNullException(nameof(material));
if (!material.HasProperty("_DitheringTex"))
throw new InvalidOperationException("Stardust render material has no temporal dither texture port.");
var shaderPath = AssetDatabase.GetAssetPath(material.shader);
var source = string.IsNullOrWhiteSpace(shaderPath) || !File.Exists(shaderPath)
? ""
: File.ReadAllText(shaderPath);
if (string.IsNullOrWhiteSpace(source))
{
if (requireAuthoredSource)
throw new InvalidOperationException("Stardust authored shader source is unavailable for verification.");
return;
}
var required = new[]
{
"_FrameNumber",
"SAMPLE_TEXTURE2D",
"clip(alpha - dither",
"Blend One Zero",
"ZWrite On"
};
foreach (var token in required)
if (!source.Contains(token, StringComparison.Ordinal))
throw new InvalidOperationException(
$"Stardust render shader lost required temporal coverage token '{token}'.");
if (source.Contains("_AlphaClip", StringComparison.Ordinal))
throw new InvalidOperationException(
"Stardust render shader regressed to a fixed alpha threshold instead of temporal coverage.");
}
internal static void VerifyOneCellShift(ComputeShader program)
{
if (program == null) throw new ArgumentNullException(nameof(program));