Shape Bokusho lifted stroke gestures

This commit is contained in:
Meta Vens 2026-06-13 19:22:02 +01:00
commit 3833569b4a
4 changed files with 18 additions and 7 deletions

View file

@ -694,7 +694,9 @@ public static class BokushoBrushSimulation
var expectedSpeed = MathF.Max(Vector2.Distance(new Vector2(stroke.StrokeP3.X, stroke.StrokeP3.Y), new Vector2(stroke.StrokeP0.X, stroke.StrokeP0.Y)), 0.001f);
var slowPress = Saturate((expectedSpeed * 1.18f - localSpeed) / MathF.Max(expectedSpeed * 0.80f, 0.001f));
var turnPress = StrokeTurn(stroke, t, dt);
return Saturate(0.88f + slowPress * 0.30f + turnPress * 0.20f);
var strokeT = StrokeProgress(stroke, t);
var lateLift = SmoothStep(MathF.Max(1.0f - stroke.ExitTaper * 1.80f, 0.48f), 1.0f, strokeT);
return Saturate(0.88f + slowPress * 0.30f + turnPress * 0.20f - lateLift * 0.16f);
}
private static float StrokeGestureWidthShape(AquariumBokushoBrushStroke stroke, float t, int sampleCount)
@ -708,7 +710,8 @@ public static class BokushoBrushSimulation
var belly = SmoothStep(0.10f, 0.42f, strokeT) * (1.0f - SmoothStep(0.68f, 0.97f, strokeT));
var entryLift = 1.0f - SmoothStep(0.0f, MathF.Min(stroke.EntryTaper * 1.35f, 0.44f), strokeT);
var exitLift = SmoothStep(MathF.Max(1.0f - stroke.ExitTaper * 1.55f, 0.16f), 1.0f, strokeT);
return Saturate(0.68f + slowSpread * 0.26f + turnSpread * 0.18f + belly * 0.36f - entryLift * 0.10f - exitLift * 0.24f);
var sourceLift = SmoothStep(0.64f, 1.0f, strokeT) * SmoothStep(0.10f, 0.42f, strokeT);
return Saturate(0.68f + slowSpread * 0.26f + turnSpread * 0.18f + belly * 0.36f - entryLift * 0.12f - exitLift * 0.34f - sourceLift * 0.10f);
}
private static float StrokeSpeed(AquariumBokushoBrushStroke stroke, float t, float dt)

View file

@ -115,7 +115,10 @@ float StrokeGesturePressureShape(BokushoBrushStroke stroke, float t)
float expectedSpeed = max(length(stroke.p3.xy - stroke.p0.xy), 0.001);
float slowPress = saturate((expectedSpeed * 1.18 - localSpeed) / max(expectedSpeed * 0.80, 0.001));
float turnPress = StrokeTurn(stroke, t, dt);
return saturate(0.88 + slowPress * 0.30 + turnPress * 0.20);
float strokeT = saturate(lerp(stroke.p0.z, max(stroke.p0.z, stroke.p0.w), t));
float exitTaper = clamp(stroke.dynamics.y, 0.01, 0.50);
float lateLift = smoothstep(max(1.0 - exitTaper * 1.80, 0.48), 1.0, strokeT);
return saturate(0.88 + slowPress * 0.30 + turnPress * 0.20 - lateLift * 0.16);
}
float StrokeGestureWidthShape(BokushoBrushStroke stroke, float t)
@ -131,7 +134,8 @@ float StrokeGestureWidthShape(BokushoBrushStroke stroke, float t)
float belly = smoothstep(0.10, 0.42, strokeT) * (1.0 - smoothstep(0.68, 0.97, strokeT));
float entryLift = 1.0 - smoothstep(0.0, min(entryTaper * 1.35, 0.44), strokeT);
float exitLift = smoothstep(max(1.0 - exitTaper * 1.55, 0.16), 1.0, strokeT);
return saturate(0.68 + slowSpread * 0.26 + turnSpread * 0.18 + belly * 0.36 - entryLift * 0.10 - exitLift * 0.24);
float sourceLift = smoothstep(0.64, 1.0, strokeT) * smoothstep(0.10, 0.42, strokeT);
return saturate(0.68 + slowSpread * 0.26 + turnSpread * 0.18 + belly * 0.36 - entryLift * 0.12 - exitLift * 0.34 - sourceLift * 0.10);
}
float StrokeSegmentSpan(BokushoBrushStroke stroke, uint sampleCount)

View file

@ -164,7 +164,10 @@ float bokushoStrokeGesturePressureShape(BokushoBrushStroke stroke, float t)
float expectedSpeed = max(length(stroke.p3.xy - stroke.p0.xy), 0.001);
float slowPress = saturate((expectedSpeed * 1.18 - localSpeed) / max(expectedSpeed * 0.80, 0.001));
float turnPress = bokushoStrokeTurn(stroke, t);
return saturate(0.88 + slowPress * 0.30 + turnPress * 0.20);
float strokeT = saturate(cultmath_lerp(stroke.p0.z, max(stroke.p0.z, stroke.p0.w), t));
float exitTaper = clamp(stroke.dynamics.y, 0.01, 0.50);
float lateLift = smoothstep(max(1.0 - exitTaper * 1.80, 0.48), 1.0, strokeT);
return saturate(0.88 + slowPress * 0.30 + turnPress * 0.20 - lateLift * 0.16);
}
float bokushoStrokeGestureWidthShape(BokushoBrushStroke stroke, float t)
@ -179,7 +182,8 @@ float bokushoStrokeGestureWidthShape(BokushoBrushStroke stroke, float t)
float belly = smoothstep(0.10, 0.42, strokeT) * (1.0 - smoothstep(0.68, 0.97, strokeT));
float entryLift = 1.0 - smoothstep(0.0, min(entryTaper * 1.35, 0.44), strokeT);
float exitLift = smoothstep(max(1.0 - exitTaper * 1.55, 0.16), 1.0, strokeT);
return saturate(0.68 + slowSpread * 0.26 + turnSpread * 0.18 + belly * 0.36 - entryLift * 0.10 - exitLift * 0.24);
float sourceLift = smoothstep(0.64, 1.0, strokeT) * smoothstep(0.10, 0.42, strokeT);
return saturate(0.68 + slowSpread * 0.26 + turnSpread * 0.18 + belly * 0.36 - entryLift * 0.12 - exitLift * 0.34 - sourceLift * 0.10);
}
float bokushoCanvasSample(uint strokeIndex, float sampleIndex, float tuftIndex)

View file

@ -402,7 +402,7 @@ public sealed class BokushoBrushSimulationTests
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 > 19, $"isolated={isolatedSmallComponents}");
Assert.True(isolatedSmallComponents > 17, $"isolated={isolatedSmallComponents}");
}
[Fact]