Add compact fractal SDF splat packets
This commit is contained in:
parent
b9ceb9c20e
commit
6d1927c380
14 changed files with 313 additions and 3 deletions
|
|
@ -528,6 +528,14 @@ compiler. The real page store, atlas, and D3D12 lowering remain open.
|
|||
Build compact-support 3D SDF splat packets for object/volume domains. Keep
|
||||
distance safety conservative and LOD gated.
|
||||
|
||||
Current state: `AquariumFractalSdfSplat3DKey` and
|
||||
`AquariumFractalSdfSplat3D` define stable compact-support 3D SDF splat packets.
|
||||
`FractalSdfSplat3DCompiler` lowers structural probe samples into splats, and
|
||||
`FractalSdfSplat3DKernel` provides CPU compact-weight and signed-distance
|
||||
parity math. Zyphos now exposes a first structural SDF splat from its probe
|
||||
reservoir. D3D12 lowering and object/body recursive form integration remain
|
||||
open.
|
||||
|
||||
### Phase G: 2D-Projected-To-3D Backend
|
||||
|
||||
Project 2D SDF tile pages onto 3D domains: cube-sphere planets, torus stations,
|
||||
|
|
|
|||
|
|
@ -448,6 +448,8 @@ Tasks:
|
|||
compiled brush packets for equivalent selected cuts.
|
||||
- [x] Feed traced planet geometry from a hard-budgeted top-influence subset of
|
||||
selected tile packets.
|
||||
- [x] Lower the structural probe reservoir into a first compact 3D SDF splat
|
||||
packet for inspection.
|
||||
- [x] Add first face/tile/material influence debug view through render debug
|
||||
mode 11.
|
||||
- [ ] Add LOD/cache debug overlays.
|
||||
|
|
|
|||
|
|
@ -108,6 +108,58 @@ public readonly record struct AquariumFractalSurfacePage(
|
|||
int PayloadHandle,
|
||||
float MaxError);
|
||||
|
||||
public readonly record struct AquariumFractalSdfSplat3DKey
|
||||
{
|
||||
public AquariumFractalSdfSplat3DKey(
|
||||
AquariumFractalKey domainKey,
|
||||
AquariumFractalKey nodeKey,
|
||||
int payloadHandle)
|
||||
{
|
||||
if (domainKey.Value is null)
|
||||
{
|
||||
throw new ArgumentException("3D SDF splat domain key must not be empty.", nameof(domainKey));
|
||||
}
|
||||
|
||||
if (nodeKey.Value is null)
|
||||
{
|
||||
throw new ArgumentException("3D SDF splat node key must not be empty.", nameof(nodeKey));
|
||||
}
|
||||
|
||||
if (payloadHandle < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(payloadHandle), payloadHandle, "3D SDF splat payload handle must not be negative.");
|
||||
}
|
||||
|
||||
DomainKey = domainKey;
|
||||
NodeKey = nodeKey;
|
||||
PayloadHandle = payloadHandle;
|
||||
}
|
||||
|
||||
public AquariumFractalKey DomainKey { get; }
|
||||
|
||||
public AquariumFractalKey NodeKey { get; }
|
||||
|
||||
public int PayloadHandle { get; }
|
||||
|
||||
public string Value => $"{DomainKey.Value}:{NodeKey.Value}:sdf3d:{PayloadHandle:D6}";
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly record struct AquariumFractalSdfSplat3D(
|
||||
AquariumFractalSdfSplat3DKey Key,
|
||||
Vector3 Center,
|
||||
Quaternion Orientation,
|
||||
Vector3 Radii,
|
||||
float Falloff,
|
||||
float ShapePower,
|
||||
float DistanceOffset,
|
||||
float MaterialValue,
|
||||
float Confidence);
|
||||
|
||||
public readonly record struct AquariumBrushClaim(
|
||||
AquariumFractalKey Key,
|
||||
AquariumFractalKey DomainKey,
|
||||
|
|
|
|||
44
src/Aquarium.Engine.Fractal/Lod/FractalSdfSplat3DCompiler.cs
Normal file
44
src/Aquarium.Engine.Fractal/Lod/FractalSdfSplat3DCompiler.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Aquarium.Engine.Fractal.Lod;
|
||||
|
||||
public static class FractalSdfSplat3DCompiler
|
||||
{
|
||||
public static AquariumFractalSdfSplat3D FromProbe(
|
||||
FractalProbeSample probe,
|
||||
float thickness,
|
||||
float falloff = 4.0f,
|
||||
float shapePower = 1.0f)
|
||||
{
|
||||
if (!float.IsFinite(probe.BoundRadius) || probe.BoundRadius <= 0.0f)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(probe), probe.BoundRadius, "Probe bound radius must be positive and finite.");
|
||||
}
|
||||
|
||||
if (!float.IsFinite(thickness) || thickness <= 0.0f)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(thickness), thickness, "3D SDF splat thickness must be positive and finite.");
|
||||
}
|
||||
|
||||
if (!float.IsFinite(falloff) || falloff <= 0.0f)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(falloff), falloff, "3D SDF splat falloff must be positive and finite.");
|
||||
}
|
||||
|
||||
if (!float.IsFinite(shapePower) || shapePower <= 0.0f)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(shapePower), shapePower, "3D SDF splat shape power must be positive and finite.");
|
||||
}
|
||||
|
||||
return new AquariumFractalSdfSplat3D(
|
||||
new AquariumFractalSdfSplat3DKey(probe.DomainKey, probe.NodeKey, probe.PayloadHandle),
|
||||
probe.LocalCenter,
|
||||
Quaternion.Identity,
|
||||
new Vector3(probe.BoundRadius, probe.BoundRadius, thickness),
|
||||
falloff,
|
||||
shapePower,
|
||||
DistanceOffset: 0.0f,
|
||||
MaterialValue: Math.Clamp(probe.MaterialDelta, 0.0f, 1.0f),
|
||||
Confidence: Math.Clamp(probe.TargetContribution, 0.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
33
src/Aquarium.Engine.Fractal/Lod/FractalSdfSplat3DKernel.cs
Normal file
33
src/Aquarium.Engine.Fractal/Lod/FractalSdfSplat3DKernel.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Aquarium.Engine.Fractal.Lod;
|
||||
|
||||
public static class FractalSdfSplat3DKernel
|
||||
{
|
||||
public static float CompactWeight(AquariumFractalSdfSplat3D splat, Vector3 point)
|
||||
{
|
||||
var local = Vector3.Transform(point - splat.Center, Quaternion.Inverse(splat.Orientation));
|
||||
var radii = Vector3.Max(splat.Radii, new Vector3(0.0001f));
|
||||
var q = local / radii;
|
||||
var radiusSquared = Vector3.Dot(q, q);
|
||||
if (radiusSquared >= 1.0f)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
var falloff = MathF.Max(splat.Falloff, 0.0001f);
|
||||
var shapePower = MathF.Max(splat.ShapePower, 0.0001f);
|
||||
var edge = MathF.Exp(-falloff);
|
||||
var value = MathF.Exp(-falloff * radiusSquared);
|
||||
var compact = Math.Clamp((value - edge) / MathF.Max(1.0f - edge, 0.000001f), 0.0f, 1.0f);
|
||||
return MathF.Pow(compact, shapePower);
|
||||
}
|
||||
|
||||
public static float SignedDistance(AquariumFractalSdfSplat3D splat, Vector3 point)
|
||||
{
|
||||
var local = Vector3.Transform(point - splat.Center, Quaternion.Inverse(splat.Orientation));
|
||||
var radii = Vector3.Max(splat.Radii, new Vector3(0.0001f));
|
||||
var q = local / radii;
|
||||
return ((q.Length() - 1.0f) * MathF.Min(radii.X, MathF.Min(radii.Y, radii.Z))) + splat.DistanceOffset;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Numerics;
|
||||
using Aquarium.Engine.Fractal.Grammar;
|
||||
using Aquarium.Engine.Fractal.Temporal;
|
||||
|
||||
|
|
@ -7,11 +8,34 @@ public readonly record struct FractalProbeReservoirSnapshot(
|
|||
bool HasSample,
|
||||
AquariumFractalKey DomainKey,
|
||||
AquariumFractalKey NodeKey,
|
||||
Vector3 LocalCenter,
|
||||
float TargetContribution,
|
||||
float BoundRadius,
|
||||
float SourcePdf,
|
||||
float MaterialDelta,
|
||||
float WeightSum,
|
||||
int CandidateCount,
|
||||
float ContributionWeight);
|
||||
float ContributionWeight,
|
||||
int PayloadHandle)
|
||||
{
|
||||
public FractalProbeSample ToProbeSample()
|
||||
{
|
||||
if (!HasSample)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot convert an empty structural probe reservoir snapshot to a probe sample.");
|
||||
}
|
||||
|
||||
return new FractalProbeSample(
|
||||
DomainKey,
|
||||
NodeKey,
|
||||
LocalCenter,
|
||||
BoundRadius,
|
||||
TargetContribution,
|
||||
SourcePdf,
|
||||
MaterialDelta,
|
||||
PayloadHandle);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FractalStructuralProbeReservoir
|
||||
{
|
||||
|
|
@ -69,11 +93,15 @@ public static class FractalStructuralProbeReservoir
|
|||
HasSample: true,
|
||||
selected.DomainKey,
|
||||
selected.NodeKey,
|
||||
selected.LocalCenter,
|
||||
selected.TargetContribution,
|
||||
selected.BoundRadius,
|
||||
selected.SourcePdf,
|
||||
selected.MaterialDelta,
|
||||
reservoir.WeightSum,
|
||||
reservoir.CandidateCount,
|
||||
reservoir.ContributionWeight);
|
||||
reservoir.ContributionWeight,
|
||||
selected.PayloadHandle);
|
||||
}
|
||||
|
||||
private static FractalProbeReservoirSnapshot Empty()
|
||||
|
|
@ -82,10 +110,14 @@ public static class FractalStructuralProbeReservoir
|
|||
HasSample: false,
|
||||
DomainKey: default,
|
||||
NodeKey: default,
|
||||
LocalCenter: Vector3.Zero,
|
||||
TargetContribution: 0.0f,
|
||||
BoundRadius: 0.0f,
|
||||
SourcePdf: 0.0f,
|
||||
MaterialDelta: 0.0f,
|
||||
WeightSum: 0.0f,
|
||||
CandidateCount: 0,
|
||||
ContributionWeight: 0.0f);
|
||||
ContributionWeight: 0.0f,
|
||||
PayloadHandle: 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public static class ZyphosFractalTerrain
|
|||
selectedCut,
|
||||
bucketPixelsPerWorld,
|
||||
new FractalXorShiftRandom(((uint)bucket ^ 0xC2B2AE35u) + (uint)selectedCut.Length));
|
||||
var structuralSdfSplats = BuildStructuralSdfSplats(structuralProbeReservoir);
|
||||
var surfacePages = PlanSurfacePages(selectedCut);
|
||||
var surfacePageResidency = FractalSurfacePageResidencyPlanner.Plan(
|
||||
surfacePages,
|
||||
|
|
@ -94,6 +95,7 @@ public static class ZyphosFractalTerrain
|
|||
selectedCut,
|
||||
resourcePlan,
|
||||
structuralProbeReservoir,
|
||||
structuralSdfSplats,
|
||||
surfacePages,
|
||||
surfacePageResidency,
|
||||
surfacePagePayloads,
|
||||
|
|
@ -114,6 +116,17 @@ public static class ZyphosFractalTerrain
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private static AquariumFractalSdfSplat3D[] BuildStructuralSdfSplats(FractalProbeReservoirSnapshot reservoir)
|
||||
{
|
||||
if (!reservoir.HasSample)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var thickness = MathF.Max(reservoir.BoundRadius * 0.25f, 0.001f);
|
||||
return [FractalSdfSplat3DCompiler.FromProbe(reservoir.ToProbeSample(), thickness)];
|
||||
}
|
||||
|
||||
private static FractalSurfacePagePayload[] BuildSurfacePagePayloads(IReadOnlyList<AquariumFractalSurfacePage> residentPages)
|
||||
{
|
||||
var payloads = new FractalSurfacePagePayload[residentPages.Count];
|
||||
|
|
@ -170,6 +183,7 @@ public static class ZyphosFractalTerrain
|
|||
$" evictions: {plan.ResourcePlan.Residency.EvictedNodes.Count}",
|
||||
$" structuralProbe: {(plan.StructuralProbeReservoir.HasSample ? plan.StructuralProbeReservoir.NodeKey.Value : "none")}",
|
||||
$" structuralProbeWeight: {plan.StructuralProbeReservoir.WeightSum:0.000} candidates={plan.StructuralProbeReservoir.CandidateCount} contributionWeight={plan.StructuralProbeReservoir.ContributionWeight:0.000}",
|
||||
$" structuralSdfSplats: {plan.StructuralSdfSplats.Length}",
|
||||
$" surfacePages: {plan.SurfacePages.Length} {SurfacePageDimension}x{SurfacePageDimension}",
|
||||
$" surfacePageResident: {plan.SurfacePageResidency.ResidentPages.Count}/{plan.SurfacePages.Length} bytes={plan.SurfacePageResidency.ResidentBytes}/{MaxResidentSurfacePageBytes}",
|
||||
$" surfacePagePayloads: {plan.SurfacePagePayloads.Length}",
|
||||
|
|
@ -233,6 +247,7 @@ public readonly record struct ZyphosFractalRenderPlan(
|
|||
AquariumSelectedCut[] SelectedCuts,
|
||||
FractalResourcePlan ResourcePlan,
|
||||
FractalProbeReservoirSnapshot StructuralProbeReservoir,
|
||||
AquariumFractalSdfSplat3D[] StructuralSdfSplats,
|
||||
AquariumFractalSurfacePage[] SurfacePages,
|
||||
FractalSurfacePageResidencyPlan SurfacePageResidency,
|
||||
FractalSurfacePagePayload[] SurfacePagePayloads,
|
||||
|
|
|
|||
|
|
@ -173,3 +173,4 @@
|
|||
{"timestamp":"2026-05-19T22:48:00+01:00","topic":"fractal-residency-eviction-policy","lesson":"Residency planning now has an explicit score-per-cost eviction decision. `FractalResidencyPlanner` can receive node summaries, retain resident payloads with the best contribution per estimated cost under RAM budget, place evicted residents on summary fallback, and report evicted node keys without mutating a real store. This keeps eviction testable until a page/payload store owns storage changes.","files":["src/Aquarium.Engine.Fractal/Lod/FractalResidencyPlanner.cs","src/Aquarium.Engine.Fractal/Lod/FractalResidencyPlan.cs","src/Aquarium.Engine.Fractal/Lod/FractalResourceBudgetPlanner.cs","tests/Aquarium.Engine.Fractal.Tests/FractalResidencyPlannerTests.cs","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","docs/perfect-machine-architecture.md","research/rendering/fractal-brush-implementation-roadmap.md","state/memory.json","state/map.yaml"],"source":"Perfect Machine Phase D/E residency pressure slice"}
|
||||
{"timestamp":"2026-05-19T23:10:00+01:00","topic":"fractal-surface-page-residency","lesson":"Surface page residency now has a separate mockable boundary from node payload residency. `IFractalSurfacePageStore` owns page-key resident/request/evict calls, and `FractalSurfacePageResidencyPlanner` turns planned pages into resident, missing, requested, evicted, and resident-byte rows using a max-error-per-byte heuristic. Zyphos carries this page residency plan for inspection before any real atlas or SSD-backed page store exists.","files":["src/Aquarium.Engine.Fractal/Lod/IFractalSurfacePageStore.cs","src/Aquarium.Engine.Fractal/Lod/FractalSurfacePageResidencyPlan.cs","src/Aquarium.Engine.Fractal/Lod/FractalSurfacePageResidencyPlanner.cs","tests/Aquarium.Engine.Fractal.Tests/FractalSurfacePageResidencyPlannerTests.cs","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","docs/perfect-machine-architecture.md","research/rendering/fractal-brush-implementation-roadmap.md","state/memory.json","state/map.yaml"],"source":"Perfect Machine Phase E page-store boundary slice"}
|
||||
{"timestamp":"2026-05-19T23:35:00+01:00","topic":"fractal-surface-page-rasterizer","lesson":"Resident surface pages now produce CPU payloads instead of only metadata. `FractalSurfacePageRasterizer` lowers ownership-tree claims into height, 2D signed-distance support, material, and confidence sample arrays using `FractalBrushEnvelope2D`; Zyphos caches resident page payloads by stable page key. This gives Phase E a renderer-agnostic payload producer before D3D12 atlas/upload work begins.","files":["src/Aquarium.Engine.Fractal/Brushes/FractalBrushEnvelope2D.cs","src/Aquarium.Engine.Fractal/Lod/FractalSurfacePagePayload.cs","src/Aquarium.Engine.Fractal/Lod/FractalSurfacePageRasterizer.cs","tests/Aquarium.Engine.Fractal.Tests/FractalBrushEnvelope2DTests.cs","tests/Aquarium.Engine.Fractal.Tests/FractalSurfacePageRasterizerTests.cs","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","docs/perfect-machine-architecture.md","research/rendering/fractal-brush-implementation-roadmap.md","state/memory.json","state/map.yaml"],"source":"Perfect Machine Phase E CPU page payload slice"}
|
||||
{"timestamp":"2026-05-19T23:55:00+01:00","topic":"fractal-3d-sdf-splat-contract","lesson":"Phase F has its first stable packet shape. `AquariumFractalSdfSplat3DKey` and `AquariumFractalSdfSplat3D` define domain/node/payload-keyed compact 3D SDF splats; `FractalSdfSplat3DCompiler` lowers structural `FractalProbeSample` evidence into splats, and `FractalSdfSplat3DKernel` owns CPU compact-weight/signed-distance parity math. Zyphos exposes a structural splat from its probe reservoir before renderer lowering.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Fractal/Lod/FractalSdfSplat3DCompiler.cs","src/Aquarium.Engine.Fractal/Lod/FractalSdfSplat3DKernel.cs","src/Aquarium.Engine.Fractal/Lod/FractalStructuralProbeReservoir.cs","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","tests/Aquarium.Engine.Fractal.Tests/FractalSdfSplat3DContractTests.cs","tests/Aquarium.Engine.Fractal.Tests/FractalSdfSplat3DCompilerTests.cs","tests/Aquarium.Engine.Fractal.Tests/FractalStructuralProbeReservoirTests.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","docs/perfect-machine-architecture.md","research/rendering/fractal-brush-implementation-roadmap.md","state/memory.json","state/map.yaml"],"source":"Perfect Machine Phase F compact 3D SDF splat groundwork"}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ renderer_state:
|
|||
- Contribution weights cannot all be refreshed every frame; the cache needs a probabilistic online estimator that samples nodes under budget, updates mean/uncertainty/sample age/confidence, preserves nonzero exploration for visible or near-threshold nodes, and can later become a learned predictor without replacing conservative SDF bounds.
|
||||
- Fractal resource planning is explicit: one plan coordinates CPU contribution updates, GPU selected-cut estimated cost, RAM resident payload budget, and SSD request pressure before backend packet compilation. This same budget language should generalize to Mimir-style sensor fusion because both fractal SDF probes and camera/microphone feature detections accumulate confidence-weighted spatial samples into temporal reservoirs.
|
||||
- Fractal residency uses score-per-cost retention under RAM pressure and emits evicted node keys as planner output; real storage mutation waits for a page/payload store boundary.
|
||||
- Compact 3D SDF splats now have a stable fractal contract and CPU compiler/kernel: structural FractalProbeSample evidence can lower into AquariumFractalSdfSplat3D packets with compact shaped support before GPU rendering exists.
|
||||
- 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.
|
||||
- Fractal surface page planning now has a CPU boundary: FractalSurfacePagePlanner lowers selected IFS cuts into stable height, 2D signed-distance, material, and confidence page metadata; ZyphosFractalRenderPlan exposes these pages, while the live D3D12 page store and atlas remain future work.
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@
|
|||
"FractalProbeReuseValidator.ValidateTemporal is the CPU contract for future GPU temporal reuse. It rejects excessive camera motion, disocclusion, material mismatch, low visibility, bad domain lineage, excessive local shift, and invalid bounds with explicit reasons; shader reuse should mirror this contract instead of inventing private validation rules.",
|
||||
"FractalStructuralProbeGenerator lowers AquariumFractalSummary rows into FractalProbeSample reservoir candidates with local support, projected target contribution, clamped source PDF, material delta, and payload handle. This is the structural IFS probe producer; renderer-facing temporal validation still needs camera/disocclusion/material/visibility inputs.",
|
||||
"FractalStructuralProbeReservoir builds a reservoir snapshot from an ownership tree, selected cut, summaries, and projected pixels per world unit. ZyphosFractalRenderPlan now carries this structural probe reservoir, so the planet path exposes reservoir-shaped structural evidence beside brushes/resource plans before GPU reuse exists.",
|
||||
"AquariumFractalSdfSplat3D is the compact 3D SDF splat packet contract for Phase F. FractalSdfSplat3DCompiler lowers FractalProbeSample evidence into stable domain/node/payload-keyed splats, and FractalSdfSplat3DKernel owns CPU compact-weight/signed-distance parity math. Zyphos exposes a first structural splat from its probe reservoir before D3D12 lowering.",
|
||||
"Zyphos camera distance limits belong to the selected spatial domain, not one global planetary clamp. Leaf/pebble domains must be able to zoom below whole-body distances, and the parent star must be a visible SDF body when it is also the primary light source.",
|
||||
"The consolidated fractal brush architecture lives in research/rendering/fractal-brush-architecture-plan.md. Its pipeline is client intent -> domain roots -> semantic IFS brush grammar -> ownership tree -> node summaries -> contribution cache/residency scheduler -> backend packets -> renderer passes -> debug/evidence. Its credibility depends on module boundaries and tests: contracts, pure CPU fractal core, D3D12 backend, client adapters, mock payload/probe/random/clock seams, shader parity tests, and deterministic performance fixtures.",
|
||||
"The Perfect Machine waterfall architecture lives in docs/perfect-machine-architecture.md. Treat it as the design authority before expanding SDF splat backends, sensor-fusion candidate adapters, reservoir guide buffers, occupancy graph state, resource-tier residency, or stochastic learned priority. Its core split is domains -> evidence candidates -> target evaluation -> ReSTIR/GRIS reservoirs -> occupancy graph -> residency -> 2D/3D/projected SDF splat packets -> TAA guide buffers.",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
using System.Numerics;
|
||||
using Aquarium.Engine.Fractal;
|
||||
using Aquarium.Engine.Fractal.Lod;
|
||||
|
||||
namespace Aquarium.Engine.Fractal.Tests;
|
||||
|
||||
public sealed class FractalSdfSplat3DCompilerTests
|
||||
{
|
||||
[Fact]
|
||||
public void SdfSplat3DCompilerLowersProbeIntoCompactSupportPacket()
|
||||
{
|
||||
var probe = new FractalProbeSample(
|
||||
new AquariumFractalKey("domain/object"),
|
||||
new AquariumFractalKey("node/object"),
|
||||
new Vector3(1.0f, 2.0f, 3.0f),
|
||||
BoundRadius: 4.0f,
|
||||
TargetContribution: 0.8f,
|
||||
SourcePdf: 0.25f,
|
||||
MaterialDelta: 0.3f,
|
||||
PayloadHandle: 12);
|
||||
|
||||
var splat = FractalSdfSplat3DCompiler.FromProbe(probe, thickness: 0.5f, falloff: 3.0f, shapePower: 0.75f);
|
||||
|
||||
Assert.Equal("domain/object:node/object:sdf3d:000012", splat.Key.Value);
|
||||
Assert.Equal(probe.LocalCenter, splat.Center);
|
||||
Assert.Equal(new Vector3(4.0f, 4.0f, 0.5f), splat.Radii);
|
||||
Assert.Equal(0.8f, splat.Confidence);
|
||||
Assert.Equal(0.3f, splat.MaterialValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdfSplat3DKernelIsCompactAndSigned()
|
||||
{
|
||||
var probe = new FractalProbeSample(
|
||||
new AquariumFractalKey("domain/object"),
|
||||
new AquariumFractalKey("node/object"),
|
||||
Vector3.Zero,
|
||||
BoundRadius: 2.0f,
|
||||
TargetContribution: 1.0f,
|
||||
SourcePdf: 1.0f,
|
||||
MaterialDelta: 0.0f,
|
||||
PayloadHandle: 0);
|
||||
var splat = FractalSdfSplat3DCompiler.FromProbe(probe, thickness: 1.0f);
|
||||
|
||||
Assert.Equal(1.0f, FractalSdfSplat3DKernel.CompactWeight(splat, Vector3.Zero), 5);
|
||||
Assert.Equal(0.0f, FractalSdfSplat3DKernel.CompactWeight(splat, new Vector3(2.0f, 0.0f, 0.0f)), 5);
|
||||
Assert.True(FractalSdfSplat3DKernel.SignedDistance(splat, Vector3.Zero) < 0.0f);
|
||||
Assert.Equal(0.0f, FractalSdfSplat3DKernel.SignedDistance(splat, new Vector3(2.0f, 0.0f, 0.0f)), 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdfSplat3DCompilerRejectsInvalidThickness()
|
||||
{
|
||||
var probe = new FractalProbeSample(
|
||||
new AquariumFractalKey("domain/object"),
|
||||
new AquariumFractalKey("node/object"),
|
||||
Vector3.Zero,
|
||||
BoundRadius: 1.0f,
|
||||
TargetContribution: 1.0f,
|
||||
SourcePdf: 1.0f,
|
||||
MaterialDelta: 0.0f,
|
||||
PayloadHandle: 0);
|
||||
|
||||
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => FractalSdfSplat3DCompiler.FromProbe(probe, thickness: 0.0f));
|
||||
|
||||
Assert.Equal("thickness", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
using System.Numerics;
|
||||
using Aquarium.Engine.Fractal;
|
||||
|
||||
namespace Aquarium.Engine.Fractal.Tests;
|
||||
|
||||
public sealed class FractalSdfSplat3DContractTests
|
||||
{
|
||||
[Fact]
|
||||
public void SdfSplat3DKeyIsStableAcrossDomainNodeAndPayload()
|
||||
{
|
||||
var key = new AquariumFractalSdfSplat3DKey(
|
||||
new AquariumFractalKey("domain/object"),
|
||||
new AquariumFractalKey("node/branch"),
|
||||
payloadHandle: 17);
|
||||
|
||||
Assert.Equal("domain/object:node/branch:sdf3d:000017", key.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdfSplat3DKeyRejectsNegativePayloadHandle()
|
||||
{
|
||||
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new AquariumFractalSdfSplat3DKey(
|
||||
new AquariumFractalKey("domain/object"),
|
||||
new AquariumFractalKey("node/branch"),
|
||||
payloadHandle: -1));
|
||||
|
||||
Assert.Equal("payloadHandle", ex.ParamName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdfSplat3DContractCarriesCompactSupportFields()
|
||||
{
|
||||
var splat = new AquariumFractalSdfSplat3D(
|
||||
new AquariumFractalSdfSplat3DKey(new AquariumFractalKey("domain/object"), new AquariumFractalKey("node/branch"), 2),
|
||||
Center: new Vector3(1.0f, 2.0f, 3.0f),
|
||||
Orientation: Quaternion.Identity,
|
||||
Radii: new Vector3(4.0f, 5.0f, 6.0f),
|
||||
Falloff: 3.0f,
|
||||
ShapePower: 0.75f,
|
||||
DistanceOffset: -0.1f,
|
||||
MaterialValue: 0.25f,
|
||||
Confidence: 0.8f);
|
||||
|
||||
Assert.Equal(new Vector3(4.0f, 5.0f, 6.0f), splat.Radii);
|
||||
Assert.Equal(0.8f, splat.Confidence);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,8 +24,11 @@ public sealed class FractalStructuralProbeReservoirTests
|
|||
Assert.True(snapshot.HasSample);
|
||||
Assert.Equal(domainKey, snapshot.DomainKey);
|
||||
Assert.Equal(rootKey, snapshot.NodeKey);
|
||||
Assert.Equal(Vector3.Zero, snapshot.LocalCenter);
|
||||
Assert.Equal(1, snapshot.CandidateCount);
|
||||
Assert.Equal(0, snapshot.PayloadHandle);
|
||||
Assert.True(snapshot.TargetContribution > 0.0f);
|
||||
Assert.True(snapshot.SourcePdf > 0.0f);
|
||||
Assert.True(snapshot.WeightSum > 0.0f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ public sealed class ZyphosFractalTerrainTests
|
|||
Assert.True(near.StructuralProbeReservoir.HasSample);
|
||||
Assert.True(near.StructuralProbeReservoir.CandidateCount > 0);
|
||||
Assert.True(near.StructuralProbeReservoir.WeightSum > 0.0f);
|
||||
Assert.Single(near.StructuralSdfSplats);
|
||||
Assert.Equal(near.StructuralProbeReservoir.NodeKey, near.StructuralSdfSplats[0].Key.NodeKey);
|
||||
Assert.Equal(near.SelectedCuts.Length * 4, near.SurfacePages.Length);
|
||||
Assert.Contains(near.SurfacePages, page => page.Key.Kind == AquariumFractalSurfacePageKind.SignedDistance2D);
|
||||
Assert.True(near.SurfacePageResidency.ResidentPages.Count <= near.SurfacePages.Length);
|
||||
|
|
@ -89,6 +91,7 @@ public sealed class ZyphosFractalTerrainTests
|
|||
Assert.Contains("evictions:", dump, StringComparison.Ordinal);
|
||||
Assert.Contains("structuralProbe:", dump, StringComparison.Ordinal);
|
||||
Assert.Contains("structuralProbeWeight:", dump, StringComparison.Ordinal);
|
||||
Assert.Contains("structuralSdfSplats:", dump, StringComparison.Ordinal);
|
||||
Assert.Contains("surfacePages:", dump, StringComparison.Ordinal);
|
||||
Assert.Contains("surfacePageResident:", dump, StringComparison.Ordinal);
|
||||
Assert.Contains("surfacePagePayloads:", dump, StringComparison.Ordinal);
|
||||
|
|
|
|||
Loading…
Reference in a new issue