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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Editor/AetheriaGravityFogVerifier.cs.meta
Normal file
2
Assets/Editor/AetheriaGravityFogVerifier.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f3c24b224fdb4ec4a5bc071e0bd4bcf4
|
||||
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ Shader "Aetheria/CloudShader"
|
|||
float density = c.a;
|
||||
if (density <= 0.0f)
|
||||
{
|
||||
result.intTransmittance = 0;
|
||||
return;
|
||||
}
|
||||
float extinction = _ExtinctionCoefficient * density / (1-fade);
|
||||
|
|
@ -102,7 +103,7 @@ Shader "Aetheria/CloudShader"
|
|||
float clampedExtinction = max(extinction, 1e-7);
|
||||
float transmittance = exp(-extinction * stepsize);
|
||||
|
||||
float3 luminance = c.rgb * _NebulaLuminance * density;
|
||||
float3 luminance = c.rgb * _NebulaLuminance;
|
||||
float3 integScatt = (luminance - luminance * transmittance) / clampedExtinction;
|
||||
float depthWeight = result.intTransmittance * (1-transmittance); //Is it a better idea to use (1-transmittance) * intTransmittance as depth weight?
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue