From 681dee5f1ddb8c86cfc6f2ed9b8b5155f10f14be Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 18 May 2026 12:19:23 +0100 Subject: [PATCH] Thread fractal detail through temporal control --- src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl | 10 +++++++--- .../Render/Shaders/D3D12SdfCommon.hlsli | 1 + src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli | 3 ++- src/Aquarium.Epiphany/Shaders/D3D12BodyAgent.hlsl | 1 + src/Aquarium.Epiphany/Shaders/D3D12CursorBody.hlsl | 1 + src/Aquarium.Epiphany/Shaders/D3D12EyesAgent.hlsl | 1 + src/Aquarium.Epiphany/Shaders/D3D12FaceAgent.hlsl | 1 + src/Aquarium.Epiphany/Shaders/D3D12HandsAgent.hlsl | 1 + .../Shaders/D3D12ImaginationAgent.hlsl | 1 + src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl | 1 + src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl | 1 + src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl | 1 + src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl | 1 + src/Aquarium.Zyphos/Shaders/D3D12ZyphosStar.hlsl | 1 + src/Aquarium.Zyphos/Shaders/D3D12ZyphosUmbros.hlsl | 1 + state/evidence.jsonl | 1 + state/memory.json | 1 + 17 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl index e4c85b3..a4627fd 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl @@ -328,6 +328,7 @@ ResolveOut D3D12ResolvePS(VertexOut input) float3 currentNormal = currentMetadata.yzw; float currentCoverage = saturate(currentControl.x); float currentStepRatio = saturate(currentControl.y); + float currentTemporalDetail = saturate(currentControl.z); float historyWeight = 0.0; float historyAge = 0.0; @@ -348,6 +349,7 @@ ResolveOut D3D12ResolvePS(VertexOut input) float previousTravel = previous.a; float3 previousNormal = previousMetadata.yzw; float previousCoverage = saturate(previousControl.x); + float previousTemporalDetail = saturate(previousControl.z); float previousHistoryAge = max(previousControl.w, 0.0); float expectedPreviousTravel = distance(previousCameraPosition, previousWorldPosition); float travelDelta = abs(previousTravel - expectedPreviousTravel); @@ -372,8 +374,10 @@ ResolveOut D3D12ResolvePS(VertexOut input) colorWeight = max(colorWeight, hotSdfCurrent * 0.82); float coverageWeight = smoothstep(0.02, 0.55, currentCoverage); float coverageContinuityWeight = 1.0 - smoothstep(0.10, 0.50, abs(previousCoverage - currentCoverage)); + float temporalDetailWeight = 1.0 - smoothstep(0.08, 0.45, abs(previousTemporalDetail - currentTemporalDetail)); + temporalDetailWeight = max(temporalDetailWeight, 1.0 - smoothstep(0.02, 0.12, max(previousTemporalDetail, currentTemporalDetail))); float historyConfidence = smoothstep(0.0, 6.0, previousHistoryAge); - float validationWeight = travelWeight * colorWeight * fieldWeight * normalWeight * coverageWeight * coverageContinuityWeight; + float validationWeight = travelWeight * colorWeight * fieldWeight * normalWeight * coverageWeight * coverageContinuityWeight * temporalDetailWeight; historyColor = clampedHistory; historyWeight = 0.82 * lerp(0.35, 1.0, historyConfidence) * validationWeight; @@ -404,7 +408,7 @@ ResolveOut D3D12ResolvePS(VertexOut input) } else if (renderDebugMode >= 4.5 && renderDebugMode < 5.5) { - finalColor = saturate(float3(currentCoverage, currentStepRatio, 0.0)); + finalColor = saturate(float3(currentCoverage, currentStepRatio, currentTemporalDetail)); } else if (renderDebugMode >= 5.5 && renderDebugMode < 6.5) { @@ -432,6 +436,6 @@ ResolveOut D3D12ResolvePS(VertexOut input) output.finalColor = float4(finalColor, 1.0); output.historyColor = float4(resolved, currentTravel); output.historyMetadata = currentMetadata; - output.historyControl = float4(currentControl.xy, 0.0, combinedHistoryAge); + output.historyControl = float4(currentControl.xyz, combinedHistoryAge); return output; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli b/src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli index 3ea29cd..a7c0091 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli +++ b/src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli @@ -82,6 +82,7 @@ struct SdfSurface float metallic; float roughness; float3 emission; + float temporalDetail; }; void cameraBasis(float3 camera, float3 target, out float3 forward, out float3 right, out float3 up) diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli b/src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli index dad778e..9c626fa 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli +++ b/src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli @@ -71,6 +71,7 @@ bool traceSdf(float3 origin, float3 direction, int sdfIndex, out float travel, o surface.metallic = 0.0; surface.roughness = 0.0; surface.emission = 0.0; + surface.temporalDetail = 0.0; float previousTravel = travel; float previousDistance = sdfDistance(origin + direction * travel, sdfIndex); float maxStep = max(sdfObject.centerRadius.w * SDF_TRACE_MAX_STEP_RADIUS_SCALE, SDF_TRACE_MIN_STEP); @@ -127,7 +128,7 @@ SceneOut D3D12SdfProxyPS(SdfObjectProxyVertexOut input) SceneOut output; output.colorTravel = float4(shadeSdf(uv, travel, p, normal, sdfIndex, surface), min(travel, farDistance + 1.0)); output.metadata = float4(fieldId, normal); - output.control = float4(1.0, stepCount / (float)SDF_TRACE_STEPS, 0.0, 0.0); + output.control = float4(1.0, stepCount / (float)SDF_TRACE_STEPS, saturate(surface.temporalDetail), 0.0); output.depth = saturate(travel / max(farDistance, 0.001)); return output; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12BodyAgent.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12BodyAgent.hlsl index b0c1a48..1364f15 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12BodyAgent.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12BodyAgent.hlsl @@ -21,6 +21,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = 0.56; surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)); + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12CursorBody.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12CursorBody.hlsl index d6a91ec..a464023 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12CursorBody.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12CursorBody.hlsl @@ -123,6 +123,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = isCalyx > 0.5 ? 0.46 : 0.22; surface.emission = surface.baseColor * (isCalyx > 0.5 ? 0.05 : 0.56); + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12EyesAgent.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12EyesAgent.hlsl index 0f457e8..6ccc1ee 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12EyesAgent.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12EyesAgent.hlsl @@ -21,6 +21,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = 0.28; surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) + surface.baseColor * 0.06; + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12FaceAgent.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12FaceAgent.hlsl index 2eee700..856d4a8 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12FaceAgent.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12FaceAgent.hlsl @@ -21,6 +21,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = 0.44; surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) + surface.baseColor * 0.04; + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12HandsAgent.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12HandsAgent.hlsl index 00ad336..b48d4e3 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12HandsAgent.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12HandsAgent.hlsl @@ -21,6 +21,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = 0.50; surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) + surface.baseColor * 0.035; + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12ImaginationAgent.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12ImaginationAgent.hlsl index 7e21155..52e1a72 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12ImaginationAgent.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12ImaginationAgent.hlsl @@ -168,6 +168,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) + rimColor * isRim * (0.55 + sdfObject.state.y * 0.20) + sparkColor * (isSpark * 1.35 + isTendril * 0.85) + shadowColor * isShadow * 0.015; + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl index fe52d6d..36aa96f 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl @@ -363,6 +363,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) + pearlColor * pearlMask * 0.040 + gold * seamMask * 0.090 + emberColor * emberMask * (3.2 + heartbeat * 1.1 + domain.pressure * 0.8); + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl index ed00c8a..62ee3f2 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl @@ -151,6 +151,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.emission = selfLight * (isGate * 0.08) + stripeColor * isStripe * (0.92 + sdfObject.state.y * 0.16) + gateColor * isGate * (0.42 + sdfObject.state.y * 0.12); + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl b/src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl index 1abf433..30b56c1 100644 --- a/src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl +++ b/src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl @@ -184,6 +184,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) + findingColor * findingMask * (0.24 + confidence * 0.50) + riskColor * riskMask * (0.36 + risk * 0.95) + riskColor * fractureMask * (0.18 + risk * 0.58); + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl b/src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl index 60d8fa6..999b21f 100644 --- a/src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl +++ b/src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl @@ -247,6 +247,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = lerp(0.34, 0.84, land); surface.emission = 0.0; + surface.temporalDetail = saturate(authoredMaterial * 3.0); return surface; } diff --git a/src/Aquarium.Zyphos/Shaders/D3D12ZyphosStar.hlsl b/src/Aquarium.Zyphos/Shaders/D3D12ZyphosStar.hlsl index a2d77a8..04e63c4 100644 --- a/src/Aquarium.Zyphos/Shaders/D3D12ZyphosStar.hlsl +++ b/src/Aquarium.Zyphos/Shaders/D3D12ZyphosStar.hlsl @@ -38,6 +38,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = 0.72; surface.emission = surface.baseColor * lerp(3.8, 7.5, hot); + surface.temporalDetail = 0.0; return surface; } diff --git a/src/Aquarium.Zyphos/Shaders/D3D12ZyphosUmbros.hlsl b/src/Aquarium.Zyphos/Shaders/D3D12ZyphosUmbros.hlsl index 6fbe93a..8dda1c3 100644 --- a/src/Aquarium.Zyphos/Shaders/D3D12ZyphosUmbros.hlsl +++ b/src/Aquarium.Zyphos/Shaders/D3D12ZyphosUmbros.hlsl @@ -84,6 +84,7 @@ SdfSurface sdfSurface(float3 p, int sdfIndex) surface.metallic = 0.0; surface.roughness = 0.92; surface.emission = 0.0; + surface.temporalDetail = 0.0; return surface; } diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 1261295..fabc1d9 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -147,3 +147,4 @@ {"timestamp":"2026-05-18T09:45:34+01:00","topic":"everything-is-a-fractal-recursive-domains","lesson":"The Zyphos world patch now expresses the 'everything is a fractal' idea as explicit recursive domains: planet -> lat/long -> continent -> forest -> tree -> leaf and continent -> coast -> pebble field, plus Umbros -> crater province -> boulder field -> pebble field. The flattened stress backend emits 58 shaped brush claims into a 64-entry D3D12 table, while SDF shaders add bounded leaf/pebble material-relief clusters so the recursion is visible even before true recursive residency and LOD caching exist.","files":["src/Aquarium.Zyphos/Worlds/zyphos-first-fractal-terrain.aquageo","src/Aquarium.Zyphos/ZyphosSpatialDomainCatalog.cs","src/Aquarium.Zyphos/ZyphosRuntime.cs","src/Aquarium.Engine/Render/Features/D3D12HeightFieldBrushConstants.cs","src/Aquarium.Engine/Render/Shaders/D3D12HeightField.hlsl","src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl","src/Aquarium.Zyphos/Shaders/D3D12ZyphosUmbros.hlsl","tests/Aquarium.Engine.Fractal.Tests/ZyphosCameraComposerTests.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosSpatialDomainCatalogTests.cs"],"source":"user asked to see recursive domains everywhere, from continent-scale detail down to pebble, forests down to leaf"} {"timestamp":"2026-05-18T09:58:37+01:00","topic":"zyphos-visible-sun-and-domain-zoom","lesson":"The primary star cannot remain only an SDF light if users need spatial orientation; it is now a rendered SDF object with emission/corona and a Solar navigation target. Camera zoom limits are now derived from the selected domain pose instead of a global 8-unit floor, so leaf and pebble domains can be inspected at their own scale while broad orbital domains still retain safe maximum framing.","files":["src/Aquarium.Zyphos/ZyphosRenderPlan.cs","src/Aquarium.Zyphos/ZyphosSceneBuilder.cs","src/Aquarium.Zyphos/Shaders/D3D12ZyphosStar.hlsl","src/Aquarium.Zyphos/ZyphosCameraComposer.cs","src/Aquarium.Zyphos/ZyphosRuntime.cs","src/Aquarium.Zyphos/ZyphosSpatialDomainCatalog.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosCameraComposerTests.cs"],"source":"user asked where the sun is and why zoom cannot reach the cool small features"} {"lesson":"The first live bridge from the fractal architecture into Zyphos SDF rendering is material/detail, not traced form: .aquageo now preserves multiple tile roots, height brush packets carry cube-tile face/level/x/y metadata, D3D12 binds that packet table into the SDF pass, and the planet shader evaluates authored brushes in cube-face tile space after hit. Evaluating all authored brushes inside sdfDistance was tested and cut because it pushed the live frame toward 50-100 ms; traced geometry needs selected-cut/resident packet policy first.","timestamp":"2026-05-18T11:28:00+01:00","files":["src/Aquarium.Engine.Fractal/Grammar/FractalDslCompiler.cs","src/Aquarium.Engine.Fractal/Brushes/FractalHeightBrushCompiler.cs","src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","src/Aquarium.Engine/Render/Features/D3D12HeightFieldBrushConstants.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl","research/rendering/fractal-brush-implementation-roadmap.md"],"source":"user pointed out the renderer was only a pile of legos and ordered the real machine to be built","topic":"zyphos-aquageo-tile-packet-sdf-bridge"} +{"timestamp":"2026-05-18T12:22:00+01:00","topic":"fractal-temporal-detail-control","lesson":"Fractal cache influence now has a first TAA-facing lane. SdfSurface carries temporalDetail, SDF proxy writes it into scene-control.z, D3D12Post validates history continuity against the current and previous temporalDetail signal, and history-control.z preserves it across frames. Zyphos feeds this from authored cube-face brush material influence; other SDFs explicitly emit zero until they gain cache-owned detail.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl","src/Aquarium.Epiphany/Shaders"],"source":"user said to weave the stochastic fractal cache into TAA buffers"} diff --git a/state/memory.json b/state/memory.json index c7554e5..76a8186 100644 --- a/state/memory.json +++ b/state/memory.json @@ -82,6 +82,7 @@ "Zyphos fractal stress data should keep authored topology richer than the first renderer backend: both Zyphos and Umbros expose lat/long, surface, object-scale, and cube-tile domains in `.aquageo`, with explicit continent/forest/tree/leaf/coast/pebble and crater/boulder/pebble recursion. The current D3D12 height-field stress table uploads 64 shaped 2D brushes and the SDF planet shaders carry separate cheap bounded quadtree-style relief.", "The `.aquageo` compiler must preserve each tile declaration as its own ownership-tree node. Collapsing every claim under the final tile makes the authored multi-domain world a lie even if the brush count looks impressive.", "Zyphos passes cube-tile domain metadata through height brush packets and binds those packets into the SDF pass. The planet shader may use authored brush packets for post-hit material/detail evaluation; traced geometry must wait for selected-cut/resident packet policy so SDF distance loops do not evaluate every brush at every step.", + "Temporal resolve has a cache-facing detail lane: SdfSurface.temporalDetail writes through scene-control.z into history-control.z, and D3D12Post reduces history confidence when current and previous temporal detail disagree. Use this lane for stochastic fractal/cache stability signals, not as geometry authority.", "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 actionable fractal brush roadmap lives in research/rendering/fractal-brush-implementation-roadmap.md. Start with the first work packet: add Aquarium.Engine.Fractal and tests, cube-face/tile key types, identity and tangent projection candidates, an area distortion sampler, face-edge tests, and a projection report before touching recursive detail."