From b19ac8cc6c6c047a3389bee9ae47d0818ca45288 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 15 Jul 2026 21:15:06 +0100 Subject: [PATCH] Capture volume render stages in live witness --- .../PlayMode/GenericWorldCaptureTests.cs | 33 +++++++++++++++---- .../PlayMode/GenericWorldCaptureTests.cs | 33 +++++++++++++++---- scripts/run-aetheria-daemon-world-witness.ps1 | 2 ++ 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/ReleaseConsumerProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs b/ReleaseConsumerProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs index f39c7ed..75f12a9 100644 --- a/ReleaseConsumerProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs +++ b/ReleaseConsumerProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs @@ -1232,19 +1232,40 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests private static void WriteFieldCloudCapture(GameObject root, string capturePath) { var renderer = root.GetComponent(); - var field = typeof(EveUnityFieldsVolumeRenderer).GetField( - "_cloudTexture", + if (renderer == null || string.IsNullOrWhiteSpace(capturePath)) return; + var raymarchField = typeof(EveUnityFieldsVolumeRenderer).GetField( + "_raymarchTexture", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); - var texture = field?.GetValue(renderer) as RenderTexture; - if (texture == null || string.IsNullOrWhiteSpace(capturePath)) return; + var historyTexturesField = typeof(EveUnityFieldsVolumeRenderer).GetField( + "_historyTextures", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + var historyIndexField = typeof(EveUnityFieldsVolumeRenderer).GetField( + "_historyTextureIndex", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + var raymarchTexture = raymarchField?.GetValue(renderer) as RenderTexture; + var historyTextures = historyTexturesField?.GetValue(renderer) as RenderTexture[]; + var historyIndex = historyIndexField?.GetValue(renderer) is int value ? value : -1; + var previous = RenderTexture.active; + var directory = Path.GetDirectoryName(Path.GetFullPath(capturePath)); + WriteFloatTexture(raymarchTexture, Path.Combine(directory, "field-volume-raymarch.exr")); + var historyTexture = historyIndex >= 0 && historyTextures != null && historyIndex < historyTextures.Length + ? historyTextures[historyIndex] + : null; + WriteFloatTexture(historyTexture, Path.Combine(directory, "field-volume-history.exr")); + WriteFloatTexture(historyTexture ?? raymarchTexture, Path.Combine(directory, "field-volume-cloud.exr")); + RenderTexture.active = previous; + } + + private static void WriteFloatTexture(RenderTexture texture, string path) + { + if (texture == null || string.IsNullOrWhiteSpace(path)) return; var previous = RenderTexture.active; RenderTexture.active = texture; var copy = new Texture2D(texture.width, texture.height, TextureFormat.RGBAFloat, false, true); copy.ReadPixels(new Rect(0, 0, texture.width, texture.height), 0, 0); copy.Apply(); RenderTexture.active = previous; - var directory = Path.GetDirectoryName(Path.GetFullPath(capturePath)); - File.WriteAllBytes(Path.Combine(directory, "field-volume-cloud.exr"), copy.EncodeToEXR()); + File.WriteAllBytes(path, copy.EncodeToEXR()); UnityEngine.Object.DestroyImmediate(copy); } diff --git a/TestProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs b/TestProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs index f39c7ed..75f12a9 100644 --- a/TestProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs +++ b/TestProject/Assets/Tests/PlayMode/GenericWorldCaptureTests.cs @@ -1232,19 +1232,40 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests private static void WriteFieldCloudCapture(GameObject root, string capturePath) { var renderer = root.GetComponent(); - var field = typeof(EveUnityFieldsVolumeRenderer).GetField( - "_cloudTexture", + if (renderer == null || string.IsNullOrWhiteSpace(capturePath)) return; + var raymarchField = typeof(EveUnityFieldsVolumeRenderer).GetField( + "_raymarchTexture", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); - var texture = field?.GetValue(renderer) as RenderTexture; - if (texture == null || string.IsNullOrWhiteSpace(capturePath)) return; + var historyTexturesField = typeof(EveUnityFieldsVolumeRenderer).GetField( + "_historyTextures", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + var historyIndexField = typeof(EveUnityFieldsVolumeRenderer).GetField( + "_historyTextureIndex", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + var raymarchTexture = raymarchField?.GetValue(renderer) as RenderTexture; + var historyTextures = historyTexturesField?.GetValue(renderer) as RenderTexture[]; + var historyIndex = historyIndexField?.GetValue(renderer) is int value ? value : -1; + var previous = RenderTexture.active; + var directory = Path.GetDirectoryName(Path.GetFullPath(capturePath)); + WriteFloatTexture(raymarchTexture, Path.Combine(directory, "field-volume-raymarch.exr")); + var historyTexture = historyIndex >= 0 && historyTextures != null && historyIndex < historyTextures.Length + ? historyTextures[historyIndex] + : null; + WriteFloatTexture(historyTexture, Path.Combine(directory, "field-volume-history.exr")); + WriteFloatTexture(historyTexture ?? raymarchTexture, Path.Combine(directory, "field-volume-cloud.exr")); + RenderTexture.active = previous; + } + + private static void WriteFloatTexture(RenderTexture texture, string path) + { + if (texture == null || string.IsNullOrWhiteSpace(path)) return; var previous = RenderTexture.active; RenderTexture.active = texture; var copy = new Texture2D(texture.width, texture.height, TextureFormat.RGBAFloat, false, true); copy.ReadPixels(new Rect(0, 0, texture.width, texture.height), 0, 0); copy.Apply(); RenderTexture.active = previous; - var directory = Path.GetDirectoryName(Path.GetFullPath(capturePath)); - File.WriteAllBytes(Path.Combine(directory, "field-volume-cloud.exr"), copy.EncodeToEXR()); + File.WriteAllBytes(path, copy.EncodeToEXR()); UnityEngine.Object.DestroyImmediate(copy); } diff --git a/scripts/run-aetheria-daemon-world-witness.ps1 b/scripts/run-aetheria-daemon-world-witness.ps1 index 23f2f5d..750122b 100644 --- a/scripts/run-aetheria-daemon-world-witness.ps1 +++ b/scripts/run-aetheria-daemon-world-witness.ps1 @@ -50,6 +50,8 @@ New-Item -ItemType Directory -Force -Path $outputRoot | Out-Null foreach ($priorArtifact in @($resultsPath, $capturePath, $mapCapturePath, $factsPath, $providerReadyPath, $witnessPath)) { if (Test-Path -LiteralPath $priorArtifact) { Remove-Item -LiteralPath $priorArtifact -Force } } +Get-ChildItem -LiteralPath $outputRoot -Filter "field-*" -File -ErrorAction SilentlyContinue | + Remove-Item -Force if ($CacheState -eq "cold" -and (Test-Path -LiteralPath $assetCachePath)) { Remove-Item -LiteralPath $assetCachePath -Recurse -Force }