Phase Bokusho fan motion by source stroke
This commit is contained in:
parent
d5de205c40
commit
107722141d
3 changed files with 30 additions and 3 deletions
|
|
@ -153,7 +153,8 @@ public static class BokushoBrushSimulation
|
|||
var poseSpread = Saturate(0.92f + MathF.Abs(stroke.ShaftTilt) * 0.22f + stroke.Compliance * 0.10f - stroke.GripHeight * 0.04f);
|
||||
var localNormalRadius = MathF.Max(normalRadius * normalShape * gestureWidth * poseSpread, 0.0001f);
|
||||
var localTangentRadius = MathF.Max(tangentRadius * tangentShape * (0.86f + gestureWidth * 0.08f + stroke.GripHeight * 0.10f), 0.0001f);
|
||||
var turn = MathF.Sin(t * MathF.Tau + strokeIndex * 0.37f);
|
||||
var turnKey = stroke.SourceStrokeId >= 0 ? stroke.SourceStrokeId : strokeIndex;
|
||||
var turn = MathF.Sin(strokeT * MathF.Tau + turnKey * 0.37f);
|
||||
var rotatedRest = restOffset + stroke.ShaftRotation * 0.10f * (1.0f - edge);
|
||||
var targetOffset = rotatedRest * localNormalRadius * (0.38f + splay * 0.52f + localPressure * 0.08f - wetness * 0.10f) + (turn + stroke.ShaftRotation * 0.22f) * localNormalRadius * 0.14f * (1.0f - edge);
|
||||
var recovery = Saturate(0.06f + stateWet * 0.10f + localPressure * 0.07f + (1.0f - edge) * 0.06f + stroke.Compliance * 0.07f);
|
||||
|
|
@ -186,7 +187,7 @@ public static class BokushoBrushSimulation
|
|||
{
|
||||
var index = ((strokeIndex * tuftCount) + tuft) * sampleCount + sample;
|
||||
var pigmentSurvival = 0.62f + cohesion * 0.30f + laneCore * 0.36f - split * 0.08f - dryMemory * 0.12f;
|
||||
var joinBlend = SegmentJoinBlend(strokes, strokeIndex, stroke, t);
|
||||
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);
|
||||
trace[index] = Saturate((contact * (0.24f + stateLoad * 0.36f + adhesion * 0.18f + laneCore * 0.12f) + deposition * 1.9f) * joinBlend);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,9 @@ void SimulateBokushoTuftSegment(
|
|||
float poseSpread = saturate(0.92 + abs(stroke.pose.x) * 0.22 + stroke.pose.w * 0.10 - stroke.pose.z * 0.04);
|
||||
float localNormalRadius = max(normalRadius * normalShape * gestureWidth * poseSpread, 0.0001);
|
||||
float localTangentRadius = max(tangentRadius * tangentShape * (0.86 + gestureWidth * 0.08 + stroke.pose.z * 0.10), 0.0001);
|
||||
float turn = sin(t * 6.28318530718 + (float)outputStrokeIndex * 0.37);
|
||||
float strokeT = saturate(lerp(stroke.p0.z, max(stroke.p0.z, stroke.p0.w), t));
|
||||
float turnKey = stroke.p3.w >= 0.0 ? stroke.p3.w : (float)outputStrokeIndex;
|
||||
float turn = sin(strokeT * 6.28318530718 + turnKey * 0.37);
|
||||
float rotatedRest = restOffset + stroke.pose.y * 0.10 * (1.0 - edge);
|
||||
float targetOffset = rotatedRest * localNormalRadius * (0.38 + splay * 0.52 + localPressure * 0.08 - wetness * 0.10) + (turn + stroke.pose.y * 0.22) * localNormalRadius * 0.14 * (1.0 - edge);
|
||||
float recovery = saturate(0.06 + stateWet * 0.10 + localPressure * 0.07 + (1.0 - edge) * 0.06 + stroke.pose.w * 0.07);
|
||||
|
|
|
|||
|
|
@ -376,6 +376,21 @@ public sealed class BokushoBrushSimulationTests
|
|||
Assert.True(MathF.Abs(sharedSecond - splitSecond) > 0.05f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CpuBrushSourceStrokeIdKeepsFanPhaseContinuousAcrossSegments()
|
||||
{
|
||||
var shared = SourceIdentityFrame(sameSourceId: true);
|
||||
var split = SourceIdentityFrame(sameSourceId: false);
|
||||
|
||||
var sharedResult = BokushoBrushSimulation.Evaluate(shared);
|
||||
var splitResult = BokushoBrushSimulation.Evaluate(split);
|
||||
var centerTuft = sharedResult.TuftCount / 2;
|
||||
var sharedJump = TipJumpAtSecondSegmentStart(sharedResult, centerTuft);
|
||||
var splitJump = TipJumpAtSecondSegmentStart(splitResult, centerTuft);
|
||||
|
||||
Assert.True(sharedJump < splitJump * 1.25f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CpuBrushGeometryEnrichesCurvedStrokePressureAndWidth()
|
||||
{
|
||||
|
|
@ -608,6 +623,15 @@ public sealed class BokushoBrushSimulationTests
|
|||
return canvas.Skip(tuft * sampleCount).Take(sampleCount).Sum();
|
||||
}
|
||||
|
||||
private static float TipJumpAtSecondSegmentStart(BokushoBrushSimulationResult result, int tuft)
|
||||
{
|
||||
var lastFirstIndex = (tuft * result.SampleCount) + result.SampleCount - 1;
|
||||
var firstSecondIndex = ((result.TuftCount + tuft) * result.SampleCount);
|
||||
var first = result.Tips[lastFirstIndex];
|
||||
var second = result.Tips[firstSecondIndex];
|
||||
return Vector2.Distance(new Vector2(first.X, first.Y), new Vector2(second.X, second.Y));
|
||||
}
|
||||
|
||||
private static float SamplePage(float[] page, int width, int height, Vector2 world, float viewRadius)
|
||||
{
|
||||
var uv = world / viewRadius * 0.5f + new Vector2(0.5f, 0.5f);
|
||||
|
|
|
|||
Loading…
Reference in a new issue