diff --git a/Assets/Scripts/Editor/IsolineExtractSmoke.cs b/Assets/Scripts/Editor/IsolineExtractSmoke.cs index 9c5c95a5f..a43c551e7 100644 --- a/Assets/Scripts/Editor/IsolineExtractSmoke.cs +++ b/Assets/Scripts/Editor/IsolineExtractSmoke.cs @@ -199,8 +199,10 @@ namespace Aetheria.EditorTools // The orientation rule's outcome (cut isoline-chain-arclength): at every point shared by exactly two endpoints of one // family, one is a start (a) and the other an end (b). Returns the endpoints that break it (two starts or two ends at one - // point, counted per endpoint, the unit of the GPU's ChainStats[1]) and the joints it judged. The mutant, the emit order - // as marched, reads ORIENTATION_MUTANT below. Bound: no conflict at all. + // point, counted per endpoint, the unit of the GPU's ChainStats[1]) and the joints it judged. Bound: no conflict at all, so the shipped + // reading is 0. The mutant (the shader emitting in the order it marches, run on a copy of the project) reads 1558 of the saddle + // fixture's 2972 joint endpoints, 7704 of the tight radial well's 12662, 8536 of the real zone's 14412 at 256 x 256 and 105058 of its + // 175652 at 3840 x 2160: a share of 52 to 61 percent. static (int conflicts, int joints) Orientation(string what, IsolineExtractor.IsoSegment[] segments) { int conflicts = 0, joints = 0, rayConflicts = 0; @@ -866,7 +868,10 @@ namespace Aetheria.EditorTools // The chain kernels' cost (ChainClear through ChainEmit, J passes): per iteration, Extract recorded 8 times through Finish and // 8 times through the chains, each timed on the wall clock to a fence (the count read back); the chain cost is the median // over 31 interleaved iterations of the paired difference (the fence and the extraction cancel), beside the median of Extract - // alone. Soul's replica (r2, GTX 1070): 0.16-0.18 ms at the map pose, 0.75-0.77 ms on the stress set. + // alone. Soul's replica (r2, GTX 1070): 0.16-0.18 ms at the map pose, 0.75-0.77 ms on the stress set. This cut's kernels + // (GTX 1070, Starfire, 2026-12-01): 0.19-0.22 ms at the map pose (Extract through Finish 1.07-1.12), 1.0-1.1 ms on the stress + // set (2.4-2.5), 0.29-0.33 ms at 3840 x 2160 (3.7-3.8). Link and Insert each probe twice (the heads and conflicts tallies + // read an endpoint's own point), which the replica did not. static void ChainCost(string what, GravityLowering.GravityTerms terms, Vector2 origin, Vector2 perTexel, Vector2Int size, IsolineExtractor.IsolineLevels levels) { const int reps = 8, iterations = 31; diff --git a/Assets/Scripts/Editor/IsolineRenderSmoke.cs b/Assets/Scripts/Editor/IsolineRenderSmoke.cs index 02d6179a9..573b5ada6 100644 --- a/Assets/Scripts/Editor/IsolineRenderSmoke.cs +++ b/Assets/Scripts/Editor/IsolineRenderSmoke.cs @@ -647,32 +647,42 @@ namespace Aetheria.EditorTools // chains; the loops are counted beside them. static bool IsClosed(List edges) => edges.Count >= 2 && PointKey(edges[0].P0) == PointKey(edges[edges.Count - 1].P1); - // The reference: the same segments with s replaced by the cumulative arclength along BuildChains' chain, from its first - // edge (the dash phase differs from the shipped one, the spacing does not). + // The reference: the same segments with s replaced, on the CPU, by the cumulative arclength along BuildChains' chain, with its + // origin where the extractor puts it: s = 0 at the start of the chain's last segment (the tail), negative before it, so + // sA = -(length from this segment's start to the tail's start) and sB = sA + |b - a|. An origin at the head instead puts a + // different dash phase at the chain ends: the tail's s runs 0 to its own length, so a dash starts one segment before the + // chain ends and every chain ends in a fragment of that length (map pose, run length p5 6 px against 36 px from a head + // origin, the same segments). The spacing is the same; the run-length percentiles are not, because of the ends. A chain that + // runs b to a in BuildChains is read the other way round; a closed loop, which has no tail, keeps its s. static Seg[] WithChainArclength(Seg[] segs, List chains) { var copy = (Seg[])segs.Clone(); foreach (var chain in chains) { - var cumulative = 0f; - for (var i = 0; i < chain.Seg.Count; i++) + List order; + if (chain.Rev.All(r => !r)) order = chain.Seg; + else if (chain.Rev.All(r => r)) order = chain.Seg.AsEnumerable().Reverse().ToList(); + else continue; + if (IsClosed(EdgesOf(segs, chain))) continue; + var prefix = new double[order.Count + 1]; + for (var i = 0; i < order.Count; i++) prefix[i + 1] = prefix[i] + (segs[order[i]].b - segs[order[i]].a).magnitude; + var tailStart = prefix[order.Count - 1]; + for (var i = 0; i < order.Count; i++) { - var k = chain.Seg[i]; - var length = (segs[k].b - segs[k].a).magnitude; - if (!chain.Rev[i]) { copy[k].sA = cumulative; copy[k].sB = cumulative + length; } - else { copy[k].sB = cumulative; copy[k].sA = cumulative + length; } - cumulative += length; + copy[order[i]].sA = (float)(prefix[i] - tailStart); + copy[order[i]].sB = (float)(prefix[i + 1] - tailStart); } } return copy; } - // Margin rule against the s = rho mutant (3d8a0d1d3, Soul's readings in unity-mut.log's base run): its run lengths at the map - // pose read p5 2, p25 10 and p50 46 px against the true arclength's 28, 45 and 51, that is |ln(mutant / reference)| 2.64, - // 1.50 and 0.103. Each bound sits at the geometric mean of that and the shipped reading below (the shipped |ln| per - // percentile, worst of the two poses). The flow frame's mutant readings were not taken at 3d8a0d1d3; the same bounds - // apply to it. - const double DashP5Bound = 1e9, DashP25Bound = 1e9, DashP50Bound = 1e9; + // Margin rule against the s = rho mutant (3d8a0d1d3; its run lengths at the map pose, measured by this same code, read p5 2, + // p25 10 and p50 46 px, Soul's unity-mut.log base run). Against this reference (p5 6, p25 44, p50 51 px at the map pose) that + // is |ln(mutant / reference)| 1.10, 1.48 and 0.103. The shipped frames equal the reference frames to the pixel at both poses + // (|ln| 0 at every percentile), so the shipped reading is floored at one pixel of run length: ln(7/6) 0.154, ln(45/44) 0.0225, + // ln(52/51) 0.0194. Bounds at the geometric means: p5 0.412 (separation 7.1), p25 0.182 (66), p50 0.0447 (5.3). The flow + // frame's mutant readings were not taken at 3d8a0d1d3; the same bounds apply to it. + const double DashP5Bound = 0.412, DashP25Bound = 0.182, DashP50Bound = 0.0447; // The map pose (Period 160 u, 78.5 px) and Soul's flow pose (Period 60 u at 1.17 u/px), rays only: the dash run lengths of // the frame drawn from the extractor's segments against the frame drawn from the same segments with s replaced by the CPU