From 98881132825ce4db883bb4d5bc6914cf1996469d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 16 Jun 2026 03:09:48 +0100 Subject: [PATCH] Align Bokusho page tangent sampling --- .../Render/Shaders/D3D12BokushoBrush.hlsl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12BokushoBrush.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12BokushoBrush.hlsl index fc2b791..4ba8fc2 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12BokushoBrush.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12BokushoBrush.hlsl @@ -54,6 +54,14 @@ float2 StrokeTangent(BokushoBrushStroke stroke, float t) return cultmath_normalize(after - before); } +float2 StrokeTangent(BokushoBrushStroke stroke, float t, uint stepCount) +{ + float dt = 1.0 / max((float)stepCount - 1.0, 1.0); + float2 before = StrokePoint(stroke, saturate(t - dt)); + float2 after = StrokePoint(stroke, saturate(t + dt)); + return cultmath_normalize(after - before); +} + float StrokeTaper(float t) { float entry = cultmath_smoothstep(0.0, 0.10, t); @@ -324,7 +332,7 @@ void SimulateBokushoTuftSegmentToPage( { float t = stepCount <= 1u ? 0.0 : (float)step / (float)(stepCount - 1u); float2 center = StrokePoint(stroke, t); - float2 tangent = StrokeTangent(stroke, t); + float2 tangent = StrokeTangent(stroke, t, stepCount); float2 normal = float2(-tangent.y, tangent.x); float taper = StrokeTaper(stroke, t); float localPressure = pressure * taper;