diff --git a/ReleaseConsumerProject/Packages/manifest.json b/ReleaseConsumerProject/Packages/manifest.json index 75303f4..c80d56b 100644 --- a/ReleaseConsumerProject/Packages/manifest.json +++ b/ReleaseConsumerProject/Packages/manifest.json @@ -8,7 +8,7 @@ "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-source-v1.0.3-r2", "org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1", "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.1.0", - "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.1.3", + "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.1.4", "org.gamecult.eve.unity-uitoolkit": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0" }, "testables": [ diff --git a/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveFieldsUnitySceneProjectionTests.cs b/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveFieldsUnitySceneProjectionTests.cs index 07fc4f6..f3e130f 100644 --- a/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveFieldsUnitySceneProjectionTests.cs +++ b/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveFieldsUnitySceneProjectionTests.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using System.Collections.Generic; using GameCult.Eve.PluginFields; using GameCult.Eve.UnityScene.Fields; using NUnit.Framework; @@ -37,5 +38,75 @@ namespace GameCult.Eve.UnityScene.Tests Assert.That(render.GetParameters()[0].ParameterType, Is.EqualTo(typeof(IEveFieldsSplatsDocument))); Assert.That(typeof(EveFieldsSplatLayerRenderer).GetField("GlobalTextureName"), Is.Null); } + + [Test] + public void RasterizerProducesProviderIndependentFieldsCapture() + { + var host = new GameObject("eve-fields-capture"); + var rasterizer = host.AddComponent(); + var output = rasterizer.Render(new CaptureDocument(), 64, 64); + Assert.That(output, Is.Not.Null); + + var previous = RenderTexture.active; + RenderTexture.active = output; + var readback = new Texture2D(64, 64, TextureFormat.RGBAFloat, false, true); + readback.ReadPixels(new Rect(0, 0, 64, 64), 0, 0); + readback.Apply(); + RenderTexture.active = previous; + Assert.That(readback.GetPixels().Any(pixel => pixel.r > 0.01f), Is.True); + + var outputPath = Path.GetFullPath(Path.Combine(Application.dataPath, "../../artifacts/fields-surface/latest/unity-fields.png")); + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); + File.WriteAllBytes(outputPath, readback.EncodeToPNG()); + UnityEngine.Object.DestroyImmediate(readback); + UnityEngine.Object.DestroyImmediate(host); + } + + private sealed class CaptureDocument : IEveFieldsSplatsDocument + { + public string Schema => EveFieldsSchemas.Splats; + public long FrameId => 1; + public double SimulationTimeSeconds => 0; + public IEveFieldsViewport Viewport { get; } = new CaptureViewport(); + public IReadOnlyList Layers { get; } = Array.Empty(); + public IEveFieldsSplatSoa Splats { get; } = new CaptureSplats(); + } + + private sealed class CaptureViewport : IEveFieldsViewport + { + public double MinX => -1; + public double MinY => -1; + public double MaxX => 1; + public double MaxY => 1; + } + + private sealed class CaptureSplats : IEveFieldsSplatSoa + { + private static readonly double[] One = { 1d }; + private static readonly double[] Zero = { 0d }; + private static readonly int[] ZeroInt = { 0 }; + public int Count => 1; + public IReadOnlyList CenterX => Zero; + public IReadOnlyList CenterY => Zero; + public IReadOnlyList HalfExtentX => One; + public IReadOnlyList HalfExtentY => One; + public IReadOnlyList RotationCos => One; + public IReadOnlyList RotationSin => Zero; + public IReadOnlyList Channel => ZeroInt; + public IReadOnlyList Falloff => ZeroInt; + public IReadOnlyList ValueR => One; + public IReadOnlyList ValueG => Zero; + public IReadOnlyList ValueB => Zero; + public IReadOnlyList ValueA => One; + public IReadOnlyList SourceKey { get; } = new[] { "capture" }; + public IReadOnlyList LayerIndex => ZeroInt; + public IReadOnlyList SourceKind => ZeroInt; + public IReadOnlyList FrequencyX => One; + public IReadOnlyList FrequencyY => One; + public IReadOnlyList PhaseX => Zero; + public IReadOnlyList PhaseY => Zero; + public IReadOnlyList AnimationSpeed => Zero; + public IReadOnlyList SourceFlags => Zero; + } } } diff --git a/packages/org.gamecult.eve.unity-scene/eve-runtime-capability.json b/packages/org.gamecult.eve.unity-scene/eve-runtime-capability.json index 55177a9..9243e56 100644 --- a/packages/org.gamecult.eve.unity-scene/eve-runtime-capability.json +++ b/packages/org.gamecult.eve.unity-scene/eve-runtime-capability.json @@ -45,7 +45,13 @@ "field.surface2d", "gravity.surface" ], - "projectionAdapter": "EveFieldsSplatRasterizer" + "projectionAdapter": "EveFieldsSplatRasterizer", + "evidencePaths": [ + "Runtime/Fields/EveFieldsSplatRasterizer.cs", + "Runtime/Fields/EveFieldsSplatLayerRenderer.cs", + "Tests/Editor/EveFieldsUnitySceneProjectionTests.cs", + "artifacts/fields-surface/latest/unity-fields.png" + ] }, { "pluginId": "sai.vn", diff --git a/packages/org.gamecult.eve.unity-scene/package.json b/packages/org.gamecult.eve.unity-scene/package.json index 465da61..723bfe5 100644 --- a/packages/org.gamecult.eve.unity-scene/package.json +++ b/packages/org.gamecult.eve.unity-scene/package.json @@ -1,7 +1,7 @@ { "name": "org.gamecult.eve.unity-scene", "displayName": "Eve Unity Scene Lowering", - "version": "0.1.3", + "version": "0.1.4", "unity": "2021.3", "description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.", "dependencies": {