Carry more Bokusho ink without clipping

This commit is contained in:
Meta Vens 2026-06-15 22:10:46 +01:00
commit 0a06f7a25f
3 changed files with 16 additions and 9 deletions

View file

@ -567,7 +567,7 @@ public sealed class AquariumBokushoBrushFrame
PhysicsHz = Math.Clamp(PhysicsHz, 60.0f, 2000.0f),
BrushRadius = MathF.Max(0.0001f, BrushRadius),
Pressure = Math.Clamp(Pressure, 0.0f, 2.0f),
InkLoad = Math.Clamp(InkLoad, 0.0f, 2.0f),
InkLoad = Math.Clamp(InkLoad, 0.0f, 3.0f),
Wetness = Math.Clamp(Wetness, 0.0f, 1.6f),
Splay = Math.Clamp(Splay, 0.0f, 2.0f),
Bend = Math.Clamp(Bend, 0.0f, 2.4f),

View file

@ -55,7 +55,7 @@ public static class BokushoBrushSimulation
}
var wetness = Saturate(frame.Wetness / 1.6f);
var load = Math.Clamp(frame.InkLoad / 1.25f, 0.0f, 1.8f);
var load = Math.Clamp(frame.InkLoad / 1.05f, 0.0f, 2.7f);
var splay = Saturate(frame.Splay / 2.0f);
var bend = Saturate(frame.Bend / 2.4f);
var friction = Saturate(frame.Friction);
@ -123,7 +123,7 @@ public static class BokushoBrushSimulation
var strokes = EffectiveStrokes(frame);
var page = new float[checked(width * height)];
var wetness = Saturate(frame.Wetness / 1.6f);
var load = Math.Clamp(frame.InkLoad / 1.25f, 0.0f, 1.8f);
var load = Math.Clamp(frame.InkLoad / 1.05f, 0.0f, 2.7f);
var splay = Saturate(frame.Splay / 2.0f);
var bend = Saturate(frame.Bend / 2.4f);
var friction = Saturate(frame.Friction);
@ -245,7 +245,7 @@ public static class BokushoBrushSimulation
{
var index = ((strokeIndex * tuftCount) + tuft) * sampleCount + sample;
var pigment = (contactTransfer * (0.95f + localPressure * 0.34f + sweptPatch * 0.24f) + airborneRelease * (1.6f + velocity * 0.002f)) * stroke.PigmentScale;
canvas[index] = Saturate(pigment);
canvas[index] = CanvasPigment(pigment);
trace[index] = Saturate(contact * 0.70f + airborneRelease * 2.0f + stateLoad * 0.18f);
tips[index] = new Vector4(
tip.X,
@ -612,8 +612,8 @@ public static class BokushoBrushSimulation
var sweepLength = sweep.Length();
var tangent = sweepLength > 0.000001f ? sweep / sweepLength : Vector2.UnitX;
var normal = new Vector2(-tangent.Y, tangent.X);
var patchTangentRadius = MathF.Max(tangentRadius * 0.22f + sweepLength * 0.5f, 0.001f);
var patchNormalRadius = MathF.Max(normalRadius * 0.16f, 0.001f);
var patchTangentRadius = MathF.Max(tangentRadius * 0.26f + sweepLength * 0.5f, 0.001f);
var patchNormalRadius = MathF.Max(normalRadius * 0.20f, 0.001f);
var center = (previousTip + tip) * 0.5f;
var extents = new Vector2(
MathF.Abs(tangent.X) * patchTangentRadius + MathF.Abs(normal.X) * patchNormalRadius,
@ -645,7 +645,7 @@ public static class BokushoBrushSimulation
}
var sampleIndex = y * width + x;
var contribution = ink * coverage * 0.002f;
var contribution = ink * coverage * 0.0032f;
page[sampleIndex] = 1.0f - (1.0f - page[sampleIndex]) * (1.0f - contribution);
}
}
@ -731,6 +731,8 @@ public static class BokushoBrushSimulation
private static float Lerp(float left, float right, float t) => left + (right - left) * t;
private static float CanvasPigment(float value) => 0.96f * (1.0f - MathF.Exp(-MathF.Max(value, 0.0f) * 0.82f));
private static float SmoothStep(float edge0, float edge1, float x)
{
var t = Saturate((x - edge0) / (edge1 - edge0));

View file

@ -71,6 +71,11 @@ float StrokeSegmentSpan(BokushoBrushStroke stroke, uint sampleCount)
return max(endValue - start, 1.0 / max((float)(sampleCount - 1u), 1.0));
}
float CanvasPigment(float value)
{
return 0.96 * (1.0 - exp(-max(value, 0.0) * 0.82));
}
float LaneHash(uint strokeIndex, uint tuft, uint salt)
{
uint value = (strokeIndex + 1u) * 0x9E3779B9u ^ (tuft + 1u) * 0x85EBCA6Bu ^ salt;
@ -180,7 +185,7 @@ void SimulateBokushoTuftSegment(
{
uint index = ((outputStrokeIndex * tuftCount) + tuft) * sampleCount + sample;
float pigment = (contactTransfer * (0.95 + localPressure * 0.34 + sweptPatch * 0.24) + airborneRelease * (1.6 + velocity * 0.002)) * stroke.dynamics.z;
float localPigment = saturate(pigment);
float localPigment = CanvasPigment(pigment);
float trace = saturate(contact * 0.70 + airborneRelease * 2.0 + stateLoad * 0.18);
BokushoTraceField[index] = trace;
BokushoCanvasField[index] = localPigment;
@ -216,7 +221,7 @@ void D3D12BokushoBrushCS(uint3 dispatchThreadId : SV_DispatchThreadID)
float laneLoad = 0.76 + laneHash * 0.34;
float seedPressure = saturate(brushMaterial.y * seedStroke.profile.y * 0.5) * 2.0;
float wetness = saturate(brushMaterial.w / 1.6);
float load = clamp(brushMaterial.z / 1.25, 0.0, 1.8);
float load = clamp(brushMaterial.z / 1.05, 0.0, 2.7);
float splay = saturate(brushDynamics.x / 2.0);
float seedRadius = max(brushMaterial.x * seedStroke.profile.x, 0.0001);
float seedNormalRadius = max(seedRadius * seedStroke.profile.z, 0.0001);