diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12TubeField.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12TubeField.hlsl index 6354992..15b457c 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12TubeField.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12TubeField.hlsl @@ -203,17 +203,18 @@ float3 TubePoint(uint logicalColumn, float x) float3(0.0, value * tubeAmplitude.y, 0.0); } -TubeFieldVertex MakeTubeVertex(float3 position, float3 previous, float3 start, float3 end, float3 next, float side, float endpointT, float capSign, float value, float3 rampColor, uint logicalColumn, float x0, float x1) +TubeFieldVertex MakeTubeVertex(float3 position, float3 previous, float3 start, float3 end, float3 next, float side, float endpointT, float capSign, float v0, float v1, float3 rampColor, uint logicalColumn, float x0, float x1) { TubeFieldVertex vertex; - float radius = max(tubeMaterial.x + value * tubeMaterial.y, 0.0001); + float radius0 = max(tubeMaterial.x + v0 * tubeMaterial.y, 0.0001); + float radius1 = max(tubeMaterial.x + v1 * tubeMaterial.y, 0.0001); vertex.position = position; vertex.segmentStart = start; vertex.segmentEnd = end; vertex.previousPoint = previous; vertex.nextPoint = next; vertex.shapeData = float4(side, endpointT, capSign, 0.0); - vertex.radiusData = float4(radius, radius, tubeMaterial.w, 0.0); + vertex.radiusData = float4(radius0, radius1, tubeMaterial.w, 0.0); vertex.color = float4(rampColor, tubeMaterial.z); vertex.material = float4(max(tubeDispatch.x, 0.0), tubeMaterial.z, 4.0, 0.0001); vertex.tubeData = float4((float)logicalColumn, x0, x1, tubeDraw.z); @@ -227,11 +228,11 @@ TubeFieldSegment MakeTubeSegment(float3 previous, float3 start, float3 end, floa float radius1 = max(tubeMaterial.x + v1 * tubeMaterial.y, 0.0001); segment.previousRadius = float4(previous, radius0); segment.startRadius = float4(start, radius0); - segment.endFeather = float4(end, tubeMaterial.w); - segment.nextAlpha = float4(next, tubeMaterial.z); + segment.endFeather = float4(end, radius1); + segment.nextAlpha = float4(next, radius1); segment.color0 = float4(rampColor0, v0); segment.color1 = float4(rampColor1, v1); - segment.material = float4(max(tubeDispatch.x, 0.0), tubeMaterial.z, 4.0, 0.0001); + segment.material = float4(max(tubeDispatch.x, 0.0), tubeMaterial.z, 4.0, tubeMaterial.w); segment.tubeData = float4((float)logicalColumn, x0, x1, tubeDraw.z); return segment; } @@ -282,10 +283,10 @@ void D3D12TubeFieldExpandCS(uint3 dispatchThreadId : SV_DispatchThreadID) uint vertexBase = globalSegment * 4u; uint indexBase = globalSegment * 6u; TubeFieldSegments[globalSegment] = MakeTubeSegment(previous, start, end, next, v0, v1, rampColor0, rampColor1, logicalColumn, x0, x1); - TubeFieldVertices[vertexBase + 0u] = MakeTubeVertex(start, previous, start, end, next, -1.0, 0.0, -1.0, v0, rampColor0, logicalColumn, x0, x1); - TubeFieldVertices[vertexBase + 1u] = MakeTubeVertex(start, previous, start, end, next, 1.0, 0.0, -1.0, v0, rampColor0, logicalColumn, x0, x1); - TubeFieldVertices[vertexBase + 2u] = MakeTubeVertex(end, previous, start, end, next, -1.0, 1.0, 1.0, v1, rampColor1, logicalColumn, x0, x1); - TubeFieldVertices[vertexBase + 3u] = MakeTubeVertex(end, previous, start, end, next, 1.0, 1.0, 1.0, v1, rampColor1, logicalColumn, x0, x1); + TubeFieldVertices[vertexBase + 0u] = MakeTubeVertex(start, previous, start, end, next, -1.0, 0.0, -1.0, v0, v1, rampColor0, logicalColumn, x0, x1); + TubeFieldVertices[vertexBase + 1u] = MakeTubeVertex(start, previous, start, end, next, 1.0, 0.0, -1.0, v0, v1, rampColor0, logicalColumn, x0, x1); + TubeFieldVertices[vertexBase + 2u] = MakeTubeVertex(end, previous, start, end, next, -1.0, 1.0, 1.0, v0, v1, rampColor1, logicalColumn, x0, x1); + TubeFieldVertices[vertexBase + 3u] = MakeTubeVertex(end, previous, start, end, next, 1.0, 1.0, 1.0, v0, v1, rampColor1, logicalColumn, x0, x1); TubeFieldIndices[indexBase + 0u] = vertexBase + 0u; TubeFieldIndices[indexBase + 1u] = vertexBase + 1u; TubeFieldIndices[indexBase + 2u] = vertexBase + 2u; @@ -719,9 +720,9 @@ bool evaluateTubeFieldSegmentCandidate(uint segmentIndex, float2 pixel, out Tube } float startRadiusPx = splineRadiusToPixels(segment.startRadius.w, startProjected.w); - float endRadiusPx = splineRadiusToPixels(segment.previousRadius.w, endProjected.w); + float endRadiusPx = splineRadiusToPixels(segment.endFeather.w, endProjected.w); float previousRadiusPx = splineRadiusToPixels(segment.previousRadius.w, previousProjected.w); - float nextRadiusPx = splineRadiusToPixels(segment.startRadius.w, nextProjected.w); + float nextRadiusPx = splineRadiusToPixels(segment.nextAlpha.w, nextProjected.w); if (!finite1(startRadiusPx) || !finite1(endRadiusPx) || !finite1(previousRadiusPx) || !finite1(nextRadiusPx)) { return false; @@ -758,9 +759,9 @@ bool evaluateTubeFieldSegmentCandidate(uint segmentIndex, float2 pixel, out Tube normalPx = nextNormal; } - float aa = max(0.75, radiusPx * max(segment.endFeather.w, 0.0)); + float aa = max(0.75, radiusPx * max(segment.material.w, 0.0)); float coverage = 1.0 - smoothstep(0.0, aa, sdf); - float alpha = saturate(segment.nextAlpha.w * coverage); + float alpha = saturate(segment.material.y * coverage); if (!finite1(sdf) || !finite1(radiusPx) || !finite2(normalPx) || alpha <= 0.004) { return false; @@ -778,7 +779,7 @@ bool evaluateTubeFieldSegmentCandidate(uint segmentIndex, float2 pixel, out Tube float3 tubeNormal = normalize(((right * normalPx.x) - (up * normalPx.y)) * rimBlend - ray * frontBlend); float normalFacing = saturate(-dot(ray, tubeNormal)); float glowFacing = pow(normalFacing, max(segment.material.z, 0.0001)); - float alphaFacing = pow(normalFacing, max(segment.material.w, 0.0001)); + float alphaFacing = 1.0; float claimCoverage = saturate(alpha * alphaFacing); if (claimCoverage <= 0.004) { @@ -962,7 +963,7 @@ void D3D12TubeFieldRestirBinSegmentsCS(uint3 dispatchThreadId : SV_DispatchThrea float radiusPx = max( splineRadiusToPixels(segment.startRadius.w, startProjected.w), - splineRadiusToPixels(segment.previousRadius.w, endProjected.w)); + splineRadiusToPixels(segment.endFeather.w, endProjected.w)); radiusPx = min(radiusPx, 256.0); if (!finite1(radiusPx)) { diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 2ab31a5..d09d27c 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -275,3 +275,4 @@ {"lesson":"The first TubeField ReSTIR cut replaces per-fragment reservoir scatter locks with pixel-owned compute reservoirs. TubeField expansion now emits reusable segment records with baked geometry/material endpoints; D3D12 bins active segments into screen tiles once per frame, streams a small fixed candidate set into a per-pixel initial reservoir, combines previous-frame reservoirs through reprojection, performs spatial neighbor reuse, and exports the selected sample into the shared field-reservoir candidate buffer for canonical scene resolve. Runtime shader compilation and Mimir synthetic spectrum execution passed; frame timing settles around the vsync band after ramp-up, but local window capture was unreliable and should not be treated as visual QA evidence.","timestamp":"2026-05-28T16:17:56+01:00","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12TubeField.hlsl","state/map.yaml","state/evidence.jsonl"],"source":"TubeField ReSTIR ownership rebuild","topic":"tubefield-restir-pixel-owned-reservoir"} {"lesson":"Reservoir history update and reuse moved out of the presentation pixel shader into a shared D3D12 compute pass. The pass reads canonical scene lanes, shared field candidate rows, and ping-ponged structured history rows; writes the next four history rows per pixel; and emits a resolved HDR field texture consumed by bloom and final presentation. The presentation shader no longer writes reservoir history, so it cannot become a hidden TAA owner. Fensalir and Mimir builds passed, the Mimir spectrum upload smoke passed, and a synthetic spectrum headless capture rendered through the compute-owned reservoir path.","timestamp":"2026-05-28T17:05:00+01:00","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","docs/temporal-spatial-evidence-reservoir.md","docs/perfect-machine-architecture.md","state/map.yaml"],"source":"user selected full structured-buffer reservoir path","topic":"reservoir-history-compute-owner"} {"lesson":"TubeField ReSTIR reuse no longer imports neighbor-pixel coverage directly. Temporal and spatial reuse now re-evaluate a shifted reservoir's selected segment at the receiving pixel before combination, and TubeField exports the four best deterministic current pixel candidates into the shared field-reservoir rows. This removes the wrong stochastic authority from opaque primary visibility, though the spectrum dashboard still reads visually busy because it draws many age-column tubes through generated segment proxies. Verified with Fensalir/Mimir builds, --mimir-spectrum-upload-smoke, and headless capture artifacts/runtime/reservoir-deterministic-top4-spectrum.png.","timestamp":"2026-05-28T17:35:00+01:00","files":["src/Aquarium.Engine/Render/Shaders/D3D12TubeField.hlsl","state/map.yaml","state/evidence.jsonl"],"source":"noisy reservoir smoke diagnosis","topic":"tubefield-shifted-reuse-top4-export"} +{"lesson":"The many-spline TubeField quality path stays on cheap segmented proxies. Segment continuity now fixes data ownership inside that model: every generated proxy vertex carries the same start/end radius pair, and the compute segment packet stores true start/end radii plus feather/alpha separately. ReSTIR candidate evaluation and tile binning now use the true end radius instead of silently reusing the start radius, reducing join disagreement without spline-wide SDF evaluation. Verified with Fensalir/Mimir builds, --mimir-spectrum-upload-smoke, and headless capture artifacts/runtime/tubefield-cheap-continuity-spectrum.png.","timestamp":"2026-05-28T17:55:00+01:00","files":["src/Aquarium.Engine/Render/Shaders/D3D12TubeField.hlsl","state/map.yaml","state/evidence.jsonl"],"source":"user chose many-hundreds-splines cheap segment continuity path","topic":"tubefield-cheap-segment-continuity"} diff --git a/state/map.yaml b/state/map.yaml index 06b9dda..9241ccb 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -220,7 +220,10 @@ next_actions: reservoirs only after re-evaluating the selected segment at the receiving pixel. TubeField exports the four best deterministic current pixel candidates into the shared field-reservoir candidate rows so opaque primary - visibility is not a single stochastic winner. The old TubeField raster path + visibility is not a single stochastic winner. The cheap segment model now + keeps a consistent start/end radius pair across each generated proxy and + stores the true end radius in the compute segment packet, so adjacent + capsules agree at joins without a heavier spline-wide SDF search. The old TubeField raster path remains compiled as a diagnostic/generated-mesh reference, but the live scene path calls the compute ReSTIR export instead of letting raster fragments arbitrate