Restore historical gravity fog shader semantics
This commit is contained in:
parent
c4d1dc166e
commit
fec92d5b48
8 changed files with 63 additions and 6 deletions
35
Assets/Editor/AetheriaGravityFogVerifier.cs
Normal file
35
Assets/Editor/AetheriaGravityFogVerifier.cs
Normal 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue