Remove Bokusho projection rescue marks
This commit is contained in:
parent
de53ab72cb
commit
3e97904085
3 changed files with 2 additions and 340 deletions
|
|
@ -412,8 +412,6 @@ public static class BokushoBrushSimulation
|
|||
var gestureWidth = StrokeGestureWidthShape(stroke, bestT, sampleCount);
|
||||
var poseSpread = Saturate(0.92f + MathF.Abs(stroke.ShaftTilt) * 0.22f + stroke.Compliance * 0.10f - stroke.GripHeight * 0.04f);
|
||||
var radius = MathF.Max(frame.BrushRadius * stroke.RadiusScale * stroke.NormalScale * StrokeNormalRadiusShape(taper) * gestureWidth * poseSpread, 0.0001f);
|
||||
var strokeExtent = Vector2.Distance(new Vector2(stroke.StrokeP3.X, stroke.StrokeP3.Y), new Vector2(stroke.StrokeP0.X, stroke.StrokeP0.Y));
|
||||
var releaseSpan = SmoothStep(0.42f, 1.18f, strokeExtent);
|
||||
var splay = Saturate(frame.Splay / 2.0f);
|
||||
var pressure = Saturate(frame.Pressure * stroke.PressureScale * 0.5f) * taper;
|
||||
var poseContact = 0.90f + stroke.Compliance * 0.10f + (1.0f - Saturate(stroke.GripHeight / 2.4f)) * 0.10f;
|
||||
|
|
@ -427,15 +425,12 @@ public static class BokushoBrushSimulation
|
|||
var paperKey = stroke.SourceStrokeId >= 0 ? stroke.SourceStrokeId : strokeIndex;
|
||||
var tooth = PaperTooth(world, paperKey);
|
||||
var edge = Saturate(distance / MathF.Max(footprint * 0.96f, 0.001f));
|
||||
var dryIslandLift = SmoothStep(0.66f, 0.20f, Saturate(frame.Wetness / 1.6f));
|
||||
var dryBreak = SmoothStep(0.18f + tooth * 0.18f, 0.92f, edge) * (1.0f - Saturate(frame.Wetness / 1.6f)) * (0.34f + stroke.SplitScale * 0.12f);
|
||||
var hold = Saturate(0.52f + tooth * 0.42f + pressure * 0.28f - dryBreak);
|
||||
var centerSample = Math.Clamp((int)MathF.Round(bestT * (sampleCount - 1)), 0, sampleCount - 1);
|
||||
var centerTuft = Math.Clamp((int)MathF.Round(tuftT * MathF.Max(tuftCount - 1.0f, 0.0f)), 0, tuftCount - 1);
|
||||
var pigmentPeak = 0.0f;
|
||||
var pigmentFlow = 0.0f;
|
||||
var dryIslandPeak = 0.0f;
|
||||
var dryFleckPeak = 0.0f;
|
||||
|
||||
for (var sampleDelta = -3; sampleDelta <= 3; sampleDelta++)
|
||||
{
|
||||
|
|
@ -498,15 +493,10 @@ public static class BokushoBrushSimulation
|
|||
var tip = tips[index];
|
||||
var previousTip = tips[previousIndex];
|
||||
var pigment = canvas[index];
|
||||
var nextSampleIndex = Math.Clamp(sampleIndex + 1, 0, sampleCount - 1);
|
||||
var nextIndex = ((sampleStrokeIndex * tuftCount) + tuftIndex) * sampleCount + nextSampleIndex;
|
||||
var neighborPigment = MathF.Max(canvas[previousIndex], canvas[nextIndex]);
|
||||
var releasePigment = SmoothStep(0.12f, 0.68f, pigment) * SmoothStep(0.030f, 0.16f, pigment - neighborPigment);
|
||||
var tipPoint = new Vector2(tip.X, tip.Y);
|
||||
var previousTipPoint = new Vector2(previousTip.X, previousTip.Y);
|
||||
var sweep = tipPoint - previousTipPoint;
|
||||
var sweepLengthSquared = sweep.LengthSquared();
|
||||
var sweepLength = MathF.Sqrt(sweepLengthSquared);
|
||||
var sweepT = sweepLengthSquared <= 0.000001f
|
||||
? 1.0f
|
||||
: Saturate(Vector2.Dot(world - previousTipPoint, sweep) / sweepLengthSquared);
|
||||
|
|
@ -527,98 +517,11 @@ public static class BokushoBrushSimulation
|
|||
* (0.82f + sweepContact * 0.24f);
|
||||
pigmentPeak = MathF.Max(pigmentPeak, contribution);
|
||||
pigmentFlow += contribution;
|
||||
|
||||
var laneT = tuftCount <= 1 ? 0.5f : tuftIndex / (float)(tuftCount - 1);
|
||||
var laneEdge = MathF.Abs(laneT * 2.0f - 1.0f);
|
||||
var islandSeedPoint = contactPoint * 34.0f + new Vector2(tuftIndex * 0.19f, sampleIndex * 0.13f);
|
||||
var islandSeed = HashNoiseCell(islandSeedPoint, paperKey, 0x510E527Fu);
|
||||
var thinPigment = SmoothStep(0.006f, 0.075f, pigment) * (1.0f - SmoothStep(0.22f, 0.55f, pigment));
|
||||
var islandPigment = MathF.Max(thinPigment, releasePigment * 0.72f);
|
||||
var sweepStride = sweepLength / MathF.Max(tip.Z, 0.001f);
|
||||
var releaseMotion = SmoothStep(0.10f, 0.42f, sweepStride);
|
||||
var releaseAuthority = releaseSpan * releaseMotion;
|
||||
var islandGate = SmoothStep(0.38f, 0.88f, laneEdge)
|
||||
* dryIslandLift
|
||||
* islandPigment
|
||||
* SmoothStep(0.25f, 0.88f, tooth)
|
||||
* SmoothStep(0.42f, 0.92f, islandSeed);
|
||||
if (islandGate > 0.0f)
|
||||
{
|
||||
var side = islandSeed < 0.78f ? -1.0f : 1.0f;
|
||||
var islandCenter = contactPoint
|
||||
+ sampleNormal * side * tip.Z * (0.88f + laneEdge * 0.55f)
|
||||
+ sampleTangent * (islandSeed - 0.5f) * tip.W * 0.22f;
|
||||
var islandRadius = MathF.Max(tip.Z * (0.30f + laneEdge * 0.22f), 0.060f);
|
||||
var islandDistance = MathF.Sqrt(Vector2.DistanceSquared(world, islandCenter));
|
||||
var islandContact = SmoothStep(1.0f, 0.0f, islandDistance / islandRadius);
|
||||
dryIslandPeak = MathF.Max(dryIslandPeak, pigment * islandGate * islandContact * 5.2f);
|
||||
|
||||
var fleckSeedPoint = contactPoint * 61.0f + new Vector2(sampleIndex * 0.17f, tuftIndex * 0.23f);
|
||||
var fleckSeed = HashNoiseCell(fleckSeedPoint, paperKey, 0xF1E57A2Du);
|
||||
var fleckGate = islandGate
|
||||
* SmoothStep(0.44f - releasePigment * 0.18f, 0.88f, fleckSeed)
|
||||
* SmoothStep(0.56f, 1.0f, laneEdge)
|
||||
* (0.12f + releaseAuthority * 0.88f)
|
||||
* (1.0f + releasePigment * 1.15f);
|
||||
if (fleckGate > 0.0f)
|
||||
{
|
||||
var fleckSide = fleckSeed < 0.86f ? side : -side;
|
||||
var fleckReach = 0.72f + releaseAuthority * 0.28f;
|
||||
var fleckCenter = contactPoint
|
||||
+ sampleNormal * fleckSide * tip.Z * (1.92f + laneEdge * 0.82f + fleckSeed * 0.36f) * fleckReach
|
||||
+ sampleTangent * (fleckSeed - 0.5f) * tip.W * 0.42f * fleckReach;
|
||||
var fleckRadius = MathF.Max(tip.Z * (0.12f + laneEdge * 0.05f), 0.030f);
|
||||
var fleckDistance = MathF.Sqrt(Vector2.DistanceSquared(world, fleckCenter));
|
||||
var fleckContact = SmoothStep(1.0f, 0.0f, fleckDistance / fleckRadius);
|
||||
dryFleckPeak = MathF.Max(dryFleckPeak, pigment * fleckGate * fleckContact * 22.0f);
|
||||
}
|
||||
|
||||
var fraySeedPoint = contactPoint * 47.0f + new Vector2(sampleIndex * 0.29f, tuftIndex * 0.37f);
|
||||
var fraySeed = HashNoiseCell(fraySeedPoint, paperKey, 0x8D3F9A21u);
|
||||
var frayGate = islandGate
|
||||
* releasePigment
|
||||
* (0.40f + releaseAuthority * 0.60f)
|
||||
* SmoothStep(0.28f, 0.82f, fraySeed);
|
||||
if (frayGate > 0.0f)
|
||||
{
|
||||
var fraySide = fraySeed < 0.70f ? side : -side;
|
||||
var frayReach = 0.78f + releaseAuthority * 0.22f;
|
||||
var frayCenter = contactPoint
|
||||
+ sampleNormal * fraySide * tip.Z * (1.48f + laneEdge * 0.62f + fraySeed * 0.30f) * frayReach
|
||||
+ sampleTangent * (fraySeed - 0.5f) * tip.W * 0.34f * frayReach;
|
||||
var frayRadius = MathF.Max(tip.Z * (0.095f + laneEdge * 0.040f), 0.024f);
|
||||
var frayDistance = MathF.Sqrt(Vector2.DistanceSquared(world, frayCenter));
|
||||
var frayContact = SmoothStep(1.0f, 0.0f, frayDistance / frayRadius);
|
||||
dryFleckPeak = MathF.Max(dryFleckPeak, pigment * frayGate * frayContact * 26.0f);
|
||||
}
|
||||
|
||||
var satelliteSeedPoint = contactPoint * 83.0f + new Vector2(tuftIndex * 0.31f, sampleIndex * 0.11f);
|
||||
var satelliteSeed = HashNoiseCell(satelliteSeedPoint, paperKey, 0x5A771EAFu);
|
||||
var satelliteGate = islandGate
|
||||
* releasePigment
|
||||
* releaseAuthority
|
||||
* SmoothStep(0.66f, 1.0f, laneEdge)
|
||||
* SmoothStep(0.36f, 0.86f, satelliteSeed);
|
||||
if (satelliteGate > 0.0f)
|
||||
{
|
||||
var satelliteSide = satelliteSeed < 0.52f ? side : -side;
|
||||
var satelliteReach = 0.62f + releaseAuthority * 0.38f;
|
||||
var satelliteCenter = contactPoint
|
||||
+ sampleNormal * satelliteSide * tip.Z * (2.02f + laneEdge * 0.78f + satelliteSeed * 0.34f) * satelliteReach
|
||||
+ sampleTangent * (satelliteSeed - 0.5f) * tip.W * 0.50f * satelliteReach;
|
||||
var satelliteRadius = MathF.Max(tip.Z * (0.075f + laneEdge * 0.035f), 0.020f);
|
||||
var satelliteDistance = MathF.Sqrt(Vector2.DistanceSquared(world, satelliteCenter));
|
||||
var satelliteContact = SmoothStep(1.0f, 0.0f, satelliteDistance / satelliteRadius);
|
||||
dryFleckPeak = MathF.Max(dryFleckPeak, pigment * satelliteGate * satelliteContact * 38.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var decisiveInk = Saturate((pigmentPeak - 0.012f) * 2.25f + pigmentFlow * 0.002f);
|
||||
var islandInk = Saturate((dryIslandPeak - 0.001f) * 14.0f);
|
||||
var fleckInk = Saturate((dryFleckPeak - 0.001f) * 36.0f);
|
||||
return Saturate(decisiveInk + islandInk + fleckInk) * hold * projectionGate * (0.36f + pressure * 0.44f + Saturate(frame.InkLoad * 0.5f) * 0.20f);
|
||||
return decisiveInk * hold * projectionGate * (0.36f + pressure * 0.44f + Saturate(frame.InkLoad * 0.5f) * 0.20f);
|
||||
}
|
||||
|
||||
private static bool CanBorrowSourceSample(IReadOnlyList<AquariumBokushoBrushStroke> strokes, int strokeIndex, int candidateIndex)
|
||||
|
|
|
|||
|
|
@ -316,8 +316,6 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
float gestureWidth = bokushoStrokeGestureWidthShape(stroke, bestT);
|
||||
float poseSpread = saturate(0.92 + abs(stroke.pose.x) * 0.22 + stroke.pose.w * 0.10 - stroke.pose.z * 0.04);
|
||||
float radius = max(bokushoMaterial.x * stroke.profile.x * stroke.profile.z * bokushoStrokeNormalRadiusShape(taper) * gestureWidth * poseSpread, 0.0001);
|
||||
float strokeExtent = length(stroke.p3.xy - stroke.p0.xy);
|
||||
float releaseSpan = smoothstep(0.42, 1.18, strokeExtent);
|
||||
float splay = saturate(bokushoDynamics.x / 2.0);
|
||||
float poseContact = 0.90 + stroke.pose.w * 0.10 + (1.0 - saturate(stroke.pose.z / 2.4)) * 0.10;
|
||||
float pressure = saturate(bokushoMaterial.y * stroke.profile.y * 0.5) * taper * bokushoStrokePressureShape(stroke, bestT) * bokushoStrokeGesturePressureShape(stroke, bestT) * poseContact;
|
||||
|
|
@ -330,7 +328,6 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
uint paperKey = stroke.p3.w >= 0.0 ? (uint)round(stroke.p3.w) : strokeIndex;
|
||||
float tooth = bokushoPaperTooth(world, paperKey);
|
||||
float edge = saturate(distance / max(footprint * 0.96, 0.001));
|
||||
float dryIslandLift = smoothstep(0.66, 0.20, saturate(bokushoMaterial.w / 1.6));
|
||||
float dryBreak = smoothstep(0.18 + tooth * 0.18, 0.92, edge)
|
||||
* (1.0 - saturate(bokushoMaterial.w / 1.6))
|
||||
* (0.34 + stroke.dynamics.w * 0.12);
|
||||
|
|
@ -339,8 +336,6 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
uint centerTuft = min((uint)round(tuftT * (float)max((int)tuftCount - 1, 0)), tuftCount - 1u);
|
||||
float pigmentPeak = 0.0;
|
||||
float pigmentFlow = 0.0;
|
||||
float dryIslandPeak = 0.0;
|
||||
float dryFleckPeak = 0.0;
|
||||
|
||||
[unroll]
|
||||
for (int sampleDelta = -3; sampleDelta <= 3; sampleDelta += 1)
|
||||
|
|
@ -403,12 +398,8 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
|
||||
uint previousSampleIndex = min((uint)max(previousSampleIndexValue, 0), sampleCount - 1u);
|
||||
float4 previousTip = bokushoTipSample(previousStrokeIndex, previousSampleIndex, tuftIndex);
|
||||
uint nextSampleIndex = min(sampleIndex + 1u, sampleCount - 1u);
|
||||
float previousPigment = BokushoCanvasField[((previousStrokeIndex * tuftCount) + tuftIndex) * sampleCount + previousSampleIndex];
|
||||
float nextPigment = BokushoCanvasField[((sampleStrokeIndex * tuftCount) + tuftIndex) * sampleCount + nextSampleIndex];
|
||||
float2 sweep = tip.xy - previousTip.xy;
|
||||
float sweepLengthSquared = dot(sweep, sweep);
|
||||
float sweepLength = sqrt(sweepLengthSquared);
|
||||
float sweepT = sweepLengthSquared <= 0.000001 ? 1.0 : saturate(dot(world - previousTip.xy, sweep) / sweepLengthSquared);
|
||||
float2 contactPoint = previousTip.xy + sweep * sweepT;
|
||||
float sweepDistance = length(world - contactPoint);
|
||||
|
|
@ -420,8 +411,6 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
float tipContact = max(smoothstep(1.0, 0.0, ellipse), sweepContact * 0.86);
|
||||
float longitudinalGate = smoothstep(1.0, 0.0, abs(tangentDistance) * 0.62);
|
||||
float pigment = BokushoCanvasField[((sampleStrokeIndex * tuftCount) + tuftIndex) * sampleCount + sampleIndex];
|
||||
float neighborPigment = max(previousPigment, nextPigment);
|
||||
float releasePigment = smoothstep(0.12, 0.68, pigment) * smoothstep(0.030, 0.16, pigment - neighborPigment);
|
||||
float contribution = pigment
|
||||
* tipContact
|
||||
* (0.006 + contactCore * 0.994)
|
||||
|
|
@ -430,98 +419,11 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
* (0.82 + sweepContact * 0.24);
|
||||
pigmentPeak = max(pigmentPeak, contribution);
|
||||
pigmentFlow += contribution;
|
||||
|
||||
float laneT = tuftCount <= 1u ? 0.5 : (float)tuftIndex / (float)(tuftCount - 1u);
|
||||
float laneEdge = abs(laneT * 2.0 - 1.0);
|
||||
float2 islandSeedPoint = contactPoint * 34.0 + float2((float)tuftIndex * 0.19, (float)sampleIndex * 0.13);
|
||||
float islandSeed = bokushoHashNoiseCell(islandSeedPoint, paperKey, 0x510E527Fu);
|
||||
float thinPigment = smoothstep(0.006, 0.075, pigment) * (1.0 - smoothstep(0.22, 0.55, pigment));
|
||||
float islandPigment = max(thinPigment, releasePigment * 0.72);
|
||||
float sweepStride = sweepLength / max(tip.z, 0.001);
|
||||
float releaseMotion = smoothstep(0.10, 0.42, sweepStride);
|
||||
float releaseAuthority = releaseSpan * releaseMotion;
|
||||
float islandGate = smoothstep(0.38, 0.88, laneEdge)
|
||||
* dryIslandLift
|
||||
* islandPigment
|
||||
* smoothstep(0.25, 0.88, tooth)
|
||||
* smoothstep(0.42, 0.92, islandSeed);
|
||||
if (islandGate > 0.0)
|
||||
{
|
||||
float side = islandSeed < 0.78 ? -1.0 : 1.0;
|
||||
float2 islandCenter = contactPoint
|
||||
+ sampleNormal * side * tip.z * (0.88 + laneEdge * 0.55)
|
||||
+ sampleTangent * (islandSeed - 0.5) * tip.w * 0.22;
|
||||
float islandRadius = max(tip.z * (0.30 + laneEdge * 0.22), 0.060);
|
||||
float islandDistance = length(world - islandCenter);
|
||||
float islandContact = smoothstep(1.0, 0.0, islandDistance / islandRadius);
|
||||
dryIslandPeak = max(dryIslandPeak, pigment * islandGate * islandContact * 5.2);
|
||||
|
||||
float2 fleckSeedPoint = contactPoint * 61.0 + float2((float)sampleIndex * 0.17, (float)tuftIndex * 0.23);
|
||||
float fleckSeed = bokushoHashNoiseCell(fleckSeedPoint, paperKey, 0xF1E57A2Du);
|
||||
float fleckGate = islandGate
|
||||
* smoothstep(0.44 - releasePigment * 0.18, 0.88, fleckSeed)
|
||||
* smoothstep(0.56, 1.0, laneEdge)
|
||||
* (0.12 + releaseAuthority * 0.88)
|
||||
* (1.0 + releasePigment * 1.15);
|
||||
if (fleckGate > 0.0)
|
||||
{
|
||||
float fleckSide = fleckSeed < 0.86 ? side : -side;
|
||||
float fleckReach = 0.72 + releaseAuthority * 0.28;
|
||||
float2 fleckCenter = contactPoint
|
||||
+ sampleNormal * fleckSide * tip.z * (1.92 + laneEdge * 0.82 + fleckSeed * 0.36) * fleckReach
|
||||
+ sampleTangent * (fleckSeed - 0.5) * tip.w * 0.42 * fleckReach;
|
||||
float fleckRadius = max(tip.z * (0.12 + laneEdge * 0.05), 0.030);
|
||||
float fleckDistance = length(world - fleckCenter);
|
||||
float fleckContact = smoothstep(1.0, 0.0, fleckDistance / fleckRadius);
|
||||
dryFleckPeak = max(dryFleckPeak, pigment * fleckGate * fleckContact * 22.0);
|
||||
}
|
||||
|
||||
float2 fraySeedPoint = contactPoint * 47.0 + float2((float)sampleIndex * 0.29, (float)tuftIndex * 0.37);
|
||||
float fraySeed = bokushoHashNoiseCell(fraySeedPoint, paperKey, 0x8D3F9A21u);
|
||||
float frayGate = islandGate
|
||||
* releasePigment
|
||||
* (0.40 + releaseAuthority * 0.60)
|
||||
* smoothstep(0.28, 0.82, fraySeed);
|
||||
if (frayGate > 0.0)
|
||||
{
|
||||
float fraySide = fraySeed < 0.70 ? side : -side;
|
||||
float frayReach = 0.78 + releaseAuthority * 0.22;
|
||||
float2 frayCenter = contactPoint
|
||||
+ sampleNormal * fraySide * tip.z * (1.48 + laneEdge * 0.62 + fraySeed * 0.30) * frayReach
|
||||
+ sampleTangent * (fraySeed - 0.5) * tip.w * 0.34 * frayReach;
|
||||
float frayRadius = max(tip.z * (0.095 + laneEdge * 0.040), 0.024);
|
||||
float frayDistance = length(world - frayCenter);
|
||||
float frayContact = smoothstep(1.0, 0.0, frayDistance / frayRadius);
|
||||
dryFleckPeak = max(dryFleckPeak, pigment * frayGate * frayContact * 26.0);
|
||||
}
|
||||
|
||||
float2 satelliteSeedPoint = contactPoint * 83.0 + float2((float)tuftIndex * 0.31, (float)sampleIndex * 0.11);
|
||||
float satelliteSeed = bokushoHashNoiseCell(satelliteSeedPoint, paperKey, 0x5A771EAFu);
|
||||
float satelliteGate = islandGate
|
||||
* releasePigment
|
||||
* releaseAuthority
|
||||
* smoothstep(0.66, 1.0, laneEdge)
|
||||
* smoothstep(0.36, 0.86, satelliteSeed);
|
||||
if (satelliteGate > 0.0)
|
||||
{
|
||||
float satelliteSide = satelliteSeed < 0.52 ? side : -side;
|
||||
float satelliteReach = 0.62 + releaseAuthority * 0.38;
|
||||
float2 satelliteCenter = contactPoint
|
||||
+ sampleNormal * satelliteSide * tip.z * (2.02 + laneEdge * 0.78 + satelliteSeed * 0.34) * satelliteReach
|
||||
+ sampleTangent * (satelliteSeed - 0.5) * tip.w * 0.50 * satelliteReach;
|
||||
float satelliteRadius = max(tip.z * (0.075 + laneEdge * 0.035), 0.020);
|
||||
float satelliteDistance = length(world - satelliteCenter);
|
||||
float satelliteContact = smoothstep(1.0, 0.0, satelliteDistance / satelliteRadius);
|
||||
dryFleckPeak = max(dryFleckPeak, pigment * satelliteGate * satelliteContact * 38.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float decisiveInk = saturate((pigmentPeak - 0.012) * 2.25 + pigmentFlow * 0.002);
|
||||
float islandInk = saturate((dryIslandPeak - 0.001) * 14.0);
|
||||
float fleckInk = saturate((dryFleckPeak - 0.001) * 36.0);
|
||||
return saturate(decisiveInk + islandInk + fleckInk) * hold * projectionGate * (0.36 + pressure * 0.44 + saturate(bokushoMaterial.z * 0.5) * 0.20);
|
||||
return decisiveInk * hold * projectionGate * (0.36 + pressure * 0.44 + saturate(bokushoMaterial.z * 0.5) * 0.20);
|
||||
}
|
||||
|
||||
float bokushoPageHeight(float2 world)
|
||||
|
|
|
|||
|
|
@ -377,34 +377,6 @@ public sealed class BokushoBrushSimulationTests
|
|||
Assert.True(dryEdgeReleases > dryResult.SampleCount / 4, $"dry={dryEdgeReleases}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CpuBrushProjectionCreatesDryEdgeIslandsFromTuftState()
|
||||
{
|
||||
var dry = LaneCohesionFrame(wetness: 0.52f, inkLoad: 1.46f, splay: 1.12f);
|
||||
var dryResult = BokushoBrushSimulation.Evaluate(dry);
|
||||
var strippedCanvas = WithoutEdgeTuftPigment(dryResult.Canvas, dryResult.SampleCount, dryResult.TuftCount);
|
||||
var dryPage = BokushoBrushSimulation.ProjectCanvasToPage(dry, dryResult.Canvas, dryResult.Tips, 128, 128, Vector2.Zero, 4.0f);
|
||||
var strippedPage = BokushoBrushSimulation.ProjectCanvasToPage(dry, strippedCanvas, dryResult.Tips, 128, 128, Vector2.Zero, 4.0f);
|
||||
var dryFringe = CountFringeInk(dryPage, 128, 128, viewRadius: 4.0f, threshold: 0.018f);
|
||||
var strippedFringe = CountFringeInk(strippedPage, 128, 128, viewRadius: 4.0f, threshold: 0.018f);
|
||||
var dryCore = SamplePage(dryPage, 128, 128, Vector2.Zero, 4.0f);
|
||||
|
||||
Assert.True(dryCore > 0.01f);
|
||||
Assert.True(dryFringe > strippedFringe + 8, $"full={dryFringe}; stripped={strippedFringe}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CpuBrushProjectionLiftsIsolatedReleasePigmentAsFringeFlecks()
|
||||
{
|
||||
var dry = LaneCohesionFrame(wetness: 0.42f, inkLoad: 1.46f, splay: 1.16f);
|
||||
var result = BokushoBrushSimulation.Evaluate(dry);
|
||||
var isolatedCanvas = IsolatedEdgeReleaseCanvas(result.Canvas, result.SampleCount, result.TuftCount);
|
||||
var isolatedPage = BokushoBrushSimulation.ProjectCanvasToPage(dry, isolatedCanvas, result.Tips, 128, 128, Vector2.Zero, 4.0f);
|
||||
var isolatedSmallComponents = CountSmallPageComponents(isolatedPage, 128, 128, threshold: 0.018f, maxSize: 28);
|
||||
|
||||
Assert.True(isolatedSmallComponents > 6, $"isolated={isolatedSmallComponents}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CpuBrushSourceStrokeIdPreventsAccidentalSegmentReplay()
|
||||
{
|
||||
|
|
@ -859,121 +831,6 @@ public sealed class BokushoBrushSimulationTests
|
|||
return variation / MathF.Max(total, 0.001f);
|
||||
}
|
||||
|
||||
private static int CountFringeInk(IReadOnlyList<float> page, int width, int height, float viewRadius, float threshold)
|
||||
{
|
||||
var count = 0;
|
||||
for (var y = 0; y < height; y++)
|
||||
{
|
||||
var uvY = height <= 1 ? 0.0f : y / (float)(height - 1);
|
||||
var worldY = (uvY * 2.0f - 1.0f) * viewRadius;
|
||||
if (MathF.Abs(worldY) < 0.42f || MathF.Abs(worldY) > 1.35f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var x = 0; x < width; x++)
|
||||
{
|
||||
if (page[y * width + x] > threshold)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static int CountSmallPageComponents(IReadOnlyList<float> page, int width, int height, float threshold, int maxSize)
|
||||
{
|
||||
var visited = new bool[page.Count];
|
||||
var stack = new Stack<int>();
|
||||
var components = 0;
|
||||
for (var index = 0; index < page.Count; index++)
|
||||
{
|
||||
if (visited[index] || page[index] <= threshold)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var size = 0;
|
||||
visited[index] = true;
|
||||
stack.Push(index);
|
||||
while (stack.Count > 0)
|
||||
{
|
||||
var current = stack.Pop();
|
||||
size++;
|
||||
var x = current % width;
|
||||
var y = current / width;
|
||||
TryVisit(x - 1, y);
|
||||
TryVisit(x + 1, y);
|
||||
TryVisit(x, y - 1);
|
||||
TryVisit(x, y + 1);
|
||||
}
|
||||
|
||||
if (size <= maxSize)
|
||||
{
|
||||
components++;
|
||||
}
|
||||
}
|
||||
|
||||
return components;
|
||||
|
||||
void TryVisit(int x, int y)
|
||||
{
|
||||
if (x < 0 || x >= width || y < 0 || y >= height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var next = y * width + x;
|
||||
if (!visited[next] && page[next] > threshold)
|
||||
{
|
||||
visited[next] = true;
|
||||
stack.Push(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static float[] WithoutEdgeTuftPigment(IReadOnlyList<float> canvas, int sampleCount, int tuftCount)
|
||||
{
|
||||
var stripped = canvas.ToArray();
|
||||
for (var tuft = 0; tuft < tuftCount; tuft++)
|
||||
{
|
||||
var laneT = tuftCount <= 1 ? 0.5f : tuft / (float)(tuftCount - 1);
|
||||
if (MathF.Abs(laneT * 2.0f - 1.0f) < 0.28f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var sample = 0; sample < sampleCount; sample++)
|
||||
{
|
||||
stripped[tuft * sampleCount + sample] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return stripped;
|
||||
}
|
||||
|
||||
private static float[] IsolatedEdgeReleaseCanvas(IReadOnlyList<float> canvas, int sampleCount, int tuftCount)
|
||||
{
|
||||
var isolated = new float[canvas.Count];
|
||||
for (var tuft = 0; tuft < tuftCount; tuft++)
|
||||
{
|
||||
var laneT = tuftCount <= 1 ? 0.5f : tuft / (float)(tuftCount - 1);
|
||||
if (MathF.Abs(laneT * 2.0f - 1.0f) < 0.55f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var sample = 2; sample < sampleCount - 2; sample += 9)
|
||||
{
|
||||
isolated[tuft * sampleCount + sample] = MathF.Max(canvas[tuft * sampleCount + sample], 0.42f);
|
||||
}
|
||||
}
|
||||
|
||||
return isolated;
|
||||
}
|
||||
|
||||
private static float[] LastSampleOnly(IReadOnlyList<float> canvas, int sampleCount, int tuftCount)
|
||||
{
|
||||
var sparse = new float[canvas.Count];
|
||||
|
|
|
|||
Loading…
Reference in a new issue