Key Bokusho paper response by source stroke

This commit is contained in:
Meta Vens 2026-06-13 15:49:20 +01:00
commit 70f5d49cc4
3 changed files with 21 additions and 2 deletions

View file

@ -393,7 +393,8 @@ public static class BokushoBrushSimulation
var distance = MathF.Sqrt(bestDistance);
var contact = SmoothStep(1.0f, 0.0f, distance / MathF.Max(footprint * 0.80f, 0.001f));
var contactCore = contact * contact * (3.0f - 2.0f * contact);
var tooth = PaperTooth(world, strokeIndex);
var paperKey = stroke.SourceStrokeId >= 0 ? stroke.SourceStrokeId : strokeIndex;
var tooth = PaperTooth(world, paperKey);
var edge = Saturate(distance / MathF.Max(footprint * 0.80f, 0.001f));
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);

View file

@ -282,7 +282,8 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
float distance = sqrt(bestDistance);
float contact = smoothstep(1.0, 0.0, distance / max(footprint * 0.80, 0.001));
float contactCore = contact * contact * (3.0 - 2.0 * contact);
float tooth = bokushoPaperTooth(world, strokeIndex);
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.80, 0.001));
float dryBreak = smoothstep(0.18 + tooth * 0.18, 0.92, edge)
* (1.0 - saturate(bokushoMaterial.w / 1.6))

View file

@ -391,6 +391,23 @@ public sealed class BokushoBrushSimulationTests
Assert.True(sharedJump < splitJump * 1.25f);
}
[Fact]
public void CpuBrushProjectionUsesSourceStrokePaperResponseAcrossSegments()
{
var shared = SourceIdentityFrame(sameSourceId: true);
var split = SourceIdentityFrame(sameSourceId: false);
var sharedResult = BokushoBrushSimulation.Evaluate(shared);
var splitResult = BokushoBrushSimulation.Evaluate(split);
var sharedPage = BokushoBrushSimulation.ProjectCanvasToPage(shared, sharedResult.Canvas, sharedResult.Tips, 128, 128, Vector2.Zero, 4.0f);
var splitPage = BokushoBrushSimulation.ProjectCanvasToPage(split, splitResult.Canvas, splitResult.Tips, 128, 128, Vector2.Zero, 4.0f);
var sharedJoin = SamplePage(sharedPage, 128, 128, new Vector2(0.0f, 0.0f), 4.0f);
var splitJoin = SamplePage(splitPage, 128, 128, new Vector2(0.0f, 0.0f), 4.0f);
Assert.True(sharedJoin > 0.0f);
Assert.True(MathF.Abs(sharedJoin - splitJoin) > 0.0001f);
}
[Fact]
public void CpuBrushGeometryEnrichesCurvedStrokePressureAndWidth()
{