From e2a81d68ee70a18da7be30d5b0c8112ab5db6902 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 20 May 2026 23:58:05 +0100 Subject: [PATCH] Teach flame parser first JWildfire dialect slice --- .../rendering/fractal-reference-oracles.md | 57 +++++++++++++++++++ .../Grammar/FractalFlameChaosGame.cs | 3 +- .../Grammar/FractalFlameDefinition.cs | 57 +++++++++++++++++-- .../Grammar/FractalFlameFileParser.cs | 30 +++++++--- .../Lod/FractalGpuProgramCompiler.cs | 4 +- .../Shaders/D3D12FractalReservoirCompute.hlsl | 32 +++++++++++ state/map.yaml | 2 + state/memory.json | 1 + .../ApophysisReferenceParityTests.cs | 38 +++++++++++++ .../JWildfire/julian-disc-minimal.flame | 10 ++++ 10 files changed, 218 insertions(+), 16 deletions(-) create mode 100644 tests/Aquarium.Engine.Fractal.Tests/Fixtures/JWildfire/julian-disc-minimal.flame diff --git a/research/rendering/fractal-reference-oracles.md b/research/rendering/fractal-reference-oracles.md index d9c1590..27b03bc 100644 --- a/research/rendering/fractal-reference-oracles.md +++ b/research/rendering/fractal-reference-oracles.md @@ -129,6 +129,63 @@ Apophysis-style minimal XML rather than full JWildfire `variationGroup` flame XML. Do not "fix" that by making the fixture bigger until the parser and DSL contract deliberately support the richer reference dialect. +## JWildfire Selftest Faceplant + +Running JWildfire's bundled `selftest.flame` through Aquarium is the correct +kind of embarrassing: + +```powershell +.\scripts\fractal-splat-receipt.ps1 ` + -ProgramFlame artifacts\reference-tools\j-wildfire-9.00\lib\FARenderJWF\selftest.flame ` + -Splats 2000000 ` + -SplatUpdates 50000 ` + -Warmup 0 ` + -Frames 1 ` + -Depth 64 ` + -ReservoirUpdates 15000 ` + -ReadbackSplats 250000 ` + -VisualParity ` + -VisualParityReferenceSamples 1000000 ` + -HistogramSize 256x256 ` + -HistogramBounds '-128,-128,128,128' +``` + +First receipt after adding the JWildfire `variationGroup`/coefficient-layout +slice and the `disc`, `julian`, and `gaussian_blur` variation subset: + +- GPU time: `66.446 ms/frame`, `15.0 FPS` equivalent +- visual score: `5.01%` +- occupancy overlap: `3.04%` +- L1 distance: `1.899840` +- artifact: + `artifacts/fractal-jwildfire-faceplant/jwildfire-vs-aquarium-expanded.png` + +The first unexpanded run scored `0.00%` and rendered a single dot. The expanded +run produces a recognizable central flame knot, but it still does not match the +reference. This is not just "more variations needed." It exposes three distinct +gaps: + +1. **DSL expressiveness.** A serious flame dialect needs named variation + nodes, parameters, post transforms, palette/color semantics, xaos/chaos + weights, and optional weighting fields. The current Aquarium flame subset is + a compact test dialect, not a full JWildfire import surface. +2. **Translation quality.** JWildfire's coefficient layout differs from the + older Apophysis-style fixtures. `variationGroup` can hide the real variation + list from the xform attributes. Rich dialect import needs a translation + report that says exactly which fields were accepted, approximated, ignored, + or rejected. +3. **Hot-path shape.** Brute replaying 64 flame iterations per splat in one + compute invocation is too slow. Rich flame rendering should store continuing + iteration state in GPU reservoirs and advance it stochastically across + frames, then density-estimate/shade from those resident samples. The reservoir + is the renderer, not an expensive reset button. + +The next coherent slice is therefore not "add 200 variations." It is an +import/lowering contract: parse a richer flame AST, produce an explicit +translation report, lower supported variation nodes into compact GPU op rows, +and carry persistent per-sample iteration state so zoom/movement can reuse +sample history instead of starting every splat from zero. + ## GPU Flame Receipt The flame fixture can now drive the D3D12 reservoir receipt directly: diff --git a/src/Aquarium.Engine.Fractal/Grammar/FractalFlameChaosGame.cs b/src/Aquarium.Engine.Fractal/Grammar/FractalFlameChaosGame.cs index f81a8bd..aecdf84 100644 --- a/src/Aquarium.Engine.Fractal/Grammar/FractalFlameChaosGame.cs +++ b/src/Aquarium.Engine.Fractal/Grammar/FractalFlameChaosGame.cs @@ -25,7 +25,7 @@ public static class FractalFlameChaosGame for (var step = 0; step < burnIn + count; step++) { - point = SelectTransform(definition.Transforms, total, (float)random.NextDouble()).Apply(point); + point = SelectTransform(definition.Transforms, total, (float)random.NextDouble()).Apply(point, random); if (step >= burnIn) { points[step - burnIn] = point; @@ -54,4 +54,3 @@ public static class FractalFlameChaosGame return transforms[^1]; } } - diff --git a/src/Aquarium.Engine.Fractal/Grammar/FractalFlameDefinition.cs b/src/Aquarium.Engine.Fractal/Grammar/FractalFlameDefinition.cs index b6f4aab..402d999 100644 --- a/src/Aquarium.Engine.Fractal/Grammar/FractalFlameDefinition.cs +++ b/src/Aquarium.Engine.Fractal/Grammar/FractalFlameDefinition.cs @@ -5,11 +5,22 @@ namespace Aquarium.Engine.Fractal.Grammar; public readonly record struct FractalFlameVariationWeights( float Linear, float Spherical, - float Bubble) + float Bubble, + float Disc = 0.0f, + float Julian = 0.0f, + float JulianPower = 2.0f, + float JulianDist = 1.0f, + float GaussianBlur = 0.0f) { - public bool HasAny => Linear != 0.0f || Spherical != 0.0f || Bubble != 0.0f; + public bool HasAny => + Linear != 0.0f || + Spherical != 0.0f || + Bubble != 0.0f || + Disc != 0.0f || + Julian != 0.0f || + GaussianBlur != 0.0f; - public Vector2 Apply(Vector2 point) + public Vector2 Apply(Vector2 point, IFractalRandom? random = null) { var result = Vector2.Zero; if (Linear != 0.0f) @@ -28,8 +39,40 @@ public readonly record struct FractalFlameVariationWeights( result += point * (Bubble * 4.0f / (radiusSquared + 4.0f)); } + if (Disc != 0.0f) + { + var radius = MathF.Sqrt(radiusSquared); + var theta = MathF.Atan2(point.Y, point.X); + var scaledTheta = Disc * theta / MathF.PI; + result += new Vector2( + MathF.Sin(MathF.PI * radius) * scaledTheta, + MathF.Cos(MathF.PI * radius) * scaledTheta); + } + + if (Julian != 0.0f) + { + var power = MathF.Abs(JulianPower) < 1.0f ? 1.0f : JulianPower; + var absPower = MathF.Max(MathF.Abs(power), 1.0f); + var branch = MathF.Floor(NextUnit(random) * absPower); + var angle = (MathF.Atan2(point.Y, point.X) + (2.0f * MathF.PI * branch)) / power; + var radius = MathF.Pow(MathF.Max(MathF.Sqrt(radiusSquared), 0.000001f), JulianDist / power); + result += new Vector2(MathF.Cos(angle), MathF.Sin(angle)) * (Julian * radius); + } + + if (GaussianBlur != 0.0f) + { + var amount = GaussianBlur * (NextUnit(random) + NextUnit(random) + NextUnit(random) + NextUnit(random) - 2.0f); + var angle = NextUnit(random) * 2.0f * MathF.PI; + result += new Vector2(MathF.Cos(angle), MathF.Sin(angle)) * amount; + } + return result; } + + private static float NextUnit(IFractalRandom? random) + { + return random is null ? 0.5f : (float)random.NextDouble(); + } } public readonly record struct FractalFlameTransform2D( @@ -41,11 +84,16 @@ public readonly record struct FractalFlameTransform2D( FractalFlameVariationWeights Variations) { public Vector2 Apply(Vector2 point) + { + return Apply(point, random: null); + } + + public Vector2 Apply(Vector2 point, IFractalRandom? random) { var affine = new Vector2( (Matrix.X * point.X) + (Matrix.Y * point.Y) + Translation.X, (Matrix.Z * point.X) + (Matrix.W * point.Y) + Translation.Y); - return Variations.HasAny ? Variations.Apply(affine) : affine; + return Variations.HasAny ? Variations.Apply(affine, random) : affine; } } @@ -81,4 +129,3 @@ public sealed class FractalFlameDefinition public IReadOnlyList Transforms { get; } } - diff --git a/src/Aquarium.Engine.Fractal/Grammar/FractalFlameFileParser.cs b/src/Aquarium.Engine.Fractal/Grammar/FractalFlameFileParser.cs index 8f7470a..fea564c 100644 --- a/src/Aquarium.Engine.Fractal/Grammar/FractalFlameFileParser.cs +++ b/src/Aquarium.Engine.Fractal/Grammar/FractalFlameFileParser.cs @@ -14,23 +14,39 @@ public static class FractalFlameFileParser var flame = document.Descendants("flame").FirstOrDefault() ?? throw new FormatException("Flame file does not contain a flame element."); var name = ((string?)flame.Attribute("name")) ?? "flame"; - var transforms = flame.Elements("xform").Select((xform, index) => ParseXform(xform, index)).ToArray(); + var isJWildfireDialect = string.Equals(document.Root?.Name.LocalName, "Flames", StringComparison.Ordinal) + || flame.Elements("xform").Any(xform => xform.Element("variationGroup") is not null); + var transforms = flame.Elements("xform").Select((xform, index) => ParseXform(xform, index, isJWildfireDialect)).ToArray(); return new FractalFlameDefinition(name, Vector2.Zero, seed, transforms); } - private static FractalFlameTransform2D ParseXform(XElement element, int index) + private static FractalFlameTransform2D ParseXform(XElement element, int index, bool isJWildfireDialect) { var coefs = ParseFloatList((string?)element.Attribute("coefs"), expectedCount: 6, "xform coefs"); + var variationGroup = element.Element("variationGroup"); + var variationSource = variationGroup ?? element; + var matrix = isJWildfireDialect + ? new Vector4(coefs[0], coefs[2], coefs[1], coefs[3]) + : new Vector4(coefs[0], coefs[1], coefs[3], coefs[4]); + var translation = isJWildfireDialect + ? new Vector2(coefs[4], coefs[5]) + : new Vector2(coefs[2], coefs[5]); + return new FractalFlameTransform2D( ((string?)element.Attribute("name")) ?? $"xform/{index:0000}", - new Vector4(coefs[0], coefs[1], coefs[3], coefs[4]), - new Vector2(coefs[2], coefs[5]), + matrix, + translation, ParseOptionalFloat(element, "weight", 1.0f), ParseOptionalFloat(element, "color", 0.0f), new FractalFlameVariationWeights( - ParseOptionalFloat(element, "linear", 0.0f), - ParseOptionalFloat(element, "spherical", 0.0f), - ParseOptionalFloat(element, "bubble", 0.0f))); + ParseOptionalFloat(variationSource, "linear", 0.0f) + ParseOptionalFloat(variationSource, "normal", 0.0f), + ParseOptionalFloat(variationSource, "spherical", 0.0f), + ParseOptionalFloat(variationSource, "bubble", 0.0f), + ParseOptionalFloat(variationSource, "disc", 0.0f) + ParseOptionalFloat(variationSource, "jwf_disc", 0.0f), + ParseOptionalFloat(variationSource, "julian", 0.0f) + ParseOptionalFloat(variationSource, "jwf_julian", 0.0f), + ParseOptionalFloat(variationSource, "julian_power", ParseOptionalFloat(variationSource, "jwf_julian_power", 2.0f)), + ParseOptionalFloat(variationSource, "julian_dist", ParseOptionalFloat(variationSource, "jwf_julian_dist", 1.0f)), + ParseOptionalFloat(variationSource, "gaussian_blur", 0.0f) + ParseOptionalFloat(variationSource, "jwf_gaussian_blur", 0.0f))); } private static float ParseOptionalFloat(XElement element, string name, float fallback) diff --git a/src/Aquarium.Engine.Fractal/Lod/FractalGpuProgramCompiler.cs b/src/Aquarium.Engine.Fractal/Lod/FractalGpuProgramCompiler.cs index 4e742d2..2bba37a 100644 --- a/src/Aquarium.Engine.Fractal/Lod/FractalGpuProgramCompiler.cs +++ b/src/Aquarium.Engine.Fractal/Lod/FractalGpuProgramCompiler.cs @@ -64,8 +64,8 @@ public static class FractalGpuProgramCompiler return new AquariumPackedFractalIfsTransform( transform.Matrix, new Vector4(transform.Translation, transform.Variations.Linear, transform.Variations.Spherical), - new Vector4(transform.Variations.Bubble, MathF.Max(transform.Weight, 0.0f), transform.Color, StableUnit(transform.Name, (int)(transform.Color * 4096.0f))), - Vector4.Zero); + new Vector4(transform.Variations.Bubble, MathF.Max(transform.Weight, 0.0f), transform.Color, transform.Variations.JulianDist), + new Vector4(transform.Variations.Disc, transform.Variations.Julian, transform.Variations.JulianPower, transform.Variations.GaussianBlur)); } private static AquariumPackedFractalIfsTransform Pack( diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl index cb060a8..f04e02b 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl @@ -149,9 +149,41 @@ float3 FractalPoint(uint index, out float radius) float2 t = transform.radiiRotationFalloff.xy; float2 affine = float2((m.x * p.x) + (m.y * p.y) + t.x, (m.z * p.x) + (m.w * p.y) + t.y); float r2 = dot(affine, affine); + float r = sqrt(max(r2, 0.0)); + float theta = atan2(affine.y, affine.x); float2 nextPoint = affine * transform.radiiRotationFalloff.z; nextPoint += affine * (transform.radiiRotationFalloff.w / max(r2, 0.000001)); nextPoint += affine * (transform.materialSeedShape.x * 4.0 / (r2 + 4.0)); + float disc = transform.tileAddress.x; + if (disc != 0.0) + { + float discTheta = disc * theta / 3.14159265358979323846; + nextPoint += float2(sin(3.14159265358979323846 * r), cos(3.14159265358979323846 * r)) * discTheta; + } + + float julian = transform.tileAddress.y; + if (julian != 0.0) + { + float power = abs(transform.tileAddress.z) < 1.0 ? 1.0 : transform.tileAddress.z; + float absPower = max(abs(power), 1.0); + float branch = floor(Random01(n + depth * 2246822519u + 97u) * absPower); + float angle = (theta + 6.28318530717958647692 * branch) / power; + float radial = pow(max(r, 0.000001), transform.materialSeedShape.w / power); + nextPoint += julian * radial * float2(cos(angle), sin(angle)); + } + + float blur = transform.tileAddress.w; + if (blur != 0.0) + { + float blurRadius = blur * ( + Random01(n + depth * 3266489917u + 11u) + + Random01(n + depth * 3266489917u + 23u) + + Random01(n + depth * 3266489917u + 37u) + + Random01(n + depth * 3266489917u + 53u) - 2.0); + float blurAngle = Random01(n + depth * 668265263u + 71u) * 6.28318530717958647692; + nextPoint += blurRadius * float2(cos(blurAngle), sin(blurAngle)); + } + p = nextPoint; material = transform.materialSeedShape.z; support *= saturate(max(length(m.xy), length(m.zw))); diff --git a/state/map.yaml b/state/map.yaml index 72e1482..c724b2d 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -154,6 +154,7 @@ renderer_state: - View-conditioned visual parity now scores named camera windows instead of trusting one global histogram. For the depth-16 flame receipt, global -8..8 scores 97.09%, mid -1..1 scores 91.93%, close -0.5..0.5 scores 88.97%, and micro -0.25..0.25 scores 82.05% with 2,656 starved reference bins and 17.95% underrepresented mass. This is the current hard loss: the reservoir is not yet spending work based on camera-conditioned underrepresentation. - High-reference flame contact sheets should use at least 20M CPU oracle samples for visual judgment. The current artifact is artifacts/fractal-contact-sheet-hq/flame-parity-contact-sheet-hq.png, comparing 20M CPU oracle histograms against 250k Aquarium GPU readback samples for global frame 1/10 and zoom frame 1/10. The 1M-sample oracle was too noisy and should be treated as a scalar smoke check only. - External flame visual references are now reproducible from ignored local artifacts. scripts/install-flame-reference-tools.ps1 hydrates JWildfire 9.00 plus Temurin JRE 17 under artifacts/reference-tools; scripts/fractal-flame-jwildfire-reference.ps1 prefers JWildfire's bundled FARenderJWF GPU renderer for explicit PNG output. Local GTX 1070 smoke rendered FARender's selftest.flame at 1024x1024 quality 2000 in 7.69 sec to artifacts/fractal-flame-jwildfire-reference/selftest-farender-20260520-233638.png. JWildfire/FARender is a visual reference artifact lane, not Aquarium runtime code. + - JWildfire selftest flame is the current honest faceplant target. After adding a first dialect slice for JWildfire coefficient layout, variationGroup, disc, julian, and gaussian_blur, the depth-64 GTX 1070 receipt against artifacts/reference-tools/j-wildfire-9.00/lib/FARenderJWF/selftest.flame reaches only 5.01% visual score / 3.04% occupancy overlap at 66.446 ms/frame. This proves the renderer needs a richer flame AST/translation report and persistent GPU iteration-state reservoirs; brute replaying deep flame iteration from zero per splat is not the final hot path. - D3D12 capacity logging now reports active fractal reservoir resident MiB, splat count, visible debug splat count, updates/pass, and candidates/update so the GPU cache has a receipt in normal runtime logs, not just in the standalone benchmark. - The consolidated fractal brush architecture plan defines the intended pipeline: client intent -> domain roots -> semantic IFS brush grammar -> ownership tree -> node summaries -> contribution cache/residency scheduler -> backend packets -> renderer passes -> debug/evidence, with explicit module boundaries and mockable unit-test seams. - The Perfect Machine architecture lives in docs/perfect-machine-architecture.md. It is the current waterfall design authority for fast 2D SDF splats, 3D SDF splats, 2D-projected-to-3D surface splats, IFS `.aquageo` structural probes, Mimir-style camera/audio evidence candidates, ReSTIR/GRIS reservoir reuse, heuristic occupancy graph updates, resource-tier residency, and TAA guide-buffer integration. @@ -191,6 +192,7 @@ next_actions: - Follow research/rendering/fractal-brush-architecture-plan.md before implementing the fractal brush DSL, IFS LOD cache, recursive detail residency, or learned contribution scoring. - Follow docs/perfect-machine-architecture.md before expanding SDF splat backends, sensor-fusion candidate adapters, reservoir guide buffers, occupancy graph state, or stochastic learned priority. - Use research/rendering/fractal-brush-implementation-roadmap.md as the actionable execution checklist for fractal brush work. + - Next flame reference slice: build a JWildfire import/lowering report that separates supported, approximated, ignored, and rejected variation fields before expanding the GPU op set. Do not hide dialect loss behind successful XML parsing. - Follow docs/zyphos-eusocial-sync.md and E:\Projects\Eusocial Interbeing\Eusocial Interbeing\World\Zyphos Simulation Brief.md before turning Zyphos visual choices into setting claims. - Follow docs/tsr-inspired-taa-spec.md when changing current temporal diagnostics. - Use docs/temporal-sdf-gaussian-field.md before wiring LocalCastBridge visual sensor fusion into Aquarium or scaling the temporal Gaussian renderer beyond the current bounded instanced pass. diff --git a/state/memory.json b/state/memory.json index f1939c3..0b5ebf0 100644 --- a/state/memory.json +++ b/state/memory.json @@ -112,6 +112,7 @@ "Global flame parity is not enough. View-conditioned parity now scores named viewport bounds and reports GPU/reference hits, starved reference bins, and underrepresented mass. First depth-16 GTX 1070 receipt with 250k GPU readback splats vs 1M CPU samples: global -8..8 scores 97.09%, mid -1..1 scores 91.93%, close -0.5..0.5 scores 88.97%, micro -0.25..0.25 scores 82.05% with 2,656 starved bins and 17.95% underrepresented mass. This proves the current reservoir is fast but not view-adaptive; next work needs camera-conditioned target weights and underrepresented-region feedback.", "Do not use the quick 1M-sample flame oracle image for visual judgment; it is too noisy. The high-reference contact sheet uses 20,000,000 CPU oracle samples and 250,000 Aquarium GPU readback splats per panel at artifacts/fractal-contact-sheet-hq/flame-parity-contact-sheet-hq.png. It makes the zoom failure legible: the CPU oracle smooths out while Aquarium remains under-sampled after zoom because the current reservoir is not view-adaptive.", "Aquarium's CPU flame histogram is a math oracle, not visual ground truth. The visual reference ladder is: Chaotica as gold market-quality reference when available/imported, JWildfire/FARender as scriptable visual reference, FLAM3/Apophysis as portable baseline compatibility, Aquarium CPU as deterministic unit-test/debug oracle only. On 2026-05-20 Chaotica and flam3-render were not on PATH, but scripts/install-flame-reference-tools.ps1 hydrated JWildfire 9.00 plus Temurin JRE 17 under ignored artifacts, and scripts/fractal-flame-jwildfire-reference.ps1 rendered JWildfire's bundled FARenderJWF selftest flame at 1024x1024 quality 2000 in 7.69 sec on the GTX 1070. JWildfire/FARender is an external visual reference artifact lane, not Aquarium runtime code. Do not claim best-in-market flame parity until imported Chaotica renders or fully matched JWildfire flame dialect metrics are wired into residual scoring.", + "JWildfire selftest is now the flame renderer faceplant target. A first dialect slice supports JWildfire coefficient layout, variationGroup, disc, julian, and gaussian_blur; the depth-64 GTX 1070 receipt still scores only 5.01% visual parity / 3.04% occupancy overlap at 66.446 ms/frame. This is a DSL/translation/hot-path failure, not just a sample-count problem: Aquarium needs a richer flame AST with explicit accepted/approximated/ignored/rejected field reports, GPU variation op rows, and persistent per-sample iteration-state reservoirs instead of replaying deep chaos-game ancestry from zero for every splat.", "Zyphos' primary planetary terrain test path is now the fractal reservoir surface. The direct SDF planet and Umbros proxy shaders are removed from the render plan; only the parent star remains as a direct SDF body/light. If the planet looks wrong, fix the reservoir lowering/shading path instead of letting the old SDF terrain hide it.", "The GPU splat receipt harness lives at tools/Aquarium.Fractal.Receipt and scripts/fractal-splat-receipt.ps1. The live receipt allocates one 80-byte packed SDF splat UAV plus three distinct 64-byte reservoir UAVs for SDF envelopes, PBR material envelopes, and radiosity; those reservoirs are sampled in independent compute passes under a stochastic update budget. On the local NVIDIA GTX 1070 it kept 2,000,000 splats and 2,000,000 reservoirs per layer resident. The fallback hash-fractal receipt updated 50,000 entries per layer with 2 candidates/update at 4.471 ms/frame, 223.7 FPS equivalent. The authored precomposed selected-cut receipt used depth 48, 4 compact transforms, and 15,000 updates per layer at 4.908 ms/frame, 203.7 FPS equivalent, with full reservoir coverage in 133.3 frames. D3D12FractalSplatRender consumes the raw splat, SDF, PBR, and radiosity buffers through separate graphics SRVs for the visible debug subset. This proves compute-side GPU residency, budgeted temporal convergence, authored-program splat population decoupled from domain ancestry depth, and first layered GPU consumption; final terrain/material/radiosity shading is still future work.", "FractalProjectedSdfSplatCompiler is the Phase G 2D-projected-to-3D lowering seam: it converts resident SignedDistance2D page payload samples into compact 3D SDF splats through an explicit page-local Vector2 -> Vector3 mapping, surface normal, support radius, and splat budget. Zyphos caches a bounded first set with a flat local mapping until cube-sphere/torus mappers are added.", diff --git a/tests/Aquarium.Engine.Fractal.Tests/ApophysisReferenceParityTests.cs b/tests/Aquarium.Engine.Fractal.Tests/ApophysisReferenceParityTests.cs index 2dd0d26..4c88caf 100644 --- a/tests/Aquarium.Engine.Fractal.Tests/ApophysisReferenceParityTests.cs +++ b/tests/Aquarium.Engine.Fractal.Tests/ApophysisReferenceParityTests.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Numerics; using System.Xml.Linq; using Aquarium.Engine.Fractal.Grammar; +using Aquarium.Engine.Fractal.Lod; namespace Aquarium.Engine.Fractal.Tests; @@ -106,6 +107,43 @@ public sealed class ApophysisReferenceParityTests Assert.Equal(0xAEB1C81Bu, checksum); } + [Fact] + public void FlameParserReadsJWildfireVariationGroupSubset() + { + var root = FindRepoRoot(); + var flamePath = Path.Combine(root, "tests", "Aquarium.Engine.Fractal.Tests", "Fixtures", "JWildfire", "julian-disc-minimal.flame"); + + var flame = FractalFlameFileParser.ParseFirst(File.ReadAllText(flamePath), seed: 91); + + Assert.Equal("julian-disc-minimal", flame.Name); + Assert.Equal(2, flame.Transforms.Count); + Assert.Equal(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), flame.Transforms[0].Matrix); + Assert.Equal(new Vector2(-0.1f, 0.2f), flame.Transforms[0].Translation); + Assert.Equal(1.0f, flame.Transforms[0].Variations.Linear); + Assert.Equal(0.5f, flame.Transforms[0].Variations.Julian); + Assert.Equal(5.0f, flame.Transforms[0].Variations.JulianPower); + Assert.Equal(1.25f, flame.Transforms[0].Variations.JulianDist); + Assert.Equal(0.02f, flame.Transforms[0].Variations.GaussianBlur); + Assert.Equal(new Vector4(0.25f, 0.75f, -0.75f, 0.25f), flame.Transforms[1].Matrix); + Assert.Equal(0.8f, flame.Transforms[1].Variations.Disc); + } + + [Fact] + public void JWildfireVariationSubsetFeedsGpuProgramRows() + { + var root = FindRepoRoot(); + var flamePath = Path.Combine(root, "tests", "Aquarium.Engine.Fractal.Tests", "Fixtures", "JWildfire", "julian-disc-minimal.flame"); + var flame = FractalFlameFileParser.ParseFirst(File.ReadAllText(flamePath), seed: 91); + + var rows = FractalGpuProgramCompiler.CompileFlame2D(flame, maxTransformCount: 8); + + Assert.Equal(2, rows.Length); + Assert.Equal(0.5f, rows[0].TileAddress.Y); + Assert.Equal(5.0f, rows[0].TileAddress.Z); + Assert.Equal(0.02f, rows[0].TileAddress.W); + Assert.Equal(0.8f, rows[1].TileAddress.X); + } + [Fact] public void PpmReferenceReceiptReadsExternalRendererOutputShape() { diff --git a/tests/Aquarium.Engine.Fractal.Tests/Fixtures/JWildfire/julian-disc-minimal.flame b/tests/Aquarium.Engine.Fractal.Tests/Fixtures/JWildfire/julian-disc-minimal.flame new file mode 100644 index 0000000..803bae2 --- /dev/null +++ b/tests/Aquarium.Engine.Fractal.Tests/Fixtures/JWildfire/julian-disc-minimal.flame @@ -0,0 +1,10 @@ + + + + + + + + + +