Tag GPU splats with form encoding
This commit is contained in:
parent
c2a5e5d1ed
commit
b0c5ad385d
6 changed files with 23 additions and 10 deletions
|
|
@ -67,6 +67,9 @@ RWStructuredBuffer<RadiosityReservoir> RadiosityReservoirs : register(u3);
|
|||
RWStructuredBuffer<FlameIterationState> FlameStates : register(u4);
|
||||
StructuredBuffer<FractalIfsTransform> ProgramTransforms : register(t0);
|
||||
|
||||
static const float FIELD_ENCODING_SIGNED_DISTANCE = 0.0;
|
||||
static const float FIELD_ENCODING_DENSITY = 2.0;
|
||||
|
||||
uint Hash(uint x)
|
||||
{
|
||||
x ^= x >> 16;
|
||||
|
|
@ -355,11 +358,12 @@ void D3D12FractalSplatReceiptCS(uint3 id : SV_DispatchThreadID)
|
|||
float radius;
|
||||
float3 p = FractalPoint(index, radius);
|
||||
uint h = Hash(index + FrameIndex * 1664525u + Seed);
|
||||
float fieldEncoding = ProgramMode == 2u ? FIELD_ENCODING_DENSITY : FIELD_ENCODING_SIGNED_DISTANCE;
|
||||
FractalSdfSplat splat;
|
||||
splat.centerRadius = float4(p, radius);
|
||||
splat.orientation = float4(0.0, 0.0, 0.0, 1.0);
|
||||
splat.radiiFalloff = float4(radius, radius * 0.72, radius * 0.45, 4.0);
|
||||
splat.materialConfidence = float4((float)(h & 1023u) / 1023.0, 1.0, 0.0, 1.0);
|
||||
splat.materialConfidence = float4((float)(h & 1023u) / 1023.0, 1.0, fieldEncoding, 1.0);
|
||||
splat.key = float4((float)index, (float)FrameIndex, (float)Depth, asfloat(h));
|
||||
Splats[index] = splat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ struct SceneOut
|
|||
};
|
||||
|
||||
static const float FIELD_ID_FRACTAL_SPLAT_BASE = 4000.0;
|
||||
static const float FIELD_ENCODING_DENSITY = 2.0;
|
||||
|
||||
void cameraBasis(float3 camera, float3 target, out float3 forward, out float3 right, out float3 up)
|
||||
{
|
||||
|
|
@ -175,6 +176,7 @@ SceneOut D3D12FractalSplatPS(FractalSplatVertexOut input)
|
|||
bool sdfResident = sdf.weightTargetCount.z > 0.5;
|
||||
bool pbrResident = pbr.weightTargetCount.z > 0.5;
|
||||
bool radiosityResident = radiosity.weightTargetCount.z > 0.5;
|
||||
bool densityField = abs(splat.materialConfidence.z - FIELD_ENCODING_DENSITY) < 0.5;
|
||||
float surfaceZ = sqrt(saturate(1.0 - r2));
|
||||
float3 tangentOffset = (input.basisRight * input.quad.x) + (input.basisUp * input.quad.y);
|
||||
float3 normal = normalize(input.basisForward * (0.92 + surfaceZ * 0.08) + tangentOffset * 0.16);
|
||||
|
|
@ -183,7 +185,9 @@ SceneOut D3D12FractalSplatPS(FractalSplatVertexOut input)
|
|||
float viewFacing = saturate(dot(normalize(cameraPosition - surfaceWorld), normal));
|
||||
float starFacing = saturate(dot(normal, normalize(float3(0.25, 0.006, 0.077) - surfaceWorld)));
|
||||
float material = saturate(splat.materialConfidence.x);
|
||||
float3 fallbackColor = lerp(float3(0.08, 0.38, 0.18), float3(0.78, 0.61, 0.32), material);
|
||||
float3 fallbackColor = densityField
|
||||
? lerp(float3(0.18, 0.08, 0.32), float3(1.0, 0.44, 0.12), material)
|
||||
: lerp(float3(0.08, 0.38, 0.18), float3(0.78, 0.61, 0.32), material);
|
||||
float3 pbrColor = lerp(float3(0.06, 0.30, 0.14), saturate(pbr.baseColorRoughMetal.rgb), 0.72);
|
||||
float3 radiosityColor = saturate(radiosity.radianceDistance.rgb);
|
||||
float reservoirConfidence = min(
|
||||
|
|
@ -193,17 +197,19 @@ SceneOut D3D12FractalSplatPS(FractalSplatVertexOut input)
|
|||
radiosityResident ? saturate(radiosity.validation.x) : 0.0));
|
||||
float3 color = pbrResident ? pbrColor : fallbackColor;
|
||||
float roughness = pbrResident ? saturate(pbr.baseColorRoughMetal.w) : 0.6;
|
||||
float diffuse = 0.32 + 0.50 * starFacing + 0.18 * viewFacing;
|
||||
float diffuse = densityField ? 0.52 + 0.36 * viewFacing : 0.32 + 0.50 * starFacing + 0.18 * viewFacing;
|
||||
float fresnel = pow(saturate(1.0 - viewFacing), 2.2);
|
||||
float3 litColor = color * diffuse + color * 0.18;
|
||||
litColor += radiosityResident ? radiosityColor * (0.24 + reservoirConfidence * 0.48) : 0.0;
|
||||
litColor += lerp(float3(0.015, 0.06, 0.05), float3(0.24, 0.30, 0.20), 1.0 - roughness) * fresnel * 0.48;
|
||||
float opacity = saturate(edgeCoverage * (0.78 + reservoirConfidence * 0.22));
|
||||
litColor += lerp(float3(0.015, 0.06, 0.05), densityField ? float3(0.95, 0.28, 0.08) : float3(0.24, 0.30, 0.20), 1.0 - roughness) * fresnel * (densityField ? 0.72 : 0.48);
|
||||
float opacity = densityField
|
||||
? saturate(edgeCoverage * edgeCoverage * (0.18 + reservoirConfidence * 0.32))
|
||||
: saturate(edgeCoverage * (0.78 + reservoirConfidence * 0.22));
|
||||
|
||||
SceneOut output;
|
||||
output.colorTravel = float4(litColor * opacity, min(input.travel - surfaceZ * input.worldRadius, farDistance + 1.0));
|
||||
output.metadata = float4(FIELD_ID_FRACTAL_SPLAT_BASE, normal);
|
||||
output.control = float4(opacity, reservoirConfidence, saturate((sdfResident ? sdf.centerRadius.w : splat.centerRadius.w) * 40.0), 0.0);
|
||||
output.control = float4(opacity, reservoirConfidence, densityField ? FIELD_ENCODING_DENSITY / 10.0 : saturate((sdfResident ? sdf.centerRadius.w : splat.centerRadius.w) * 40.0), 0.0);
|
||||
output.reservoirGuide = float4(
|
||||
sdfResident ? saturate(sdf.validation.x) : 0.0,
|
||||
pbrResident ? saturate(pbr.validation.x) : 0.0,
|
||||
|
|
|
|||
|
|
@ -200,3 +200,4 @@
|
|||
{"timestamp":"2026-05-21T09:05:00+01:00","topic":"form-appearance-transport-fields","lesson":"The Perfect Machine architecture now treats SDF/PBR/radiosity as the first opaque backend packet slice, not the conceptual layer split. The durable split is Form, Appearance, and Transport. SDF/level-set is one Form encoding for opaque solids; density/extinction/confidence is the Form encoding for flames, smoke, transparent gradients, and uncertain sensor-fusion volumes. PBR is one Appearance encoding; participating media need albedo/emission/phase/absorption/scattering, with Transport owning radiance, emission, and scattering reuse. Do not force flames or Mimir confidence volumes to become fake surfaces before they can enter reservoirs.","files":["docs/perfect-machine-architecture.md","docs/temporal-sdf-gaussian-field.md","docs/temporal-spatial-evidence-reservoir.md","research/rendering/fractal-brush-implementation-roadmap.md","state/map.yaml","state/memory.json"],"source":"user reframed flame IFS and sensor fusion as field-density evidence rather than opaque SDF surfaces"}
|
||||
{"timestamp":"2026-05-21T09:40:00+01:00","topic":"shared-form-reservoir-code","lesson":"The code now matches the Form/Appearance/Transport architecture at the reservoir seam. AquariumFieldLayer and AquariumFieldEncoding live in contracts; TemporalSpatialEvidenceObservation/Sample and FractalProbeSample carry layer/encoding; TemporalSpatialEvidenceReservoir keys tracks by layer+encoding+stable key; FractalProbeReuseValidator rejects mismatched encodings before spatial reuse; Form/SignedDistance lowers through FractalSdfSplat3DCompiler while Form/Density or Form/Extinction lowers through FractalDensitySplat3DCompiler. The packed transparent density splat is 80 bytes to stay stride-aligned with the opaque SDF splat. Do not add a parallel transparent reservoir; extend encodings and lowerings under the same sample/reservoir contract.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Fractal/Lod/FractalProbeSample.cs","src/Aquarium.Engine.Fractal/Lod/FractalDensitySplat3DCompiler.cs","src/Aquarium.Engine.Fractal/Lod/FractalSdfSplat3DCompiler.cs","src/Aquarium.Engine.Fractal/Temporal/TemporalSpatialEvidenceObservation.cs","src/Aquarium.Engine.Fractal/Temporal/TemporalSpatialEvidenceReservoir.cs","src/Aquarium.Engine.Fractal/Lod/FractalGpuReservoirBudgetPlanner.cs","docs/perfect-machine-architecture.md","state/map.yaml","state/memory.json"],"source":"user asked to fix code so one reservoir handles transparent and opaque fields with defensible architecture"}
|
||||
{"timestamp":"2026-05-21T10:05:00+01:00","topic":"aquageo-transparent-form-claims","lesson":"The `.aquageo` DSL now has first-class `density` and `extinction` field claims, and the recursive `flame` primitive emits Density payloads instead of pretending to be height. FractalSummaryBuilder scores Height, SignedDistance, Density, and Extinction as Form contribution. FractalHeightBrushCompiler filters mixed trees to Height payloads for height-field lowering, preserving the invariant that backend compilers lower only the payloads they own.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Fractal/Grammar/FractalDslCompiler.cs","src/Aquarium.Engine.Fractal/Grammar/FractalSummaryBuilder.cs","src/Aquarium.Engine.Fractal/Brushes/FractalHeightBrushCompiler.cs","tests/Aquarium.Engine.Fractal.Tests/FractalDslCompilerTests.cs","tests/Aquarium.Engine.Fractal.Tests/FractalHeightBrushCompilerTests.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","docs/perfect-machine-architecture.md","state/map.yaml","state/memory.json"],"source":"continued code migration after density claims exposed height lowering as a hidden payload router"}
|
||||
{"timestamp":"2026-05-21T10:20:00+01:00","topic":"gpu-field-encoding-tag","lesson":"D3D12FractalReservoirCompute now tags flame-mode splats as Density in an existing material/confidence lane, preserving the 80-byte hot splat stride. D3D12FractalSplatRender branches on the encoding tag for a softer transparent-field visualization while opaque SDF splats keep the existing surface resolve. The receipt harness now reports Form/Appearance/Transport reservoir layers while keeping backend slice names in parentheses. This is field-aware GPU consumption, not full participating-media integration.","files":["src/Aquarium.Engine/Render/Shaders/D3D12FractalReservoirCompute.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12FractalSplatRender.hlsl","tools/Aquarium.Fractal.Receipt/Program.cs","state/map.yaml","state/memory.json"],"source":"continued runtime migration after shared CPU reservoir and DSL field claims were in place"}
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ renderer_state:
|
|||
- The Apophysis/FLAM3 reference subset now has a runtime parser/evaluator boundary: FractalFlameFileParser reads `.flame` xforms with weight, color, affine coefficients, and `linear`/`spherical`/`bubble` variation weights; FractalFlameChaosGame produces deterministic point sets; FractalPointHistogramBuilder produces fixed histogram checksums for parity receipts.
|
||||
- tools/Aquarium.Fractal.Receipt can now run a CPU flame histogram receipt with `--flame`; scripts/fractal-flame-receipt.ps1 emits the default linear/spherical/bubble fixture checksum 0xAEB1C81B under artifacts/fractal-flame-receipts. It can also hash binary PPM renders with `--reference-ppm`; scripts/fractal-flame-reference-render.ps1 drives a local external `flam3-render` through FLAM3's documented env vars and records image-shape/non-black/checksum receipts under artifacts/fractal-flame-reference without vendoring GPL renderer code.
|
||||
- D3D12FractalReservoirCompute has an explicit flame 2D program mode for the proven FLAM3-style subset. FractalGpuProgramCompiler lowers flame rows into packed affine/variation program rows, and tools/Aquarium.Fractal.Receipt can run them with `--program-flame`. Flame mode now keeps 32-byte AquariumPackedFractalFlameState rows in a GPU UAV so touched splats advance persistent chaos-game state instead of replaying from the origin. Local GTX 1070 JWildfire selftest receipt after 8 full-population acquisition frames: 2,000,000 resident splats, 2,000,000 flame states, 2,000,000 first-slice Form/Appearance/Transport reservoirs each, steady 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, 1.011 ms/frame, 988.8 FPS equivalent, 84.85% CPU-slice distribution parity, checksum 0xC633FADC3BD7E5BE.
|
||||
- The live GPU splat packet now carries a Form encoding tag in the existing material/confidence lane without changing the 80-byte stride. Flame-mode compute writes Density encoding; the visible fractal splat pass branches on that encoding for a softer transparent-field resolve while keeping opaque SDF splats on the existing surface path. This is not full volume ray integration, but it keeps the hot path field-aware without adding a parallel transparent buffer.
|
||||
- The first visual parity receipt compares GPU flame splat XY histograms against the CPU flame oracle. With 250,000 GPU readback splats and 1,000,000 CPU reference samples in 128x128 bounds -8,-8,8,8, the mixed flame fixture scores 84.05% distribution parity at frame 1, 84.10% at frame 5, 84.20% at frame 20, and 84.24% after the 60-frame/10-warmup receipt, with cosine similarity around 0.9955. This is a stable sampler score, not proof of learned convergence; visual-error feedback is still future work.
|
||||
- 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.
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@
|
|||
"The local Apophysis/FLAM3 subset parser owns only a small proven flame shape: xform weight/color, affine coefficients, and `linear`, `spherical`, and `bubble` variation weights. `FractalFlameChaosGame` and `FractalPointHistogramBuilder` provide deterministic CPU receipts. External renderer proof stays optional and outside runtime through FLAM3-compatible PPM receipt hashing.",
|
||||
"Use `scripts/fractal-flame-receipt.ps1` for the local CPU flame receipt. The default mixed linear/spherical/bubble fixture uses 8192 samples, 64 burn-in, 64x64 bounds -8,-8,8,8, seed 0x0BADC0DE, and checksum 0xAEB1C81B. Use `scripts/fractal-flame-reference-render.ps1` with a local `flam3-render` executable to produce external PPM image receipts under artifacts/fractal-flame-reference; Aquarium does not vendor Apophysis or FLAM3.",
|
||||
"FractalGpuProgramCompiler can lower the proven FLAM3-style flame subset into GPU program rows for D3D12FractalReservoirCompute's explicit flame 2D program mode. Flame mode owns a 32-byte AquariumPackedFractalFlameState UAV row per resident splat; touched rows advance persistent chaos-game state instead of replaying from the origin. The cache has two phases: full-population acquisition, then budgeted stochastic maintenance. On 2026-05-21 the GTX 1070 ran JWildfire FARender selftest.flame with 2,000,000 splats, 2,000,000 flame states, three 2,000,000-row first-slice Form/Appearance/Transport reservoir layers, 8 full acquisition frames, steady 50,000 splat updates/frame, 15,000 reservoir updates/pass/frame, depth 8, at 1.011 ms/frame / 988.8 FPS equivalent, 84.85% CPU-slice distribution parity, checksum 0xC633FADC3BD7E5BE. Without acquisition, the same steady budget scored only 32.64%; do not confuse a cold persistent cache with a bad sampler.",
|
||||
"The live GPU splat packet carries a Form encoding tag in an existing material/confidence lane so flame-mode compute can mark splats as Density without changing the 80-byte hot stride. D3D12FractalSplatRender branches on that tag for the current transparent-field visualization. This is a field-aware debug/consumption path, not full volume ray integration; do not add a second transparent splat buffer unless a measured resolve need beats the shared packet invariant.",
|
||||
"The first visual parity metric compares GPU flame splat XY histograms against the local CPU flame oracle. With 250,000 GPU readback splats, 1,000,000 CPU reference samples, 128x128 bounds -8,-8,8,8, and the mixed FLAM3-style fixture, distribution score is 84.05% at frame 1, 84.10% at frame 5, 84.20% at frame 20, and 84.24% after the 60-frame/10-warmup receipt; cosine similarity stays about 0.9955. This is high distribution similarity but not learned convergence: the current reservoir path initializes splats and stochastically replaces them, without visual-error feedback or ReSTIR/MIS target correction yet.",
|
||||
"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.",
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ var importReportPath = WriteProgramFlameImportReport(options, receiptStamp);
|
|||
Console.WriteLine("=== Aquarium Perfect Machine GPU Splat Receipt ===");
|
||||
Console.WriteLine($"adapter: {receipt.Adapter}");
|
||||
Console.WriteLine($"splats: {receipt.SplatCount:N0}");
|
||||
Console.WriteLine($"sdf reservoirs: {receipt.SdfReservoirCount:N0}");
|
||||
Console.WriteLine($"pbr reservoirs: {receipt.PbrReservoirCount:N0}");
|
||||
Console.WriteLine($"radiosity reservoirs: {receipt.RadiosityReservoirCount:N0}");
|
||||
Console.WriteLine($"form reservoirs (SDF backend slice): {receipt.SdfReservoirCount:N0}");
|
||||
Console.WriteLine($"appearance reservoirs (PBR backend slice): {receipt.PbrReservoirCount:N0}");
|
||||
Console.WriteLine($"transport reservoirs (radiosity backend slice): {receipt.RadiosityReservoirCount:N0}");
|
||||
Console.WriteLine($"flame states: {receipt.FlameStateCount:N0}");
|
||||
Console.WriteLine($"ifs program transforms: {receipt.ProgramTransformCount:N0}");
|
||||
Console.WriteLine($"program mode: {DescribeProgramMode(receipt.ProgramMode)}");
|
||||
|
|
@ -49,7 +49,7 @@ Console.WriteLine($"candidates/pass: {receipt.CandidatesPerPass}");
|
|||
Console.WriteLine($"reservoir updates/pass/frame: {receipt.ReservoirUpdatesPerPass:N0}");
|
||||
Console.WriteLine($"reservoir full-coverage frames: {receipt.ReservoirFullCoverageFrames:0.0}");
|
||||
Console.WriteLine($"frames: {receipt.MeasuredFrames}");
|
||||
Console.WriteLine("shader: D3D12 compute, independent GPU-resident SDF/PBR/radiosity reservoir passes");
|
||||
Console.WriteLine("shader: D3D12 compute, independent GPU-resident Form/Appearance/Transport reservoir passes");
|
||||
Console.WriteLine($"packed bytes/splat: {receipt.BytesPerSplat}");
|
||||
Console.WriteLine($"packed bytes/reservoir: {receipt.BytesPerReservoir}");
|
||||
Console.WriteLine($"packed bytes/flame state: {receipt.BytesPerFlameState}");
|
||||
|
|
|
|||
Loading…
Reference in a new issue