From 03ce78031f28d7bfae4dcdc477a7273c6ecae55b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 15 Jul 2026 23:38:00 +0100 Subject: [PATCH] Lower portable radial cosine fields --- TestProject/Packages/packages-lock.json | 2 +- .../Runtime/Fields/EveFieldsSplatsCore.hlsl | 9 ++++ .../EveFieldsUnitySceneProjectionTests.cs | 48 +++++++++++++++++++ .../org.gamecult.eve.unity-scene/package.json | 4 +- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/TestProject/Packages/packages-lock.json b/TestProject/Packages/packages-lock.json index eb007d8..ea3990d 100644 --- a/TestProject/Packages/packages-lock.json +++ b/TestProject/Packages/packages-lock.json @@ -51,7 +51,7 @@ "source": "local", "dependencies": { "org.gamecult.cultlib": "1.0.13", - "org.gamecult.eve.plugin-fields": "0.2.0", + "org.gamecult.eve.plugin-fields": "0.2.3", "org.gamecult.eve.surface": "0.2.2", "com.unity.mathematics": "1.3.2", "com.unity.modules.particlesystem": "1.0.0" diff --git a/packages/org.gamecult.eve.unity-scene/Runtime/Fields/EveFieldsSplatsCore.hlsl b/packages/org.gamecult.eve.unity-scene/Runtime/Fields/EveFieldsSplatsCore.hlsl index d40dce3..316316d 100644 --- a/packages/org.gamecult.eve.unity-scene/Runtime/Fields/EveFieldsSplatsCore.hlsl +++ b/packages/org.gamecult.eve.unity-scene/Runtime/Fields/EveFieldsSplatsCore.hlsl @@ -176,6 +176,15 @@ float4 Frag(Varyings input) : SV_Target input.fieldWorld * splat.sourceFrequencyPhase.xy + splat.sourceFrequencyPhase.zw, _EveFieldsSimulationTimeSeconds * splat.layerSource.z); } + else if (sourceKind == 4) + { + float distance01 = length(input.localUv); + float radialExponent = max(0.0001, splat.sourceFrequencyPhase.y); + source = cos( + pow(distance01, radialExponent) * splat.sourceFrequencyPhase.x + + splat.sourceFrequencyPhase.z + + _EveFieldsSimulationTimeSeconds * splat.layerSource.z); + } if (((int)round(splat.layerSource.w) & 1) != 0) source = abs(source); return splat.value * (alpha * source * _ValueScale); } 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 32d9451..7be1fc4 100644 --- a/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveFieldsUnitySceneProjectionTests.cs +++ b/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveFieldsUnitySceneProjectionTests.cs @@ -209,6 +209,54 @@ namespace GameCult.Eve.UnityScene.Tests Assert.That(Mathf.Abs(laterValue - firstValue), Is.GreaterThan(0.005f)); } + [Test] + public void RasterizerLowersPortableAnimatedRadialCosine() + { + var initial = RadialCosineDocument(0); + var halfTurnLater = RadialCosineDocument(Math.PI); + + var center = RenderFieldPixel(initial, 64, 64); + var radial = RenderFieldPixel(initial, 80, 64); + var laterCenter = RenderFieldPixel(halfTurnLater, 64, 64); + var localX = (80.5f / 128f) * 2f - 1f; + var localY = (64.5f / 128f) * 2f - 1f; + var expected = Mathf.Cos(Mathf.Pow(Mathf.Sqrt(localX * localX + localY * localY), 1.25f) * Mathf.PI * 2f); + + Assert.That(center, Is.GreaterThan(0.98f)); + Assert.That(radial, Is.EqualTo(expected).Within(0.04f)); + Assert.That(laterCenter, Is.LessThan(-0.98f), + "radial phase animation must use provider-published simulation time"); + } + + private static EveFieldsSplatsDocument RadialCosineDocument(double simulationTime) + { + return new EveFieldsSplatsDocument + { + SimulationTimeSeconds = simulationTime, + Viewport = new EveFieldsViewport { MinX = -1, MinY = -1, MaxX = 1, MaxY = 1 }, + Splats = new EveFieldsSplatSoa + { + Count = 1, + CenterX = new[] { 0d }, + CenterY = new[] { 0d }, + HalfExtentX = new[] { 1d }, + HalfExtentY = new[] { 1d }, + RotationCos = new[] { 1d }, + RotationSin = new[] { 0d }, + Channel = new[] { 0 }, + Falloff = new[] { EveFieldsSplatFalloffs.Solid }, + ValueR = new[] { 1d }, + ValueA = new[] { 1d }, + LayerIndex = new[] { 0 }, + SourceKind = new[] { EveFieldsSplatSourceKinds.AnimatedRadialCosine }, + FrequencyX = new[] { Math.PI * 2d }, + FrequencyY = new[] { 1.25d }, + PhaseX = new[] { 0d }, + AnimationSpeed = new[] { 1d } + } + }; + } + private static EveFieldsSplatsDocument ProceduralDocument( double min, double max, diff --git a/packages/org.gamecult.eve.unity-scene/package.json b/packages/org.gamecult.eve.unity-scene/package.json index 0c48786..4b65aa3 100644 --- a/packages/org.gamecult.eve.unity-scene/package.json +++ b/packages/org.gamecult.eve.unity-scene/package.json @@ -1,12 +1,12 @@ { "name": "org.gamecult.eve.unity-scene", "displayName": "Eve Unity Scene Lowering", - "version": "0.3.43", + "version": "0.3.44", "unity": "2021.3", "description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.", "dependencies": { "org.gamecult.cultlib": "1.0.13", - "org.gamecult.eve.plugin-fields": "0.2.2", + "org.gamecult.eve.plugin-fields": "0.2.3", "org.gamecult.eve.surface": "0.2.2", "com.unity.mathematics": "1.3.2", "com.unity.modules.particlesystem": "1.0.0"