Release dry pigment from torn Bokusho bristles
This commit is contained in:
parent
6a55921bc2
commit
64205786cc
3 changed files with 77 additions and 8 deletions
|
|
@ -189,8 +189,21 @@ public static class BokushoBrushSimulation
|
|||
var depositBody = 0.70f + laneCore * 0.58f - edgeComb * 0.14f;
|
||||
var depositIntermittency = (1.0f - fiberGate * dryMemory * (0.48f + edge * 0.24f)) * bristleContinuity;
|
||||
var deposition = contact * stateLoad * stateWet * Saturate(0.10f + drag * 0.72f + velocity * 0.010f) * (0.74f + separation * 0.18f + cohesion * 0.26f) * depositBody * depositIntermittency;
|
||||
stateLoad = MathF.Max(0.0f, stateLoad - deposition * segmentSpan * (0.032f + localPressure * 0.020f - cohesion * 0.008f));
|
||||
stateWet = MathF.Max(0.0f, stateWet - deposition * segmentSpan * (0.010f + dryMemory * 0.004f + edgeComb * 0.003f));
|
||||
var releaseNoise = LaneHash(laneKey + sample * 41, tuft, 307);
|
||||
var releaseGate = SmoothStep(0.38f, 0.92f, releaseNoise)
|
||||
* bristleTear
|
||||
* dryMemory
|
||||
* edgeComb
|
||||
* (1.0f - laneCore * 0.72f);
|
||||
var dryRelease = contact
|
||||
* stateLoad
|
||||
* stateWet
|
||||
* releaseGate
|
||||
* Saturate(0.18f + velocity * 0.012f + separation * 0.32f)
|
||||
* (0.18f + edge * 0.34f);
|
||||
var consumedPigment = deposition + dryRelease * 0.72f;
|
||||
stateLoad = MathF.Max(0.0f, stateLoad - consumedPigment * segmentSpan * (0.032f + localPressure * 0.020f - cohesion * 0.008f));
|
||||
stateWet = MathF.Max(0.0f, stateWet - consumedPigment * segmentSpan * (0.010f + dryMemory * 0.004f + edgeComb * 0.003f));
|
||||
|
||||
if (writeOutput)
|
||||
{
|
||||
|
|
@ -198,8 +211,10 @@ public static class BokushoBrushSimulation
|
|||
var pigmentSurvival = 0.62f + cohesion * 0.30f + laneCore * 0.36f - split * 0.08f - dryMemory * 0.12f;
|
||||
var joinBlend = SegmentJoinBlend(strokes, strokeIndex, stroke, t);
|
||||
var pigment = deposition * (8.4f + contact * 2.8f) + contact * stateLoad * stateWet * (0.14f + laneCore * 0.18f) + adhesion * contact * 0.08f;
|
||||
canvas[index] = Saturate(pigment * pigmentSurvival * stroke.PigmentScale * joinBlend * bristleContinuity);
|
||||
trace[index] = Saturate((contact * (0.24f + stateLoad * 0.36f + adhesion * 0.18f + laneCore * 0.12f) + deposition * 1.9f) * joinBlend * (0.72f + bristleContinuity * 0.28f));
|
||||
var continuousPigment = pigment * pigmentSurvival * stroke.PigmentScale * joinBlend * bristleContinuity;
|
||||
var releasePigment = dryRelease * (18.0f + velocity * 0.022f) * stroke.PigmentScale * joinBlend * (0.46f + edgeComb * 0.54f);
|
||||
canvas[index] = Saturate(continuousPigment + releasePigment);
|
||||
trace[index] = Saturate((contact * (0.24f + stateLoad * 0.36f + adhesion * 0.18f + laneCore * 0.12f) + deposition * 1.9f + dryRelease * 2.8f) * joinBlend * (0.72f + bristleContinuity * 0.28f));
|
||||
tips[index] = new Vector4(
|
||||
tip.X,
|
||||
tip.Y,
|
||||
|
|
|
|||
|
|
@ -279,8 +279,21 @@ void SimulateBokushoTuftSegment(
|
|||
float depositBody = 0.70 + laneCore * 0.58 - edgeComb * 0.14;
|
||||
float depositIntermittency = (1.0 - fiberGate * dryMemory * (0.48 + edge * 0.24)) * bristleContinuity;
|
||||
float deposition = contact * stateLoad * stateWet * saturate(0.10 + drag * 0.72 + velocity * 0.010) * (0.74 + separation * 0.18 + cohesion * 0.26) * depositBody * depositIntermittency;
|
||||
stateLoad = max(0.0, stateLoad - deposition * segmentSpan * (0.032 + localPressure * 0.020 - cohesion * 0.008));
|
||||
stateWet = max(0.0, stateWet - deposition * segmentSpan * (0.010 + dryMemory * 0.004 + edgeComb * 0.003));
|
||||
float releaseNoise = LaneHash(laneKey + sample * 41u, tuft, 307u);
|
||||
float releaseGate = smoothstep(0.38, 0.92, releaseNoise)
|
||||
* bristleTear
|
||||
* dryMemory
|
||||
* edgeComb
|
||||
* (1.0 - laneCore * 0.72);
|
||||
float dryRelease = contact
|
||||
* stateLoad
|
||||
* stateWet
|
||||
* releaseGate
|
||||
* saturate(0.18 + velocity * 0.012 + separation * 0.32)
|
||||
* (0.18 + edge * 0.34);
|
||||
float consumedPigment = deposition + dryRelease * 0.72;
|
||||
stateLoad = max(0.0, stateLoad - consumedPigment * segmentSpan * (0.032 + localPressure * 0.020 - cohesion * 0.008));
|
||||
stateWet = max(0.0, stateWet - consumedPigment * segmentSpan * (0.010 + dryMemory * 0.004 + edgeComb * 0.003));
|
||||
|
||||
if (writeOutput)
|
||||
{
|
||||
|
|
@ -288,8 +301,10 @@ void SimulateBokushoTuftSegment(
|
|||
float pigmentSurvival = 0.62 + cohesion * 0.30 + laneCore * 0.36 - split * 0.08 - dryMemory * 0.12;
|
||||
float joinBlend = SegmentJoinBlend(outputStrokeIndex, stroke, t);
|
||||
float pigment = deposition * (8.4 + contact * 2.8) + contact * stateLoad * stateWet * (0.14 + laneCore * 0.18) + adhesion * contact * 0.08;
|
||||
float localPigment = saturate(pigment * pigmentSurvival * stroke.dynamics.z * joinBlend * bristleContinuity);
|
||||
float trace = saturate((contact * (0.24 + stateLoad * 0.36 + adhesion * 0.18 + laneCore * 0.12) + deposition * 1.9) * joinBlend * (0.72 + bristleContinuity * 0.28));
|
||||
float continuousPigment = pigment * pigmentSurvival * stroke.dynamics.z * joinBlend * bristleContinuity;
|
||||
float releasePigment = dryRelease * (18.0 + velocity * 0.022) * stroke.dynamics.z * joinBlend * (0.46 + edgeComb * 0.54);
|
||||
float localPigment = saturate(continuousPigment + releasePigment);
|
||||
float trace = saturate((contact * (0.24 + stateLoad * 0.36 + adhesion * 0.18 + laneCore * 0.12) + deposition * 1.9 + dryRelease * 2.8) * joinBlend * (0.72 + bristleContinuity * 0.28));
|
||||
BokushoTraceField[index] = trace;
|
||||
BokushoCanvasField[index] = localPigment;
|
||||
BokushoTipField[index] = float4(
|
||||
|
|
|
|||
|
|
@ -364,6 +364,19 @@ public sealed class BokushoBrushSimulationTests
|
|||
Assert.True(edgeRoughness > centerRoughness * 1.20f, $"center={centerRoughness:0.000000}; edge={edgeRoughness:0.000000}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CpuBrushDryTearsReleaseEdgePigmentIntoCanvas()
|
||||
{
|
||||
var dry = LaneCohesionFrame(wetness: 0.46f, inkLoad: 1.48f, splay: 1.14f);
|
||||
|
||||
var dryResult = BokushoBrushSimulation.Evaluate(dry);
|
||||
var dryEdgeReleases = CountEdgeReleaseSamples(dryResult.Canvas, dryResult.SampleCount, dryResult.TuftCount, threshold: 0.055f);
|
||||
var dryCenter = TuftSum(dryResult.Canvas, dryResult.SampleCount, dryResult.TuftCount / 2);
|
||||
|
||||
Assert.True(dryCenter > 0.30f);
|
||||
Assert.True(dryEdgeReleases > dryResult.SampleCount / 4, $"dry={dryEdgeReleases}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CpuBrushProjectionCreatesDryEdgeIslandsFromTuftState()
|
||||
{
|
||||
|
|
@ -746,6 +759,32 @@ public sealed class BokushoBrushSimulationTests
|
|||
return canvas.Skip(tuft * sampleCount).Take(sampleCount).Sum();
|
||||
}
|
||||
|
||||
private static int CountEdgeReleaseSamples(IReadOnlyList<float> canvas, int sampleCount, int tuftCount, float threshold)
|
||||
{
|
||||
var count = 0;
|
||||
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 = 1; sample < sampleCount - 1; sample++)
|
||||
{
|
||||
var index = tuft * sampleCount + sample;
|
||||
var value = canvas[index];
|
||||
var neighborhood = MathF.Max(canvas[index - 1], canvas[index + 1]);
|
||||
if (value > threshold && value > neighborhood * 1.35f)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static float StrokeSum(float[] canvas, int sampleCount, int tuftCount, int stroke)
|
||||
{
|
||||
return canvas.Skip(stroke * sampleCount * tuftCount).Take(sampleCount * tuftCount).Sum();
|
||||
|
|
|
|||
Loading…
Reference in a new issue