diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index cd08e0be9..e8d471311 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -220,6 +220,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks new AetheriaRuntimeDaemonHealthDocument(), AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon")); var volume = Flatten(surface.Surface.Root).Single(node => node.Kind == "field.volume3d"); + var stardust = Flatten(surface.Surface.Root).Single(node => node.Kind == "field.particles3d"); var gravityField = Flatten(surface.Surface.Root).Single(node => node.Kind == "field.surface2d"); Require(volume.Props.Values.All(value => value == null || !value.Contains("_Nebula", StringComparison.Ordinal)) && volume.Props["layerBindings"].Contains("fog.surface_height=surfaceHeight", StringComparison.Ordinal) && @@ -229,17 +230,43 @@ internal sealed class AetheriaDaemonYmirSmokeChecks volume.Props["documentFloatBindings"] == "simulationTimeSeconds=flowScroll,0.025,0" && !volume.Props.ContainsKey("vectorParameters"), "portable Eve volume surfaces must name logical ports rather than Unity shader properties"); - Require(gravityField.Props["minX"] == "-1000" && - gravityField.Props["minY"] == "-1000" && - gravityField.Props["maxX"] == "1000" && - gravityField.Props["maxY"] == "1000" && + Require(gravityField.Props["minX"] == "-768" && + gravityField.Props["minY"] == "-768" && + gravityField.Props["maxX"] == "768" && + gravityField.Props["maxY"] == "768" && volume.Props["documentRef"] == gravityField.Props["renderSplatsDocumentId"], - "flight fog rasterization and native sampling must share the fossil 2000-square splat-camera viewport"); + "flight fog rasterization must share the exact 256-by-6 Stardust lattice viewport"); + Require(stardust.Props["documentRef"] == gravityField.Props["renderSplatsDocumentId"] && + stardust.Props["computeProgramAssetRef"] == "compute.environment.stardust" && + stardust.Props["materialAssetRef"] == "material.environment.stardust" && + stardust.Props["span"] == "256" && + stardust.Props["threadGroupSize"] == "128" && + stardust.Props["particleStrideBytes"] == "28" && + stardust.Props["viewportAnchor"] == "active-camera.xz" && + stardust.Props["layerBindings"] == "fog.surface_height=surfaceHeight;fog.tint=tint" && + stardust.Props["cellWorldSize"] == "6" && + stardust.Props["gravityTexelsPerCell"] == "8" && + stardust.Props["viewportSnapLayer"] == "fog.surface_height" && + stardust.Props["viewportSnapTexels"] == "8" && + stardust.Props["documentFloatBindings"] == + "simulationTimeSeconds=time,1,0;simulationTimeSeconds=flowScroll,0.025,0" && + stardust.Props["documentTimeVectorPort"] == "timeVector" && + stardust.Props["floatParameters"].Contains( + "period=2;minimumSize=0.25;maximumSize=0.75;spacing=6;ceilingHeight=0;" + + "floorHeight=-10;minHeadroom=25;maxHeadroom=100;heightExponent=3", + StringComparison.Ordinal), + "portable Stardust semantics must preserve the grid/gravity lattice, dispatch, camera snap, time, and particle values exactly"); var shader = AetheriaRuntimeAssets.ProjectManifest(null).Assets.Single(asset => asset.Ref.AssetKey == "shader.environment.gravity-fog"); var postProcess = AetheriaRuntimeAssets.ProjectManifest(null).Assets.Single(asset => asset.Ref.AssetKey == "profile.environment.flight"); + var stardustCompute = AetheriaRuntimeAssets.ProjectManifest(null).Assets.Single(asset => + asset.Ref.AssetKey == "compute.environment.stardust"); + var stardustMaterial = AetheriaRuntimeAssets.ProjectManifest(null).Assets.Single(asset => + asset.Ref.AssetKey == "material.environment.stardust"); + var stardustColors = AetheriaRuntimeAssets.ProjectManifest(null).Assets.Single(asset => + asset.Ref.AssetKey == "texture.environment.stardust-colors"); Require(postProcess.Ref.Kind == AetheriaRuntimeAssetKinds.VolumeProfile && postProcess.Ref.Metadata["presentationRole"] == "environment.post-process.flight", "provider asset catalog must carry the advertised flight post-process profile variant"); @@ -253,6 +280,18 @@ internal sealed class AetheriaDaemonYmirSmokeChecks shader.Ref.Metadata["unity.volume.matrixPort.previousViewProjection"] == "_PrevVP" && shader.Ref.Metadata["unity.volume.floatPort.resetHistory"] == "_ResetHistory", "provider asset metadata must own the concrete Unity volume-program ABI projected into runtime variants"); + Require(stardustCompute.Ref.Kind == AetheriaRuntimeAssetKinds.ComputeShader && + stardustCompute.Ref.Metadata["unity.particles.kernel.update"] == "UpdateParticles" && + stardustCompute.Ref.Metadata["unity.particles.bufferPort.particles"] == "particles" && + !stardustCompute.Ref.Metadata.ContainsKey("unity.particles.texturePort.patch") && + !stardustCompute.Ref.Metadata.ContainsKey("unity.particles.texturePort.patchHeight") && + stardustCompute.Ref.Metadata["unity.particles.vectorPort.viewportTransform"] == "_GridTransform" && + stardustCompute.Ref.Metadata["unity.particles.vectorPort.timeVector"] == "_Time" && + stardustCompute.Ref.Metadata["unity.particles.intPort.span"] == "span" && + stardustMaterial.Ref.Metadata["unity.particles.bufferPort.particles"] == "particles" && + stardustMaterial.Ref.Metadata["unity.particles.bufferPort.quadPoints"] == "quadPoints" && + stardustColors.Ref.Metadata["unityAssetPath"] == "Assets/Resources/Gradients/blackbody.png", + "provider asset metadata must own the exact Stardust compute/render ABI and authored color ramp"); var fogVolume = Flatten(surface.Surface.Root) .Single(component => string.Equals(component.Kind, "field.volume3d", StringComparison.Ordinal)); Require(fogVolume.Props.TryGetValue("floatParameters", out var fogParameters) && diff --git a/Aetheria.Unity/Packages/manifest.json b/Aetheria.Unity/Packages/manifest.json index fc752a83a..03500e09b 100644 --- a/Aetheria.Unity/Packages/manifest.json +++ b/Aetheria.Unity/Packages/manifest.json @@ -9,6 +9,6 @@ "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.14", "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.2.3", "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.2", - "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.51" + "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.52" } } diff --git a/Aetheria.Unity/Packages/packages-lock.json b/Aetheria.Unity/Packages/packages-lock.json index 3b43240ce..0f30d6365 100644 --- a/Aetheria.Unity/Packages/packages-lock.json +++ b/Aetheria.Unity/Packages/packages-lock.json @@ -144,7 +144,7 @@ "hash": "140e1bd963a0033e66777a3b2c5fe6e9c97dfe32" }, "org.gamecult.eve.unity-scene": { - "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.51", + "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.52", "depth": 0, "source": "git", "dependencies": { @@ -155,7 +155,7 @@ "com.unity.render-pipelines.universal": "17.4.0", "com.unity.modules.particlesystem": "1.0.0" }, - "hash": "21ac39e7bdfca9d81a0b7d89834f7e9da60aaad6" + "hash": "5809a553d815dec6e317c36ea1e762fc6b6b8b29" }, "com.unity.modules.assetbundle": { "version": "1.0.0", diff --git a/Assets/Editor/AetheriaStardustContinuityVerifier.cs b/Assets/Editor/AetheriaStardustContinuityVerifier.cs new file mode 100644 index 000000000..52fce46c0 --- /dev/null +++ b/Assets/Editor/AetheriaStardustContinuityVerifier.cs @@ -0,0 +1,156 @@ +using System; +using System.Runtime.InteropServices; +using UnityEngine; + +namespace Aetheria.Editor +{ + internal static class AetheriaStardustContinuityVerifier + { + private const int Span = 16; + private const int GroupSize = 128; + private const float Spacing = 6f; + + [StructLayout(LayoutKind.Sequential)] + private struct Particle + { + public Vector3 Position; + public Vector3 Color; + public float Size; + } + + internal static void VerifyOneCellShift(ComputeShader program) + { + if (program == null) throw new ArgumentNullException(nameof(program)); + if (!SystemInfo.supportsComputeShaders) + throw new InvalidOperationException("Stardust continuity proof requires compute-shader support."); + + var kernel = program.FindKernel("UpdateParticles"); + using var particles = new ComputeBuffer(Span * Span, 7 * sizeof(float), ComputeBufferType.Structured); + var field = ConstantTexture(new Color(0.5f, 0.5f, 0.5f, 1f)); + var tint = ConstantTexture(Color.white); + var hue = ConstantTexture(Color.white); + try + { + program.EnableKeyword("FLOW_GLOBAL"); + program.EnableKeyword("NOISE_SLOPE"); + program.SetBuffer(kernel, "particles", particles); + program.SetTexture(kernel, "_NebulaSurfaceHeight", field); + program.SetTexture(kernel, "_NebulaTint", tint); + program.SetTexture(kernel, "HueTexture", hue); + program.SetVector("_NebulaSurfaceHeight_TexelSize", new Vector4(0.25f, 0.25f, 4f, 4f)); + program.SetVector("_NebulaTint_TexelSize", new Vector4(0.25f, 0.25f, 4f, 4f)); + program.SetVector("_Time", new Vector4(0.625f, 12.5f, 25f, 37.5f)); + program.SetFloat("time", 12.5f); + program.SetFloat("period", 2f); + program.SetFloat("spacing", Spacing); + program.SetFloat("ceilingHeight", 0f); + program.SetFloat("floorHeight", -10f); + program.SetFloat("heightExponent", 3f); + program.SetFloat("maximumSize", 0.75f); + program.SetFloat("minimumSize", 0.25f); + program.SetFloat("minHeadroom", 25f); + program.SetFloat("maxHeadroom", 100f); + program.SetFloat("_FlowScale", 512f); + program.SetFloat("_FlowAmplitude", 15f); + program.SetFloat("_FlowScroll", 0.3125f); + program.SetFloat("_DynamicLodHigh", 7f); + program.SetFloat("_DynamicLodLow", 2f); + program.SetInt("span", Span); + + var before = DispatchAndRead(program, kernel, particles, 0f, 0f); + AssertWholeBlockRemapIsInvisible( + before, + DispatchAndRead(program, kernel, particles, Spacing, 0f), + 1, + 0); + AssertWholeBlockRemapIsInvisible( + before, + DispatchAndRead(program, kernel, particles, 0f, Spacing), + 0, + 1); + AssertWholeBlockRemapIsInvisible( + before, + DispatchAndRead(program, kernel, particles, Spacing, Spacing), + 1, + 1); + Debug.Log("Aetheria Stardust continuity: 705 overlapping world cells remained bit-identical " + + "across X, Y, and diagonal whole-buffer remaps."); + } + finally + { + UnityEngine.Object.DestroyImmediate(field); + UnityEngine.Object.DestroyImmediate(tint); + UnityEngine.Object.DestroyImmediate(hue); + } + } + + private static Particle[] DispatchAndRead( + ComputeShader program, + int kernel, + ComputeBuffer particles, + float gridCenterX, + float gridCenterY) + { + program.SetVector("_GridTransform", new Vector4(gridCenterX, gridCenterY, 1536f, 1536f)); + program.Dispatch(kernel, Mathf.CeilToInt((float)(Span * Span) / GroupSize), 1, 1); + var result = new Particle[Span * Span]; + particles.GetData(result); + return result; + } + + private static void AssertWholeBlockRemapIsInvisible( + Particle[] before, + Particle[] after, + int cellDeltaX, + int cellDeltaY) + { + var half = Span / 2; + var sameSlot = half * Span + half; + if (BitwiseEqual(before[sameSlot], after[sameSlot])) + throw new InvalidOperationException( + "Stardust continuity fixture did not reassign the sampled buffer slot to a new world cell."); + + var minimumWorldX = Math.Max(-half, -half + cellDeltaX); + var maximumWorldX = Math.Min(half - 1, half - 1 + cellDeltaX); + var minimumWorldY = Math.Max(-half, -half + cellDeltaY); + var maximumWorldY = Math.Min(half - 1, half - 1 + cellDeltaY); + for (var worldY = minimumWorldY; worldY <= maximumWorldY; worldY++) + for (var worldX = minimumWorldX; worldX <= maximumWorldX; worldX++) + { + var beforeIndex = (worldY + half) * Span + worldX + half; + var afterIndex = (worldY - cellDeltaY + half) * Span + + (worldX - cellDeltaX) + half; + if (!BitwiseEqual(before[beforeIndex], after[afterIndex])) + throw new InvalidOperationException( + $"Stardust cell ({worldX},{worldY}) changed while crossing one spatial cell; " + + $"buffer slots {beforeIndex} and {afterIndex} must describe the same stateless particle."); + } + } + + private static bool BitwiseEqual(Particle left, Particle right) => + Bits(left.Position.x) == Bits(right.Position.x) && + Bits(left.Position.y) == Bits(right.Position.y) && + Bits(left.Position.z) == Bits(right.Position.z) && + Bits(left.Color.x) == Bits(right.Color.x) && + Bits(left.Color.y) == Bits(right.Color.y) && + Bits(left.Color.z) == Bits(right.Color.z) && + Bits(left.Size) == Bits(right.Size); + + private static int Bits(float value) => BitConverter.SingleToInt32Bits(value); + + private static Texture2D ConstantTexture(Color color) + { + var texture = new Texture2D(4, 4, TextureFormat.RGBA32, false, true) + { + filterMode = FilterMode.Bilinear, + wrapMode = TextureWrapMode.Clamp, + hideFlags = HideFlags.HideAndDontSave + }; + var pixels = new Color[16]; + for (var index = 0; index < pixels.Length; index++) pixels[index] = color; + texture.SetPixels(pixels); + texture.Apply(false, false); + return texture; + } + } +} diff --git a/Assets/Editor/AetheriaStardustContinuityVerifier.cs.meta b/Assets/Editor/AetheriaStardustContinuityVerifier.cs.meta new file mode 100644 index 000000000..21a5599b7 --- /dev/null +++ b/Assets/Editor/AetheriaStardustContinuityVerifier.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0389390ce7724a84192e606a4cda9047 \ No newline at end of file diff --git a/Assets/Editor/EveAssetBundleBuilder.cs b/Assets/Editor/EveAssetBundleBuilder.cs index 42c3f21b9..651bbd651 100644 --- a/Assets/Editor/EveAssetBundleBuilder.cs +++ b/Assets/Editor/EveAssetBundleBuilder.cs @@ -583,6 +583,19 @@ namespace Aetheria.Editor var dither = LoadAuthoredAsset(bundle, assetNames, "Assets/Resources/LDR_LLL1_0.png"); if (dither == null) throw new InvalidOperationException("Aetheria Eve bundle has no pre-generated volume dither texture."); + var stardustCompute = LoadAuthoredAsset(bundle, assetNames, + "Assets/Shaders/Compute/Stardust/Stardust.compute"); + if (stardustCompute == null || !stardustCompute.HasKernel("UpdateParticles")) + throw new InvalidOperationException("Aetheria Eve bundle has no supported Stardust update program."); + var stardustMaterial = LoadAuthoredAsset(bundle, assetNames, + "Assets/Shaders/Compute/Stardust/Stardust.mat"); + if (stardustMaterial == null || stardustMaterial.shader == null || !stardustMaterial.shader.isSupported) + throw new InvalidOperationException("Aetheria Eve bundle has no supported Stardust render material."); + var stardustColors = LoadAuthoredAsset(bundle, assetNames, + "Assets/Resources/Gradients/blackbody.png"); + if (stardustColors == null) + throw new InvalidOperationException("Aetheria Eve bundle has no pre-generated Stardust color texture."); + AetheriaStardustContinuityVerifier.VerifyOneCellShift(stardustCompute); } finally { diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssetDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssetDocuments.cs index bec849cf7..24e7611b6 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssetDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssetDocuments.cs @@ -14,6 +14,7 @@ namespace GameCult.Aetheria.State.Verse public const string Mesh = "mesh"; public const string Material = "material"; public const string Shader = "shader"; + public const string ComputeShader = "compute-shader"; public const string Audio = "audio"; public const string Prefab = "prefab"; public const string VolumeProfile = "unity.volume-profile"; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssets.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssets.cs index 409c25d9a..6bbe6b6c6 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssets.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeAssets.cs @@ -30,6 +30,9 @@ namespace GameCult.Aetheria.State.Verse Add(entries, EnvironmentPostProcessProfile()); Add(entries, EnvironmentGravityFogShader()); Add(entries, EnvironmentDitherTexture()); + Add(entries, EnvironmentStardustComputeShader()); + Add(entries, EnvironmentStardustMaterial()); + Add(entries, EnvironmentStardustColorTexture()); Add(entries, MapIcon("entity.player", "Player", "Sprites/Icons/Stroked/Ship")); Add(entries, MapIcon("entity.ship", "Ship", "Sprites/Icons/Stroked/Ship")); Add(entries, MapIcon("entity.orbital", "Orbital", "Sprites/Icons/Stroked/orbital")); @@ -312,6 +315,114 @@ namespace GameCult.Aetheria.State.Verse }; } + public static AetheriaRuntimeAssetManifestEntry EnvironmentStardustComputeShader() + { + return new AetheriaRuntimeAssetManifestEntry + { + Ref = new AetheriaRuntimeAssetRef + { + AssetKey = "compute.environment.stardust", + Kind = AetheriaRuntimeAssetKinds.ComputeShader, + Uri = CultMeshAssetUri("compute.environment.stardust"), + MimeType = "application/vnd.unity.compute-shader", + Metadata = new Dictionary(StringComparer.Ordinal) + { + ["unityAssetPath"] = "Assets/Shaders/Compute/Stardust/Stardust.compute", + ["presentationRole"] = "environment.stardust.update", + ["unity.particles.kernel.update"] = "UpdateParticles", + ["unity.particles.feature.flow.global.keyword"] = "FLOW_GLOBAL", + ["unity.particles.feature.noise.slope.keyword"] = "NOISE_SLOPE", + ["unity.particles.texturePort.surfaceHeight"] = "_NebulaSurfaceHeight", + ["unity.particles.texturePort.tint"] = "_NebulaTint", + ["unity.particles.texturePort.hue"] = "HueTexture", + ["unity.particles.bufferPort.particles"] = "particles", + ["unity.particles.vectorPort.viewportTransform"] = "_GridTransform", + ["unity.particles.vectorPort.timeVector"] = "_Time", + ["unity.particles.floatPort.time"] = "time", + ["unity.particles.floatPort.period"] = "period", + ["unity.particles.floatPort.spacing"] = "spacing", + ["unity.particles.floatPort.ceilingHeight"] = "ceilingHeight", + ["unity.particles.floatPort.floorHeight"] = "floorHeight", + ["unity.particles.floatPort.maximumSize"] = "maximumSize", + ["unity.particles.floatPort.minimumSize"] = "minimumSize", + ["unity.particles.floatPort.minHeadroom"] = "minHeadroom", + ["unity.particles.floatPort.maxHeadroom"] = "maxHeadroom", + ["unity.particles.floatPort.heightExponent"] = "heightExponent", + ["unity.particles.intPort.span"] = "span", + ["unity.particles.floatPort.fillDensity"] = "_NebulaFillDensity", + ["unity.particles.floatPort.fillDistance"] = "_NebulaFillDistance", + ["unity.particles.floatPort.fillExponent"] = "_NebulaFillExponent", + ["unity.particles.floatPort.fillOffset"] = "_NebulaFillOffset", + ["unity.particles.floatPort.patchDensity"] = "_NebulaPatchDensity", + ["unity.particles.floatPort.floorOffset"] = "_NebulaFloorOffset", + ["unity.particles.floatPort.floorBlend"] = "_NebulaFloorBlend", + ["unity.particles.floatPort.patchBlend"] = "_NebulaPatchBlend", + ["unity.particles.floatPort.luminance"] = "_NebulaLuminance", + ["unity.particles.floatPort.tintLodExponent"] = "_TintLodExponent", + ["unity.particles.floatPort.flowScale"] = "_FlowScale", + ["unity.particles.floatPort.flowAmplitude"] = "_FlowAmplitude", + ["unity.particles.floatPort.flowScroll"] = "_FlowScroll", + ["unity.particles.floatPort.flowPeriod"] = "_FlowPeriod", + ["unity.particles.floatPort.flowSlopeAmplitude"] = "_FlowSlopeAmplitude", + ["unity.particles.floatPort.flowSwirlAmplitude"] = "_FlowSwirlAmplitude", + ["unity.particles.floatPort.noiseScale"] = "_NebulaNoiseScale", + ["unity.particles.floatPort.noiseAmplitude"] = "_NebulaNoiseAmplitude", + ["unity.particles.floatPort.noiseExponent"] = "_NebulaNoiseExponent", + ["unity.particles.floatPort.noiseSpeed"] = "_NebulaNoiseSpeed", + ["unity.particles.floatPort.noiseSlopeExponent"] = "_NebulaNoiseSlopeExponent", + ["unity.particles.floatPort.dynamicSkyBoost"] = "_DynamicSkyBoost", + ["unity.particles.floatPort.dynamicLodHigh"] = "_DynamicLodHigh", + ["unity.particles.floatPort.dynamicLodLow"] = "_DynamicLodLow", + ["unity.particles.floatPort.dynamicIntensity"] = "_DynamicIntensity" + } + }, + Tags = new[] { "presentation", "environment", "stardust", "particles", "compute" } + }; + } + + public static AetheriaRuntimeAssetManifestEntry EnvironmentStardustMaterial() + { + return new AetheriaRuntimeAssetManifestEntry + { + Ref = new AetheriaRuntimeAssetRef + { + AssetKey = "material.environment.stardust", + Kind = AetheriaRuntimeAssetKinds.Material, + Uri = CultMeshAssetUri("material.environment.stardust"), + MimeType = "application/vnd.unity.material", + Metadata = new Dictionary(StringComparer.Ordinal) + { + ["unityAssetPath"] = "Assets/Shaders/Compute/Stardust/Stardust.mat", + ["presentationRole"] = "environment.stardust.render", + ["unity.particles.pass.render"] = "0", + ["unity.particles.bufferPort.particles"] = "particles", + ["unity.particles.bufferPort.quadPoints"] = "quadPoints" + } + }, + Tags = new[] { "presentation", "environment", "stardust", "particles", "material" } + }; + } + + public static AetheriaRuntimeAssetManifestEntry EnvironmentStardustColorTexture() + { + return new AetheriaRuntimeAssetManifestEntry + { + Ref = new AetheriaRuntimeAssetRef + { + AssetKey = "texture.environment.stardust-colors", + Kind = AetheriaRuntimeAssetKinds.Texture, + Uri = CultMeshAssetUri("texture.environment.stardust-colors"), + MimeType = "image/png", + Metadata = new Dictionary(StringComparer.Ordinal) + { + ["unityAssetPath"] = "Assets/Resources/Gradients/blackbody.png", + ["presentationRole"] = "environment.stardust.colors" + } + }, + Tags = new[] { "presentation", "environment", "stardust", "pre-generated" } + }; + } + public static AetheriaRuntimeAssetManifestEntry EnvironmentDitherTexture() { return new AetheriaRuntimeAssetManifestEntry diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs index 177d470b5..f6372983c 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs @@ -659,6 +659,7 @@ namespace GameCult.Aetheria.State.Verse if (aimPresentation != null) presentationChildren.Insert(0, aimPresentation); presentationChildren.Insert(0, GravityFogVolume("aetheria.daemon.game.world.gravity-fog")); + presentationChildren.Insert(1, StardustParticles("aetheria.daemon.game.world.stardust")); return new AetheriaRuntimeSurfaceComponent( id, @@ -720,6 +721,53 @@ namespace GameCult.Aetheria.State.Verse AetheriaRuntimeSurfaceStateBindings.FromProps(props)); } + private static AetheriaRuntimeSurfaceComponent StardustParticles(string id) + { + var viewport = DefaultViewport(); + var props = new Dictionary(StringComparer.Ordinal) + { + ["label"] = "Gravity-field stardust", + ["documentRef"] = ViewportDocumentId("aetheria.viewport.render_splats", viewport), + ["documentSchema"] = AetheriaRuntimeDaemonSchemas.RenderSplatsViewport, + ["computeProgramAssetRef"] = "compute.environment.stardust", + ["materialAssetRef"] = "material.environment.stardust", + ["renderChannel"] = "world.transparent", + ["features"] = "flow.global;noise.slope", + ["span"] = "256", + ["threadGroupSize"] = "128", + ["particleStrideBytes"] = "28", + ["textureWidth"] = "1024", + ["textureHeight"] = "1024", + ["layerBindings"] = "fog.surface_height=surfaceHeight;fog.tint=tint", + ["layerTargetDescriptors"] = "fog.surface_height=2,2,false,bilinear;" + + "fog.tint=0.5,0.5,true,trilinear", + ["assetTextureBindings"] = "texture.environment.stardust-colors=hue", + ["viewportAnchor"] = "active-camera.xz", + ["cellWorldSize"] = "6", + ["gravityTexelsPerCell"] = "8", + ["viewportSnapLayer"] = "fog.surface_height", + ["viewportSnapTexels"] = "8", + ["documentFloatBindings"] = "simulationTimeSeconds=time,1,0;" + + "simulationTimeSeconds=flowScroll,0.025,0", + ["documentTimeVectorPort"] = "timeVector", + ["floatParameters"] = "period=2;minimumSize=0.25;maximumSize=0.75;spacing=6;" + + "ceilingHeight=0;floorHeight=-10;minHeadroom=25;maxHeadroom=100;heightExponent=3;" + + "fillDensity=0.000000001;fillDistance=120;fillExponent=5;fillOffset=70;" + + "patchDensity=0.35;floorOffset=-20;floorBlend=10;patchBlend=25;luminance=1;" + + "tintLodExponent=-0.45;flowScale=512;flowAmplitude=15;flowPeriod=8;" + + "flowSlopeAmplitude=0;flowSwirlAmplitude=0;noiseScale=414.2167;" + + "noiseAmplitude=-36.17;noiseExponent=-0.25;noiseSpeed=0.0025;" + + "noiseSlopeExponent=0.15;dynamicSkyBoost=2;dynamicLodHigh=7;" + + "dynamicLodLow=2;dynamicIntensity=0.5" + }; + return new AetheriaRuntimeSurfaceComponent( + id, + "field.particles3d", + props, + Array.Empty(), + AetheriaRuntimeSurfaceStateBindings.FromProps(props)); + } + private static AetheriaRuntimeSurfaceComponent? AimPresentation( AetheriaRuntimeRunCheckpointCommit run, AetheriaRuntimeZoneSnapshotCommit zone, @@ -1268,15 +1316,16 @@ namespace GameCult.Aetheria.State.Verse private static AetheriaRuntimeViewportBounds DefaultViewport() { - // The canonical flight scene renders every splat layer through an - // orthographic-size-1000 camera. The 3000-unit Zone Brushes mesh is - // deliberately oversized and is brush data, not the sampling viewport. + // Stardust owns a 256-cell camera-relative lattice at six world units + // per cell. Gravity is rasterized at eight texels per Stardust cell, + // so the 1536-square viewport maps exactly to the 2048-square surface + // target without either lattice crawling under the other. return new AetheriaRuntimeViewportBounds { - MinX = -1000, - MinY = -1000, - MaxX = 1000, - MaxY = 1000 + MinX = -768, + MinY = -768, + MaxX = 768, + MaxY = 768 }; } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index ed1fcb285..91c35e721 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -975,6 +975,55 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. material using `Universal Render Pipeline/Unlit`; visual inspection shows ship hulls instead of opaque shield ellipsoids and readable map glyphs. +### Stardust Field-Particle Contract + +- Owner: Aetheria owns the authored Stardust program, its exact scalar values, + its color ramp, and the choice to visualize the gravity-fog field with + stateless camera-relative particles. EveUnity owns only generic program + binding, compute dispatch, and procedural drawing. +- Inputs: the same typed `gamecult.eve.fields.splats.v1` document used by the + fog volume; gravity surface height and gravity-derived tint (not patch or + patch-height layers); the provider compute shader, material, and blackbody + color texture; active camera XZ; and daemon simulation time. +- Outputs: `field.particles3d` names the provider programs, logical field and + asset ports, the 256-by-256 row-major particle grid, 128-thread dispatch, + 28-byte particle stride, exact fossil values, and camera-followed viewport + policy. +- Hash invariant: no client CPU particle state exists. The provider compute + program retains `id % span`, `id / span`, truncation toward zero, the `65535` + unsigned cell offset, Wang/xorshift sequence, Perlin jitter, lifetime phase, + and float32 evaluation. Changing any of these creates a different field. + Buffer slots are not particle identities: after a one-cell X move, + `before[localX + 1, localY]` and `after[localX, localY]` must be the same + world-cell particle bit for bit. Every slot is reassigned while all + overlapping world particles remain visually motionless. +- Viewport invariant: the particle grid and sampled gravity textures use one + transform and one integer lattice. The 256-by-256 particle grid at six world + units per cell owns a 1536-square viewport. The 2048-square surface-height + target is therefore 0.75 world units per texel and exactly eight gravity + texels per Stardust cell; the 512-square tint target is exactly two texels per + cell. Camera XZ snaps by one six-unit Stardust cell/eight gravity pixels using + truncation toward zero. The snapped center becomes both the raster viewport + center and `_GridTransform.xy`. A 2000-wide viewport is rejected because it + aliases the gravity and particle lattices even when particle hashing itself + is correct. +- Derived state: GPU buffers, generated quads, raster targets, keywords, and + draw calls are client presentation state. They cannot feed simulation. +- Forbidden writers: EveUnity cannot reseed, pool, randomly initialize, move, + recolor, or CPU-generate particles. Aetheria cannot publish per-particle rows + or make the field a gameplay body set. +- Cut line: the fossil `Stardust` MonoBehaviour and renderer feature remain only + reference code. Generic clients execute advertised provider programs through + logical ABI metadata; no Aetheria type enters EveUnity. +- Verification layer: daemon smoke locks every authored value and asset ref; + generic package tests lock ABI validation, repeated daemon-time bindings, + truncating camera snap, buffer layout, and dispatch dimensions. Provider + bundle verification dispatches the bundled HLSL and reindexes by world cell; + 705 overlapping cells across X, Y, and diagonal whole-buffer remaps must keep + all seven particle floats bit-identical while the same buffer slot changes + identity. The released witness must record 65,536 particles, one compute + dispatch and one pilot-camera draw while the map camera remains isolated. + ### Gravity Fog Presentation Contract - Owner: Aetheria owns gravity/fog brush placement and values, authored volume diff --git a/scripts/verify-aetheria-unity-client.ps1 b/scripts/verify-aetheria-unity-client.ps1 index a706f84bf..8c251c418 100644 --- a/scripts/verify-aetheria-unity-client.ps1 +++ b/scripts/verify-aetheria-unity-client.ps1 @@ -20,8 +20,8 @@ $expected = @{ "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.2", "140e1bd963a0033e66777a3b2c5fe6e9c97dfe32") "org.gamecult.eve.unity-scene" = @( - "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.51", - "21ac39e7bdfca9d81a0b7d89834f7e9da60aaad6") + "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.52", + "5809a553d815dec6e317c36ea1e762fc6b6b8b29") } foreach ($packageName in $expected.Keys) {