From 005795a9ef93b49f4d51b7eac620e7fa92b4064c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 16 Jul 2026 13:04:37 +0100 Subject: [PATCH] Serialize provider post-process profiles --- Assets/Editor/EveAssetBundleBuilder.cs | 34 +++++++++++++++++-- .../Editor/EveEnvironmentProfileMigrator.cs | 14 ++++---- Assets/Editor/EveThermalProfileMigrator.cs | 16 ++++----- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/Assets/Editor/EveAssetBundleBuilder.cs b/Assets/Editor/EveAssetBundleBuilder.cs index 651bbd651..9d38f15ee 100644 --- a/Assets/Editor/EveAssetBundleBuilder.cs +++ b/Assets/Editor/EveAssetBundleBuilder.cs @@ -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(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(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(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."); + } } } diff --git a/Assets/Editor/EveEnvironmentProfileMigrator.cs b/Assets/Editor/EveEnvironmentProfileMigrator.cs index 7b50e896b..f69e8963a 100644 --- a/Assets/Editor/EveEnvironmentProfileMigrator.cs +++ b/Assets/Editor/EveEnvironmentProfileMigrator.cs @@ -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(); + var profile = VolumeProfileFactory.CreateVolumeProfileAtPath(FlightProfilePath); profile.name = "Aetheria Flight"; - AssetDatabase.CreateAsset(profile, FlightProfilePath); - var tonemapping = profile.Add(true); + var tonemapping = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); tonemapping.mode.Override(TonemappingMode.ACES); - var color = profile.Add(true); + var color = VolumeProfileFactory.CreateVolumeComponent(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(true); + var bloom = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); bloom.intensity.Override(3f); bloom.threshold.Override(1.5f); bloom.scatter.Override(1f); - var vignette = profile.Add(true); + var vignette = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); vignette.intensity.Override(0.3f); vignette.smoothness.Override(0.4f); - var grain = profile.Add(true); + var grain = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); grain.type.Override(FilmGrainLookup.Thin1); grain.intensity.Override(0.1f); diff --git a/Assets/Editor/EveThermalProfileMigrator.cs b/Assets/Editor/EveThermalProfileMigrator.cs index 8acef4f74..9f74f2c9f 100644 --- a/Assets/Editor/EveThermalProfileMigrator.cs +++ b/Assets/Editor/EveThermalProfileMigrator.cs @@ -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(); - AssetDatabase.CreateAsset(profile, path); + var profile = VolumeProfileFactory.CreateVolumeProfileAtPath(path); - var vignette = profile.Add(true); + var vignette = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); vignette.color.overrideState = overrideVignetteColor; vignette.color.value = vignetteColor; vignette.intensity.Override(vignetteIntensity); vignette.smoothness.Override(vignetteSmoothness); - var color = profile.Add(true); + var color = VolumeProfileFactory.CreateVolumeComponent(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(true); + var balance = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); balance.temperature.Override(temperature); } - var bloom = profile.Add(true); + var bloom = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); bloom.intensity.Override(bloomIntensity); bloom.threshold.Override(1.5f); bloom.scatter.Override(1f); - var grain = profile.Add(true); + var grain = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); grain.type.Override(FilmGrainLookup.Thin1); grain.intensity.Override(grainIntensity); if (depthOfField) { - var focus = profile.Add(true); + var focus = VolumeProfileFactory.CreateVolumeComponent(profile, true, false); focus.mode.Override(DepthOfFieldMode.Bokeh); focus.focusDistance.Override(0.1f); focus.aperture.Override(0.1f);