Restore historical gravity fog shader semantics

This commit is contained in:
Meta Vens 2026-07-16 19:33:35 +01:00
commit fec92d5b48
8 changed files with 63 additions and 6 deletions

View file

@ -0,0 +1,35 @@
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Aetheria.Editor
{
internal static class AetheriaGravityFogVerifier
{
internal static void VerifyCameraProjection(Shader shader, bool requireAuthoredSource)
{
if (shader == null)
throw new ArgumentNullException(nameof(shader));
var shaderPath = AssetDatabase.GetAssetPath(shader);
var source = string.IsNullOrWhiteSpace(shaderPath) || !File.Exists(shaderPath)
? ""
: File.ReadAllText(shaderPath);
if (string.IsNullOrWhiteSpace(source))
{
if (requireAuthoredSource)
throw new InvalidOperationException("Gravity-fog authored shader source is unavailable for verification.");
return;
}
const string forwardRay = "float3(i.vsray, 1.0)";
var first = source.IndexOf(forwardRay, StringComparison.Ordinal);
var second = first < 0
? -1
: source.IndexOf(forwardRay, first + forwardRay.Length, StringComparison.Ordinal);
if (second < 0)
throw new InvalidOperationException(
"Gravity-fog raymarching and temporal reprojection must both use the historical positive-Z Unity shader camera transform.");
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f3c24b224fdb4ec4a5bc071e0bd4bcf4

View file

@ -58,6 +58,11 @@ namespace Aetheria.Editor
AetheriaStardustContinuityVerifier.VerifyTemporalDitherMaterial(
authoredStardustMaterial,
requireAuthoredSource: true);
var authoredGravityFogShader = AssetDatabase.LoadAssetAtPath<Shader>(
"Assets/Shaders/Raymarching/CloudShader.shader");
AetheriaGravityFogVerifier.VerifyCameraProjection(
authoredGravityFogShader,
requireAuthoredSource: true);
var manifest = BuildPipeline.BuildAssetBundles(
output,
@ -616,6 +621,9 @@ namespace Aetheria.Editor
var gravityFog = LoadAuthoredAsset<Shader>(bundle, assetNames, "Assets/Shaders/Raymarching/CloudShader.shader");
if (gravityFog == null || !gravityFog.isSupported)
throw new InvalidOperationException("Aetheria Eve bundle has no supported gravity-fog volume shader.");
AetheriaGravityFogVerifier.VerifyCameraProjection(
gravityFog,
requireAuthoredSource: false);
var dither = LoadAuthoredAsset<Texture2D>(bundle, assetNames, "Assets/Resources/LDR_LLL1_0.png");
if (dither == null)
throw new InvalidOperationException("Aetheria Eve bundle has no pre-generated volume dither texture.");