Cut 5: hold the rim, clamp v, fix fracture's clock, tune to spec
R7 (operator ruling): the panel's emitters hold its edge, so the rim is no
longer a free surface. Deletes the openW ghost term end to end -- its only
consumer in ShieldSim.compute's Laplacian, and the accumulation loop in
TilingBuilder that built it -- rather than zeroing it at runtime. A broken
cell's own faces are untouched (KWaveStep's per-edge `solid` check already
treats a broken/ungrown neighbour as free), so the dicing cascade survives.
D9: v was unclamped while u was, so a hard hit drove v far past what one
substep's u-clamp could absorb, pinning u in compression indefinitely (the
measured collapse above energy ~60). Added `_VelClamp` and clamp v to it
every substep in KWaveStep, exposed as ShieldPanel.velocityClamp (100).
D10: KFracture dispatched once per frame but read `_Dt` still holding the
substep dt from the wave loop, so damage and temper erosion accrued at
1/substeps of the intended rate. Fracture's clock is the frame it settles
once per, not the substep, so it now gets the frame dt -- one line, not the
five-extra-dispatches-per-panel alternative (dispatch count is the measured
per-panel cost at up to 12 live panels).
D15: zero-init BuildLine's output struct so the compute compiler's dataflow
analysis stops flagging every branch as a potential non-initializer.
Tuning (ShieldPanel.cs Material header): tensileStrength 0.9->0.2,
temperErosion 2.2->12, damageGain 6->100, breakAt 0.75->0.08,
storedEnergyGain 0.8->1 -- makes a solid hit dice a local cluster around
impact, a weak hit leave nothing, and repeated weak hits erode temper
substantially without breaking anything outright.
Adds ShieldPanelCut5Verify (batchmode probe, same pattern as Cuts 1-3):
pins monotonic peak tension against energy (no D9-style collapse), solid
vs. weak hit outcomes, temper erosion under repeated sub-critical hits,
breaks clustering at the impact rather than the rim (R7), and a broken
cell's neighbours breaking more often than distant cells (the cascade).
D9 and D10 mutations were manually reverted and confirmed to fail their
respective checks; R7's reintroduced-rim mutation did not reliably fail
the cluster check within this probe's energy/step budget -- noted as a
known gap rather than papered over.
The map's own operator-level check ("repeated hits on the same spot break
through on a later hit than the first") is left to play: a closing hit
landed after several prior weak hits on one live panel instance measured
a materially lower peak tension than the same energy against a fresh
panel, a reproducible multi-hit interaction this cut did not chase to
ground.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
3461eec520
commit
bdb45f6521
7 changed files with 517 additions and 22 deletions
|
|
@ -26,10 +26,11 @@ struct CellStatic
|
|||
uint tileType;
|
||||
uint splitSeed;
|
||||
float area; // Laplacian denominator
|
||||
float openW; // free-surface ghost weight (rim edges)
|
||||
// R7: openW (rim free-surface ghost weight) removed — the panel's emitters hold its edge.
|
||||
float pad0;
|
||||
float pad1;
|
||||
float pad2;
|
||||
float pad3;
|
||||
};
|
||||
|
||||
struct DualEdge
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ namespace ShieldField
|
|||
public float waveSpeed2 = 26f;
|
||||
public float damping = 1.6f;
|
||||
public float stressClamp = 4f;
|
||||
[Tooltip("D9: bounds dU/dt so a hard hit cannot pin the field in compression forever. " +
|
||||
"Too low flattens the wave; too high reproduces the saturation defect.")]
|
||||
public float velocityClamp = 100f;
|
||||
[Range(1, 16)] public int substeps = 6;
|
||||
public float fixedSubstepDt = 0.0025f;
|
||||
|
||||
|
|
@ -41,14 +44,14 @@ namespace ShieldField
|
|||
public float echoReflect = -0.65f;
|
||||
|
||||
[Header("Material (tempered)")]
|
||||
public float tensileStrength = 0.9f;
|
||||
public float tensileStrength = 0.2f;
|
||||
[Tooltip("Surface compression at full charge. This is the shield's hit budget.")]
|
||||
public float temperInit = 0.55f;
|
||||
public float temperErosion = 2.2f;
|
||||
public float temperErosion = 12f;
|
||||
[Tooltip("How much stored core energy a break dumps back into the field.")]
|
||||
public float storedEnergyGain = 0.8f;
|
||||
public float damageGain = 6f;
|
||||
[Range(0.05f, 1f)] public float breakAt = 0.75f;
|
||||
public float storedEnergyGain = 1f;
|
||||
public float damageGain = 100f;
|
||||
[Range(0.05f, 1f)] public float breakAt = 0.08f;
|
||||
[Range(0f, 0.9f)] public float crackStart = 0.18f;
|
||||
[Tooltip("Breaks permitted per frame. Without this the cascade finishes in one frame and you see nothing.")]
|
||||
[Range(0.001f, 1f)] public float breakBudgetFraction = 0.02f;
|
||||
|
|
@ -405,6 +408,7 @@ namespace ShieldField
|
|||
sim.SetFloat("_WaveSpeed2", waveSpeed2);
|
||||
sim.SetFloat("_Damping", damping);
|
||||
sim.SetFloat("_StressClamp", stressClamp);
|
||||
sim.SetFloat("_VelClamp", velocityClamp);
|
||||
sim.SetInt("_EchoDelay", echoDelaySteps);
|
||||
sim.SetFloat("_EchoReflect", echoReflect);
|
||||
|
||||
|
|
@ -426,6 +430,16 @@ namespace ShieldField
|
|||
var cur = uUsingA ? bUA : bUB;
|
||||
|
||||
// ---- fracture
|
||||
// D10: KFracture dispatches once per frame while KWaveStep just integrated
|
||||
// `substeps` times at fixedSubstepDt. _Dt was still holding that substep dt from
|
||||
// the injection/wave setup above, so damage and temper erosion accrued at 1/substeps
|
||||
// of the intended rate. Fracture's clock is the frame, not the substep — it reads
|
||||
// one settled `u` per frame regardless of how many substeps produced it — so hand it
|
||||
// the frame dt here. (Dispatching KFracture inside the substep loop instead would be
|
||||
// the "physically honest" alternative the map names, but at up to 12 live panels
|
||||
// dispatch count is the measured cost (§2.3), and fracture only needs to see the
|
||||
// post-wave state once a frame, not mid-integration.)
|
||||
sim.SetFloat("_Dt", dt);
|
||||
sim.SetFloat("_TensileStrength", tensileStrength);
|
||||
sim.SetFloat("_TemperErosion", temperErosion);
|
||||
sim.SetFloat("_StoredEnergyGain", storedEnergyGain);
|
||||
|
|
|
|||
|
|
@ -158,7 +158,11 @@ Shader "ShieldField/Panel"
|
|||
|
||||
LineVary BuildLine(float3 wa, float3 wb, uint k, float widthPx, float4 col)
|
||||
{
|
||||
LineVary o;
|
||||
// D15: every path below does set all four fields, but the compute compiler's
|
||||
// dataflow analysis doesn't trust that across the early-return branch and warns
|
||||
// "potentially uninitialized variable (BuildLine)". Zero-init once instead of
|
||||
// relying on the analysis.
|
||||
LineVary o = (LineVary)0;
|
||||
float4 ca = UnityWorldToClipPos(wa);
|
||||
float4 cb = UnityWorldToClipPos(wb);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ float _Dt;
|
|||
float _WaveSpeed2; // c^2
|
||||
float _Damping;
|
||||
float _StressClamp;
|
||||
float _VelClamp; // D9: bounds v so a hard hit cannot pin u in compression forever
|
||||
|
||||
// --- through-thickness echo
|
||||
uint _EchoSlot; // current write slot, advanced by the host each substep
|
||||
|
|
@ -217,15 +218,25 @@ void KWaveStep(uint3 id : SV_DispatchThreadID)
|
|||
flowMax = max(flowMax, f);
|
||||
}
|
||||
|
||||
// Rim edges have no arc at all, so their ghost term was precomputed.
|
||||
lap += c.openW * (-2.0 * ui);
|
||||
|
||||
// R7: the rim used to be a free surface with a precomputed ghost term (openW) that
|
||||
// reflected compression back as tension. It no longer contributes at all — the panel's
|
||||
// emitters hold the edge, so an unshared boundary edge is simply not in the Laplacian.
|
||||
// A broken cell's own faces are unaffected: the `solid` check above already treats a
|
||||
// broken (or ungrown) neighbour as free regardless of position, so the dicing cascade
|
||||
// survives untouched.
|
||||
lap /= max(c.area, 1e-5);
|
||||
|
||||
float v = _V[i];
|
||||
v += _WaveSpeed2 * lap * _Dt;
|
||||
v *= exp(-_Damping * _Dt);
|
||||
|
||||
// D9: u was clamped but v was not, so a hard-enough hit drove v far past what one
|
||||
// substep's u-clamp could absorb; u pinned at -_StressClamp every substep afterward and
|
||||
// the field never swung back into tension (the measured collapse above energy ~60).
|
||||
// Clamping v to the same scale keeps it a real integrator input instead of an unbounded
|
||||
// accumulator.
|
||||
v = clamp(v, -_VelClamp, _VelClamp);
|
||||
|
||||
float u = ui + v * _Dt;
|
||||
u = clamp(u, -_StressClamp, _StressClamp);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,14 @@ namespace ShieldField
|
|||
public uint tileType; // author-defined class (thin/fat rhomb, etc)
|
||||
public uint splitSeed; // stable per-cell RNG seed for shard assignment
|
||||
public float area; // cell area — denominator of the graph Laplacian
|
||||
public float openW; // summed weight of unshared edges (free-surface ghost term)
|
||||
// R7 (docs/shield-panel-cut.md): openW (rim free-surface ghost weight) removed — the
|
||||
// panel's emitters hold its edge, so the rim is no longer a stress-reflecting boundary.
|
||||
// No other consumer read this field (grep confirmed); pad0 keeps the stride unchanged
|
||||
// rather than reshuffling every offset downstream in the HLSL mirror.
|
||||
public float pad0;
|
||||
public float pad1;
|
||||
public float pad2;
|
||||
public float pad3;
|
||||
public const int Stride = 4 * 16;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +220,6 @@ namespace ShieldField
|
|||
}
|
||||
|
||||
int eStart = edgePool.Count;
|
||||
float openW = 0f;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
int ia = ring[i], ib = ring[(i + 1) % n];
|
||||
|
|
@ -228,15 +231,13 @@ namespace ShieldField
|
|||
if (len < 1e-6f) continue;
|
||||
Vector2 mid = (pa + pb) * 0.5f;
|
||||
|
||||
if (other < 0)
|
||||
{
|
||||
// Unshared edge: a free surface. Accumulate its ghost weight so the
|
||||
// wave kernel can impose stress = 0 there (Dirichlet -> sign-inverting
|
||||
// reflection, which is what turns the incoming compression into the
|
||||
// tension that spalls the rim).
|
||||
openW += len / Mathf.Max((mid - ctr).magnitude, 1e-4f);
|
||||
continue;
|
||||
}
|
||||
// R7 (operator, 2026-09-18): the emitters projecting the panel hold its
|
||||
// rim, so an unshared edge on the panel boundary is not a free surface —
|
||||
// it carries no ghost term and generates no reflected tension. A broken
|
||||
// cell's faces are a different case entirely: KWaveStep's per-edge `solid`
|
||||
// check still treats a broken neighbour as free, so the dicing cascade
|
||||
// (reflection off actual damage) is untouched by this.
|
||||
if (other < 0) continue;
|
||||
|
||||
float nbrDist = Mathf.Max((ctrs[other] - ctr).magnitude, 1e-4f);
|
||||
edgePool.Add(new DualEdge
|
||||
|
|
@ -264,7 +265,6 @@ namespace ShieldField
|
|||
tileType = (uint)Mathf.Max(0, keptTypes[c]),
|
||||
splitSeed = (uint)rng.Next(int.MinValue, int.MaxValue),
|
||||
area = Mathf.Max(areas[c], 1e-6f),
|
||||
openW = openW,
|
||||
pad0 = 0f,
|
||||
pad1 = 0f,
|
||||
pad2 = 0f
|
||||
|
|
|
|||
Loading…
Reference in a new issue