Lower portable radial cosine fields

This commit is contained in:
Meta Vens 2026-07-15 23:38:00 +01:00
commit 03ce78031f
4 changed files with 60 additions and 3 deletions

View file

@ -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"

View file

@ -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);
}

View file

@ -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,

View file

@ -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"