Add planetary topology and debug evidence
This commit is contained in:
parent
f98a37d348
commit
0e6a30eeb5
5 changed files with 133 additions and 6 deletions
|
|
@ -319,6 +319,10 @@ Topology probes cover all twelve cube edges, all eight corners, sibling and
|
|||
parent/child neighbors, independent request order, eviction, and page-border
|
||||
overlap at several levels.
|
||||
|
||||
The root-page GPU topology probe groups canonical spherical boundary samples
|
||||
and verifies all `12 * (9 - 2) = 84` non-corner edge groups plus all eight
|
||||
three-face corners within `1e-5`.
|
||||
|
||||
Timeline probes cover direct load, orbital descent, cube-edge crossing,
|
||||
transition midpoint and arrival, missing-page fallback, page arrival, eviction,
|
||||
regeneration, reload, and field-version change.
|
||||
|
|
@ -327,6 +331,20 @@ Visible debug views expose face/tile/level, residency, field version, active
|
|||
wavelengths, height bounds, tangent gradient, final normal, ridge/gully masks,
|
||||
parent residual blend, direct-minus-page error, and cross-edge discontinuity.
|
||||
|
||||
Patch-native runtime modes currently provide:
|
||||
|
||||
- mode 22: selected face, deepest level, and residual blend;
|
||||
- mode 23: sampled height, maximum slope, and unresolved/error bound;
|
||||
- mode 24: refined raster normal;
|
||||
- mode 25: ridge, gully, and residual blend;
|
||||
- mode 26: cube-edge proximity, cross-edge height delta, and missing-side
|
||||
residency.
|
||||
|
||||
The direct-minus-page comparison is numerically covered by GPU readback but is
|
||||
not yet published as a visible runtime projection. Field version and wavelength
|
||||
identity are available in page metadata/capacity logs but likewise need a
|
||||
pixel-visible lowering before the debug requirement is complete.
|
||||
|
||||
## Performance questions
|
||||
|
||||
- How many terrain evaluations occur per ray and resolved pixel?
|
||||
|
|
@ -344,8 +362,9 @@ Measure the actual visible path.
|
|||
Finish the raster-patch proof before expanding the quadtree or polishing the
|
||||
surface:
|
||||
|
||||
1. Audit every numerical, topology, timeline, and visible-debug requirement
|
||||
against authoritative tests, captures, and runtime source.
|
||||
1. Publish a debug comparison surface for direct-minus-page error, field
|
||||
version, and active wavelength identity rather than leaving them only in
|
||||
tests and logs.
|
||||
2. Compare the four-step page-backed hit against the direct CPU/GPU oracle at
|
||||
patch interiors, silhouettes, cube edges, and transition midpoints.
|
||||
3. Complete the patch-stage compiler run and record its result separately from
|
||||
|
|
|
|||
|
|
@ -61,6 +61,32 @@ bool zyTrySampleErosionPage(float3 dir, out float4 heightGradient, out float2 ma
|
|||
return found;
|
||||
}
|
||||
|
||||
bool zyTerrainDeepestPageEvidence(
|
||||
float3 dir,
|
||||
out ZyPlanetPageMetadata selectedMetadata,
|
||||
out ZyPlanetPageSummary selectedSummary,
|
||||
out float4 selectedHeightGradient,
|
||||
out float2 selectedMasks)
|
||||
{
|
||||
selectedMetadata=(ZyPlanetPageMetadata)0;
|
||||
selectedSummary=(ZyPlanetPageSummary)0;
|
||||
selectedHeightGradient=0.0;
|
||||
selectedMasks=0.0;
|
||||
float selectedLevel=-1.0;
|
||||
int pageCount=min((int)zy_planet_page_set[0].state.x,64);
|
||||
[loop] for(int pageIndex=0;pageIndex<pageCount;pageIndex++)
|
||||
{
|
||||
float2 local; ZyPlanetPageMetadata metadata=zy_planet_page_metadata[pageIndex];
|
||||
ZyPlanetPageSummary summary=zy_planet_page_summary[pageIndex];
|
||||
if(metadata.address.y<selectedLevel||summary.metadata.w<=0.5||!zyTerrainPageLocal(dir,metadata,local))continue;
|
||||
selectedLevel=metadata.address.y;
|
||||
selectedMetadata=metadata;
|
||||
selectedSummary=summary;
|
||||
zySampleErosionPage(pageIndex,local,selectedHeightGradient,selectedMasks);
|
||||
}
|
||||
return selectedLevel>=0.0;
|
||||
}
|
||||
|
||||
float zyTerrainConservativeDistanceScale(float3 dir)
|
||||
{
|
||||
float erosionSlope=0.0; int pageCount=min((int)zy_planet_page_set[0].state.x,64);
|
||||
|
|
|
|||
|
|
@ -54,8 +54,33 @@ ZyPatchSceneOut D3D12ZyphosTerrainPatchPS(ZyPatchVertexOut input)
|
|||
float3 normal=cross(ddy(p),ddx(p));
|
||||
if(!all(isfinite(normal))||dot(normal,normal)<1.0e-10)normal=radial; else normal=normalize(normal);
|
||||
if(dot(normal,cameraPosition-p)<0.0)normal=-normal;
|
||||
float3 terrainDir=zyPlanetDir(p-planet.centerRadius.xyz,planet);
|
||||
ZyPlanetPageMetadata debugMetadata; ZyPlanetPageSummary debugSummary; float4 debugHeightGradient; float2 debugMasks;
|
||||
bool hasDebugPage=zyTerrainDeepestPageEvidence(terrainDir,debugMetadata,debugSummary,debugHeightGradient,debugMasks);
|
||||
float3 debugColor=0.0;
|
||||
if(renderDebugMode>=21.5&&renderDebugMode<22.5)
|
||||
debugColor=hasDebugPage?float3(debugMetadata.address.x/5.0,debugMetadata.address.y/5.0,saturate(debugMetadata.state.y)):float3(1,0,1);
|
||||
else if(renderDebugMode>=22.5&&renderDebugMode<23.5)
|
||||
debugColor=hasDebugPage?float3(saturate(0.5+debugHeightGradient.x*2.0),saturate(debugSummary.bounds.z*0.1),saturate(debugSummary.bounds.w*10.0)):float3(1,0,1);
|
||||
else if(renderDebugMode>=23.5&&renderDebugMode<24.5)
|
||||
debugColor=abs(normal);
|
||||
else if(renderDebugMode>=24.5&&renderDebugMode<25.5)
|
||||
debugColor=hasDebugPage?float3(saturate(debugMasks),saturate(debugMetadata.state.y)):float3(1,0,1);
|
||||
else if(renderDebugMode>=25.5&&renderDebugMode<26.5)
|
||||
{
|
||||
float3 absoluteDirection=abs(terrainDir);
|
||||
float dominant=max(absoluteDirection.x,max(absoluteDirection.y,absoluteDirection.z));
|
||||
float second=absoluteDirection.x+absoluteDirection.y+absoluteDirection.z-dominant-min(absoluteDirection.x,min(absoluteDirection.y,absoluteDirection.z));
|
||||
float3 dominantAxis=absoluteDirection.x>=absoluteDirection.y&&absoluteDirection.x>=absoluteDirection.z?float3(sign(terrainDir.x),0,0):absoluteDirection.y>=absoluteDirection.z?float3(0,sign(terrainDir.y),0):float3(0,0,sign(terrainDir.z));
|
||||
float3 secondaryAxis=absoluteDirection.x<dominant&&absoluteDirection.x>=min(absoluteDirection.y,absoluteDirection.z)?float3(sign(terrainDir.x),0,0):absoluteDirection.y<dominant&&absoluteDirection.y>=min(absoluteDirection.x,absoluteDirection.z)?float3(0,sign(terrainDir.y),0):float3(0,0,sign(terrainDir.z));
|
||||
float3 crossDirection=normalize(secondaryAxis-dominantAxis*dot(secondaryAxis,terrainDir));
|
||||
float4 sideA,sideB; float2 sideMasks; bool hasA=zyTrySampleErosionPage(normalize(terrainDir-crossDirection*0.001),sideA,sideMasks); bool hasB=zyTrySampleErosionPage(normalize(terrainDir+crossDirection*0.001),sideB,sideMasks);
|
||||
float edgeProximity=1.0-saturate((dominant-second)*100.0);
|
||||
debugColor=float3(saturate(abs(sideA.x-sideB.x)*100.0)*edgeProximity,edgeProximity,(hasA&&hasB)?0.0:1.0);
|
||||
}
|
||||
SdfSurface surface=sdfSurface(p,0);
|
||||
ZyPatchSceneOut output; output.colorTravel=float4(shadeSdf(0.0,travel,p,normal,0,surface),min(travel,farDistance+1.0));
|
||||
float3 shaded=(renderDebugMode>=21.5&&renderDebugMode<26.5)?debugColor:shadeSdf(0.0,travel,p,normal,0,surface);
|
||||
ZyPatchSceneOut output; output.colorTravel=float4(shaded,min(travel,farDistance+1.0));
|
||||
output.metadata=float4(FIELD_ID_SDF_OBJECT_BASE,normal); output.control=float4(1,4.0/384.0,saturate(surface.temporalDetail),saturate(surface.reservoirConfidence));
|
||||
float3 forward,right,up; cameraBasis(cameraPosition,cameraTarget,forward,right,up);
|
||||
output.reservoirGuide=float4(saturate(surface.reservoirConfidence),0,1,0); output.overdraw=1;
|
||||
|
|
|
|||
|
|
@ -127,6 +127,11 @@ invariants:
|
|||
exact residual age, or a cross-face eviction midpoint. Capture priming is
|
||||
presentation evidence only: production arrival/departure ownership remains
|
||||
the time-based resident-page lifecycle.
|
||||
- Planet patch debug modes 22-26 expose selected face/level/blend, page
|
||||
bounds and unresolved error, refined normal, ridge/gully evidence, and
|
||||
cross-edge discontinuity/missing residency. Direct-minus-page error remains
|
||||
a numerical readback surface until an honest pixel-visible comparison
|
||||
product is added; do not relabel the unresolved bound as measured error.
|
||||
- Planetary page residency separates content from presentation state.
|
||||
ContentVersion changes only when the resident tile set changes;
|
||||
PresentationVersion carries arrival/departure weights without regenerating
|
||||
|
|
|
|||
|
|
@ -196,12 +196,12 @@ public sealed class D3D12PlanetarySurfacePageTests
|
|||
CopyShaderTree(Path.GetFullPath(Path.Combine(RepositoryRoot(), "..", "CultMath", "shaders")), Path.Combine(temporaryRoot, "CultMath"));
|
||||
foreach (var shaderName in new[] { "D3D12ZyphosPlanet.hlsl", "D3D12ZyphosUmbros.hlsl", "D3D12ZyphosStar.hlsl" })
|
||||
{
|
||||
var bytecode = D3D12ShaderCompiler.Compile(Path.Combine(temporaryRoot, shaderName), "D3D12SdfProxyPS", "ps_5_0", skipOptimizationInDebug: false);
|
||||
var bytecode = D3D12ShaderCompiler.Compile(Path.Combine(temporaryRoot, shaderName), "D3D12SdfProxyPS", "ps_5_0");
|
||||
Assert.False(bytecode.IsEmpty);
|
||||
}
|
||||
var patchPath = Path.Combine(temporaryRoot, "D3D12ZyphosTerrainPatch.hlsl");
|
||||
Assert.False(D3D12ShaderCompiler.Compile(patchPath, "D3D12ZyphosTerrainPatchVS", "vs_5_0", skipOptimizationInDebug: false).IsEmpty);
|
||||
Assert.False(D3D12ShaderCompiler.Compile(patchPath, "D3D12ZyphosTerrainPatchPS", "ps_5_0", skipOptimizationInDebug: false).IsEmpty);
|
||||
Assert.False(D3D12ShaderCompiler.Compile(patchPath, "D3D12ZyphosTerrainPatchVS", "vs_5_0").IsEmpty);
|
||||
Assert.False(D3D12ShaderCompiler.Compile(patchPath, "D3D12ZyphosTerrainPatchPS", "ps_5_0").IsEmpty);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -223,6 +223,47 @@ public sealed class D3D12PlanetarySurfacePageTests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IndependentlyGeneratedRootPagesAgreeAcrossAllCubeEdgesAndCorners()
|
||||
{
|
||||
const int interior=9,border=2;
|
||||
var groups=new Dictionary<(int X,int Y,int Z),List<PageOutput>>();
|
||||
var requests=Enum.GetValues<CubeFace>().Select(face=>new PlanetarySurfacePageRequest(new CubeTileKey(face,0,0,0),interior,border)).ToArray();
|
||||
const float radius=8.4f;
|
||||
var inputs=requests.SelectMany(request=>
|
||||
{
|
||||
var spacing=PlanetarySurfacePageSampling.NominalAngularTexelSize(request)*radius;
|
||||
return Enumerable.Range(0,request.StorageSize*request.StorageSize).Select(index=>
|
||||
{
|
||||
var x=index%request.StorageSize; var y=index/request.StorageSize;
|
||||
return new PageInput(new Vector4(PlanetarySurfacePageSampling.Direction(request,x,y),radius),new Vector4(spacing,0,0,0));
|
||||
});
|
||||
}).ToArray();
|
||||
var generated=D3D12ComputeProbe.Run<PageInput,PageOutput>(ShaderPath(),"D3D12ZyphosTerrainPageCS",inputs);
|
||||
var outputOffset=0;
|
||||
foreach(var request in requests)
|
||||
{
|
||||
for(var y=0;y<interior;y++) for(var x=0;x<interior;x++)
|
||||
{
|
||||
if(x!=0&&x!=interior-1&&y!=0&&y!=interior-1)continue;
|
||||
var direction=PlanetarySurfacePageSampling.DirectionAtLocal(request,x/(float)(interior-1),y/(float)(interior-1));
|
||||
var key=((int)MathF.Round(direction.X*1_000_000),(int)MathF.Round(direction.Y*1_000_000),(int)MathF.Round(direction.Z*1_000_000));
|
||||
if(!groups.TryGetValue(key,out var samples))groups[key]=samples=[];
|
||||
samples.Add(generated[outputOffset+(border+y)*request.StorageSize+border+x]);
|
||||
}
|
||||
outputOffset+=request.StorageSize*request.StorageSize;
|
||||
}
|
||||
var edges=groups.Values.Where(samples=>samples.Count==2).ToArray();
|
||||
var corners=groups.Values.Where(samples=>samples.Count==3).ToArray();
|
||||
Assert.Equal(12*(interior-2),edges.Length);
|
||||
Assert.Equal(8,corners.Length);
|
||||
foreach(var samples in edges.Concat(corners))
|
||||
{
|
||||
var expected=samples[0];
|
||||
Assert.All(samples.Skip(1),actual=>AssertPageOutputClose(expected,actual,1.0e-5f));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GeneratedPagePublishesFiniteChannelsAndSummaryEvidence()
|
||||
{
|
||||
|
|
@ -270,6 +311,17 @@ public sealed class D3D12PlanetarySurfacePageTests
|
|||
return D3D12ComputeProbe.Run<PageInput,PageOutput>(shader,"D3D12ZyphosTerrainPageCS",input);
|
||||
}
|
||||
|
||||
private static void AssertPageOutputClose(PageOutput expected,PageOutput actual,float tolerance)
|
||||
{
|
||||
static void Close(Vector4 a,Vector4 b,float epsilon)
|
||||
{
|
||||
Assert.InRange(MathF.Abs(a.X-b.X),0,epsilon); Assert.InRange(MathF.Abs(a.Y-b.Y),0,epsilon);
|
||||
Assert.InRange(MathF.Abs(a.Z-b.Z),0,epsilon); Assert.InRange(MathF.Abs(a.W-b.W),0,epsilon);
|
||||
}
|
||||
Close(expected.HeightGradient,actual.HeightGradient,tolerance);
|
||||
Close(expected.Masks,actual.Masks,tolerance);
|
||||
}
|
||||
|
||||
private static string ShaderPath()=>Path.Combine(RepositoryRoot(),"src","Aquarium.Zyphos","Shaders","D3D12ZyphosTerrainPage.hlsl");
|
||||
|
||||
private static void CopyShaderTree(string source, string destination)
|
||||
|
|
|
|||
Loading…
Reference in a new issue