Pull Bokusho release flecks toward brush edges
This commit is contained in:
parent
e90828baca
commit
d8eb303bbd
3 changed files with 39 additions and 5 deletions
|
|
@ -559,6 +559,23 @@ public static class BokushoBrushSimulation
|
|||
dryFleckPeak = MathF.Max(dryFleckPeak, pigment * fleckGate * fleckContact * 22.0f);
|
||||
}
|
||||
|
||||
var fraySeedPoint = contactPoint * 47.0f + new Vector2(sampleIndex * 0.29f, tuftIndex * 0.37f);
|
||||
var fraySeed = HashNoiseCell(fraySeedPoint, paperKey, 0x8D3F9A21u);
|
||||
var frayGate = islandGate
|
||||
* releasePigment
|
||||
* SmoothStep(0.28f, 0.82f, fraySeed);
|
||||
if (frayGate > 0.0f)
|
||||
{
|
||||
var fraySide = fraySeed < 0.70f ? side : -side;
|
||||
var frayCenter = contactPoint
|
||||
+ sampleNormal * fraySide * tip.Z * (1.48f + laneEdge * 0.62f + fraySeed * 0.30f)
|
||||
+ sampleTangent * (fraySeed - 0.5f) * tip.W * 0.34f;
|
||||
var frayRadius = MathF.Max(tip.Z * (0.095f + laneEdge * 0.040f), 0.024f);
|
||||
var frayDistance = MathF.Sqrt(Vector2.DistanceSquared(world, frayCenter));
|
||||
var frayContact = SmoothStep(1.0f, 0.0f, frayDistance / frayRadius);
|
||||
dryFleckPeak = MathF.Max(dryFleckPeak, pigment * frayGate * frayContact * 26.0f);
|
||||
}
|
||||
|
||||
var satelliteSeedPoint = contactPoint * 83.0f + new Vector2(tuftIndex * 0.31f, sampleIndex * 0.11f);
|
||||
var satelliteSeed = HashNoiseCell(satelliteSeedPoint, paperKey, 0x5A771EAFu);
|
||||
var satelliteGate = islandGate
|
||||
|
|
@ -568,8 +585,8 @@ public static class BokushoBrushSimulation
|
|||
{
|
||||
var satelliteSide = satelliteSeed < 0.52f ? side : -side;
|
||||
var satelliteCenter = contactPoint
|
||||
+ sampleNormal * satelliteSide * tip.Z * (2.90f + laneEdge * 1.35f + satelliteSeed * 0.72f)
|
||||
+ sampleTangent * (satelliteSeed - 0.5f) * tip.W * 0.82f;
|
||||
+ sampleNormal * satelliteSide * tip.Z * (2.34f + laneEdge * 0.96f + satelliteSeed * 0.46f)
|
||||
+ sampleTangent * (satelliteSeed - 0.5f) * tip.W * 0.64f;
|
||||
var satelliteRadius = MathF.Max(tip.Z * (0.075f + laneEdge * 0.035f), 0.020f);
|
||||
var satelliteDistance = MathF.Sqrt(Vector2.DistanceSquared(world, satelliteCenter));
|
||||
var satelliteContact = SmoothStep(1.0f, 0.0f, satelliteDistance / satelliteRadius);
|
||||
|
|
|
|||
|
|
@ -460,6 +460,23 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
dryFleckPeak = max(dryFleckPeak, pigment * fleckGate * fleckContact * 22.0);
|
||||
}
|
||||
|
||||
float2 fraySeedPoint = contactPoint * 47.0 + float2((float)sampleIndex * 0.29, (float)tuftIndex * 0.37);
|
||||
float fraySeed = bokushoHashNoiseCell(fraySeedPoint, paperKey, 0x8D3F9A21u);
|
||||
float frayGate = islandGate
|
||||
* releasePigment
|
||||
* smoothstep(0.28, 0.82, fraySeed);
|
||||
if (frayGate > 0.0)
|
||||
{
|
||||
float fraySide = fraySeed < 0.70 ? side : -side;
|
||||
float2 frayCenter = contactPoint
|
||||
+ sampleNormal * fraySide * tip.z * (1.48 + laneEdge * 0.62 + fraySeed * 0.30)
|
||||
+ sampleTangent * (fraySeed - 0.5) * tip.w * 0.34;
|
||||
float frayRadius = max(tip.z * (0.095 + laneEdge * 0.040), 0.024);
|
||||
float frayDistance = length(world - frayCenter);
|
||||
float frayContact = smoothstep(1.0, 0.0, frayDistance / frayRadius);
|
||||
dryFleckPeak = max(dryFleckPeak, pigment * frayGate * frayContact * 26.0);
|
||||
}
|
||||
|
||||
float2 satelliteSeedPoint = contactPoint * 83.0 + float2((float)tuftIndex * 0.31, (float)sampleIndex * 0.11);
|
||||
float satelliteSeed = bokushoHashNoiseCell(satelliteSeedPoint, paperKey, 0x5A771EAFu);
|
||||
float satelliteGate = islandGate
|
||||
|
|
@ -469,8 +486,8 @@ float bokushoStrokePageHeight(float2 world, BokushoBrushStroke stroke, uint stro
|
|||
{
|
||||
float satelliteSide = satelliteSeed < 0.52 ? side : -side;
|
||||
float2 satelliteCenter = contactPoint
|
||||
+ sampleNormal * satelliteSide * tip.z * (2.90 + laneEdge * 1.35 + satelliteSeed * 0.72)
|
||||
+ sampleTangent * (satelliteSeed - 0.5) * tip.w * 0.82;
|
||||
+ sampleNormal * satelliteSide * tip.z * (2.34 + laneEdge * 0.96 + satelliteSeed * 0.46)
|
||||
+ sampleTangent * (satelliteSeed - 0.5) * tip.w * 0.64;
|
||||
float satelliteRadius = max(tip.z * (0.075 + laneEdge * 0.035), 0.020);
|
||||
float satelliteDistance = length(world - satelliteCenter);
|
||||
float satelliteContact = smoothstep(1.0, 0.0, satelliteDistance / satelliteRadius);
|
||||
|
|
|
|||
|
|
@ -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 > 18, $"isolated={isolatedSmallComponents}");
|
||||
Assert.True(isolatedSmallComponents > 19, $"isolated={isolatedSmallComponents}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in a new issue