Serialize provider post-process profiles
This commit is contained in:
parent
43331e3095
commit
005795a9ef
3 changed files with 47 additions and 17 deletions
|
|
@ -6,6 +6,7 @@ using GameCult.Aetheria.State.Verse;
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Aetheria.Editor
|
||||
{
|
||||
|
|
@ -575,8 +576,7 @@ namespace Aetheria.Editor
|
|||
if (reflection == null)
|
||||
throw new InvalidOperationException("Aetheria Eve bundle has no provider reflection cubemap.");
|
||||
var postProcess = LoadAuthoredAsset<VolumeProfile>(bundle, assetNames, EveEnvironmentProfileMigrator.FlightProfilePath);
|
||||
if (postProcess == null)
|
||||
throw new InvalidOperationException("Aetheria Eve bundle has no provider flight post-process profile.");
|
||||
VerifyFlightPostProcessProfile(postProcess);
|
||||
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.");
|
||||
|
|
@ -610,5 +610,35 @@ namespace Aetheria.Editor
|
|||
string.Equals(path, authoredPath, StringComparison.OrdinalIgnoreCase));
|
||||
return string.IsNullOrWhiteSpace(nativePath) ? null : bundle.LoadAsset<T>(nativePath);
|
||||
}
|
||||
|
||||
private static void VerifyFlightPostProcessProfile(VolumeProfile profile)
|
||||
{
|
||||
if (profile == null)
|
||||
throw new InvalidOperationException("Aetheria Eve bundle has no provider flight post-process profile.");
|
||||
if (!profile.TryGet(out Tonemapping tonemapping) ||
|
||||
!tonemapping.mode.overrideState ||
|
||||
tonemapping.mode.value != TonemappingMode.ACES)
|
||||
throw new InvalidOperationException("Aetheria flight profile has no serialized ACES tonemapping component.");
|
||||
if (!profile.TryGet(out ColorAdjustments color) ||
|
||||
!color.postExposure.overrideState ||
|
||||
!Mathf.Approximately(color.postExposure.value, 2f) ||
|
||||
!color.contrast.overrideState ||
|
||||
!Mathf.Approximately(color.contrast.value, 15f))
|
||||
throw new InvalidOperationException("Aetheria flight profile has no serialized exposure/contrast component.");
|
||||
if (!profile.TryGet(out Bloom bloom) ||
|
||||
!bloom.intensity.overrideState ||
|
||||
!Mathf.Approximately(bloom.intensity.value, 3f) ||
|
||||
!bloom.threshold.overrideState ||
|
||||
!Mathf.Approximately(bloom.threshold.value, 1.5f))
|
||||
throw new InvalidOperationException("Aetheria flight profile has no serialized bloom component.");
|
||||
if (!profile.TryGet(out Vignette vignette) ||
|
||||
!vignette.intensity.overrideState ||
|
||||
!Mathf.Approximately(vignette.intensity.value, 0.3f))
|
||||
throw new InvalidOperationException("Aetheria flight profile has no serialized vignette component.");
|
||||
if (!profile.TryGet(out FilmGrain grain) ||
|
||||
!grain.intensity.overrideState ||
|
||||
!Mathf.Approximately(grain.intensity.value, 0.1f))
|
||||
throw new InvalidOperationException("Aetheria flight profile has no serialized film-grain component.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
|
@ -15,30 +16,29 @@ namespace Aetheria.Editor
|
|||
{
|
||||
Directory.CreateDirectory(Root);
|
||||
AssetDatabase.DeleteAsset(FlightProfilePath);
|
||||
var profile = ScriptableObject.CreateInstance<VolumeProfile>();
|
||||
var profile = VolumeProfileFactory.CreateVolumeProfileAtPath(FlightProfilePath);
|
||||
profile.name = "Aetheria Flight";
|
||||
AssetDatabase.CreateAsset(profile, FlightProfilePath);
|
||||
|
||||
var tonemapping = profile.Add<Tonemapping>(true);
|
||||
var tonemapping = VolumeProfileFactory.CreateVolumeComponent<Tonemapping>(profile, true, false);
|
||||
tonemapping.mode.Override(TonemappingMode.ACES);
|
||||
|
||||
var color = profile.Add<ColorAdjustments>(true);
|
||||
var color = VolumeProfileFactory.CreateVolumeComponent<ColorAdjustments>(profile, true, false);
|
||||
// The fossil histogram exposure clamps average luminance to 2^-3 and
|
||||
// uses a 0.5 middle-grey key. At that dark-scene bound the resulting
|
||||
// exposure is 4x, which is the fixed URP equivalent available here.
|
||||
color.postExposure.Override(2f);
|
||||
color.contrast.Override(15f);
|
||||
|
||||
var bloom = profile.Add<Bloom>(true);
|
||||
var bloom = VolumeProfileFactory.CreateVolumeComponent<Bloom>(profile, true, false);
|
||||
bloom.intensity.Override(3f);
|
||||
bloom.threshold.Override(1.5f);
|
||||
bloom.scatter.Override(1f);
|
||||
|
||||
var vignette = profile.Add<Vignette>(true);
|
||||
var vignette = VolumeProfileFactory.CreateVolumeComponent<Vignette>(profile, true, false);
|
||||
vignette.intensity.Override(0.3f);
|
||||
vignette.smoothness.Override(0.4f);
|
||||
|
||||
var grain = profile.Add<FilmGrain>(true);
|
||||
var grain = VolumeProfileFactory.CreateVolumeComponent<FilmGrain>(profile, true, false);
|
||||
grain.type.Override(FilmGrainLookup.Thin1);
|
||||
grain.intensity.Override(0.1f);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
|
@ -34,38 +35,37 @@ namespace Aetheria.Editor
|
|||
{
|
||||
var path = $"{Root}/{name}.asset";
|
||||
AssetDatabase.DeleteAsset(path);
|
||||
var profile = ScriptableObject.CreateInstance<VolumeProfile>();
|
||||
AssetDatabase.CreateAsset(profile, path);
|
||||
var profile = VolumeProfileFactory.CreateVolumeProfileAtPath(path);
|
||||
|
||||
var vignette = profile.Add<Vignette>(true);
|
||||
var vignette = VolumeProfileFactory.CreateVolumeComponent<Vignette>(profile, true, false);
|
||||
vignette.color.overrideState = overrideVignetteColor;
|
||||
vignette.color.value = vignetteColor;
|
||||
vignette.intensity.Override(vignetteIntensity);
|
||||
vignette.smoothness.Override(vignetteSmoothness);
|
||||
|
||||
var color = profile.Add<ColorAdjustments>(true);
|
||||
var color = VolumeProfileFactory.CreateVolumeComponent<ColorAdjustments>(profile, true, false);
|
||||
color.postExposure.Override(exposure);
|
||||
color.contrast.overrideState = contrast != 0;
|
||||
color.contrast.value = contrast;
|
||||
color.saturation.Override(saturation);
|
||||
if (temperature != 0)
|
||||
{
|
||||
var balance = profile.Add<WhiteBalance>(true);
|
||||
var balance = VolumeProfileFactory.CreateVolumeComponent<WhiteBalance>(profile, true, false);
|
||||
balance.temperature.Override(temperature);
|
||||
}
|
||||
|
||||
var bloom = profile.Add<Bloom>(true);
|
||||
var bloom = VolumeProfileFactory.CreateVolumeComponent<Bloom>(profile, true, false);
|
||||
bloom.intensity.Override(bloomIntensity);
|
||||
bloom.threshold.Override(1.5f);
|
||||
bloom.scatter.Override(1f);
|
||||
|
||||
var grain = profile.Add<FilmGrain>(true);
|
||||
var grain = VolumeProfileFactory.CreateVolumeComponent<FilmGrain>(profile, true, false);
|
||||
grain.type.Override(FilmGrainLookup.Thin1);
|
||||
grain.intensity.Override(grainIntensity);
|
||||
|
||||
if (depthOfField)
|
||||
{
|
||||
var focus = profile.Add<DepthOfField>(true);
|
||||
var focus = VolumeProfileFactory.CreateVolumeComponent<DepthOfField>(profile, true, false);
|
||||
focus.mode.Override(DepthOfFieldMode.Bokeh);
|
||||
focus.focusDistance.Override(0.1f);
|
||||
focus.aperture.Override(0.1f);
|
||||
|
|
|
|||
Loading…
Reference in a new issue