コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
a5cd6aa08f
|
||
|
|
854bf21860
|
||
|
|
4f8489057a
|
||
|
|
3f1e63f27b
|
||
|
|
971b0c4151
|
||
|
|
31520cbf4b
|
検索条件に一致するファイルはありません
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
ローポリ化 for YMM4 v2.0.0
|
||||
ローポリ化 for YMM4 v2.0.1
|
||||
========================================
|
||||
YukkuriMovieMaker4上で動作する、素材を三角形の面で塗り分けて
|
||||
ローポリ画として描画する映像エフェクトプラグインです。
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>2.0.0</Version>
|
||||
<Version>2.0.1</Version>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
|
||||
@@ -200,7 +200,7 @@ internal readonly partial struct EdgeDistanceSeedShader(
|
||||
}
|
||||
}
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
|
||||
[ThreadGroupSize(LowPolyAbstractionSettings.JumpFloodGroupWidth, 1, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct JumpFloodPixelPassShader(
|
||||
ReadWriteBuffer<int> input,
|
||||
@@ -642,7 +642,7 @@ internal readonly partial struct VoronoiScatterShader(
|
||||
}
|
||||
}
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
|
||||
[ThreadGroupSize(LowPolyAbstractionSettings.JumpFloodGroupWidth, 1, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct JumpFloodSitePassShader(
|
||||
ReadWriteBuffer<int> input,
|
||||
@@ -678,7 +678,7 @@ internal readonly partial struct JumpFloodSitePassShader(
|
||||
if (sx < 0 || sx >= workingWidth || sy < 0 || sy >= workingHeight)
|
||||
continue;
|
||||
var candidate = input[sy * workingWidth + sx];
|
||||
if (candidate < 0)
|
||||
if (candidate < 0 || candidate == best)
|
||||
continue;
|
||||
var delta = position - sitePositions[candidate];
|
||||
var distance = delta.X * delta.X + delta.Y * delta.Y;
|
||||
@@ -693,7 +693,7 @@ internal readonly partial struct JumpFloodSitePassShader(
|
||||
}
|
||||
}
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
|
||||
[ThreadGroupSize(LowPolyAbstractionSettings.AccumulateGroupDim, LowPolyAbstractionSettings.AccumulateGroupDim, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct CentroidAccumulateShader(
|
||||
ReadWriteBuffer<int> assignment,
|
||||
@@ -708,6 +708,18 @@ internal readonly partial struct CentroidAccumulateShader(
|
||||
private readonly int workingWidth = workingWidth;
|
||||
private readonly int workingHeight = workingHeight;
|
||||
|
||||
[GroupShared(LowPolyAbstractionSettings.AccumulateGroupSize)]
|
||||
private static readonly int[] groupSite = null!;
|
||||
|
||||
[GroupShared(LowPolyAbstractionSettings.AccumulateGroupSize)]
|
||||
private static readonly int[] groupWeight = null!;
|
||||
|
||||
[GroupShared(LowPolyAbstractionSettings.AccumulateGroupSize)]
|
||||
private static readonly int[] groupWeightedX = null!;
|
||||
|
||||
[GroupShared(LowPolyAbstractionSettings.AccumulateGroupSize)]
|
||||
private static readonly int[] groupWeightedY = null!;
|
||||
|
||||
private void AddCarry(int index, int value)
|
||||
{
|
||||
int previous;
|
||||
@@ -720,23 +732,51 @@ internal readonly partial struct CentroidAccumulateShader(
|
||||
{
|
||||
var x = ThreadIds.X;
|
||||
var y = ThreadIds.Y;
|
||||
if (x >= workingWidth || y >= workingHeight)
|
||||
return;
|
||||
var slot = GroupIds.Index;
|
||||
var site = -1;
|
||||
var wq = 0;
|
||||
var weightedX = 0;
|
||||
var weightedY = 0;
|
||||
if (x < workingWidth && y < workingHeight)
|
||||
{
|
||||
var index = y * workingWidth + x;
|
||||
var assigned = assignment[index];
|
||||
if (assigned >= 0)
|
||||
{
|
||||
wq = Hlsl.Max((int)(weight[index] * LowPolyAbstractionSettings.WeightScale + 0.5f), 0);
|
||||
if (wq != 0)
|
||||
{
|
||||
site = assigned;
|
||||
weightedX = wq * (x * LowPolyAbstractionSettings.PositionSubScale + LowPolyAbstractionSettings.PositionSubScale / 2);
|
||||
weightedY = wq * (y * LowPolyAbstractionSettings.PositionSubScale + LowPolyAbstractionSettings.PositionSubScale / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
groupSite[slot] = site;
|
||||
groupWeight[slot] = wq;
|
||||
groupWeightedX[slot] = weightedX;
|
||||
groupWeightedY[slot] = weightedY;
|
||||
Hlsl.GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
var index = y * workingWidth + x;
|
||||
var site = assignment[index];
|
||||
if (site < 0)
|
||||
return;
|
||||
var w = weight[index];
|
||||
var wq = Hlsl.Max((int)(w * LowPolyAbstractionSettings.WeightScale + 0.5f), 0);
|
||||
if (wq == 0)
|
||||
return;
|
||||
var xq = x * LowPolyAbstractionSettings.PositionSubScale + LowPolyAbstractionSettings.PositionSubScale / 2;
|
||||
var yq = y * LowPolyAbstractionSettings.PositionSubScale + LowPolyAbstractionSettings.PositionSubScale / 2;
|
||||
for (var other = 0; other < slot; other++)
|
||||
{
|
||||
if (groupSite[other] == site)
|
||||
return;
|
||||
}
|
||||
for (var other = slot + 1; other < LowPolyAbstractionSettings.AccumulateGroupSize; other++)
|
||||
{
|
||||
if (groupSite[other] != site)
|
||||
continue;
|
||||
wq += groupWeight[other];
|
||||
weightedX += groupWeightedX[other];
|
||||
weightedY += groupWeightedY[other];
|
||||
}
|
||||
var baseIndex = site * 6;
|
||||
AddCarry(baseIndex, wq);
|
||||
AddCarry(baseIndex + 2, wq * xq);
|
||||
AddCarry(baseIndex + 4, wq * yq);
|
||||
AddCarry(baseIndex + 2, weightedX);
|
||||
AddCarry(baseIndex + 4, weightedY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1017,13 +1057,14 @@ internal readonly partial struct TriangleMapShader(
|
||||
for (var slot = 0; slot < listed; slot++)
|
||||
{
|
||||
var triangle = incidence[site * LowPolyAbstractionSettings.MaxIncidence + slot];
|
||||
if (best >= 0 && triangle >= best)
|
||||
continue;
|
||||
var a = sitePositions[triangleVertices[triangle * 3]];
|
||||
var b = sitePositions[triangleVertices[triangle * 3 + 1]];
|
||||
var c = sitePositions[triangleVertices[triangle * 3 + 2]];
|
||||
if (LowPolyAbstractionShaderMath.ContainsPoint(a, b, c, px, py))
|
||||
{
|
||||
best = triangle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
triangleMap[index] = best;
|
||||
}
|
||||
@@ -1403,19 +1444,16 @@ internal readonly partial struct RenderShader(
|
||||
private int FindTriangle(float px, float py, int site)
|
||||
{
|
||||
var listed = Hlsl.Min(incidenceCounts[site], LowPolyAbstractionSettings.MaxIncidence);
|
||||
var best = -1;
|
||||
for (var slot = 0; slot < listed; slot++)
|
||||
{
|
||||
var triangle = incidence[site * LowPolyAbstractionSettings.MaxIncidence + slot];
|
||||
if (best >= 0 && triangle >= best)
|
||||
continue;
|
||||
var a = sitePositions[triangleVertices[triangle * 3]];
|
||||
var b = sitePositions[triangleVertices[triangle * 3 + 1]];
|
||||
var c = sitePositions[triangleVertices[triangle * 3 + 2]];
|
||||
if (LowPolyAbstractionShaderMath.ContainsPoint(a, b, c, px, py))
|
||||
best = triangle;
|
||||
return triangle;
|
||||
}
|
||||
return best;
|
||||
return -1;
|
||||
}
|
||||
|
||||
private float SourceAlpha(float x, float y)
|
||||
|
||||
@@ -317,8 +317,11 @@ internal sealed partial class LowPolyAbstractionPipelineHost
|
||||
RecordVoronoi(in context, grid, scratch, siteCapacity, in derived);
|
||||
context.For(accumulatorLength, new FillIntShader(grid.SiteAccumulators, accumulatorLength, 0));
|
||||
context.Barrier(grid.SiteAccumulators);
|
||||
context.For(derived.WorkingWidth, derived.WorkingHeight, new CentroidAccumulateShader(
|
||||
GetAssignment(grid, in derived), grid.Weight, grid.SiteAccumulators, derived.WorkingWidth, derived.WorkingHeight));
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<CentroidAccumulateShader>(derived.WorkingWidth),
|
||||
ThreadGroupAlignment.AlignY<CentroidAccumulateShader>(derived.WorkingHeight),
|
||||
new CentroidAccumulateShader(
|
||||
GetAssignment(grid, in derived), grid.Weight, grid.SiteAccumulators, derived.WorkingWidth, derived.WorkingHeight));
|
||||
context.Barrier(grid.SiteAccumulators);
|
||||
context.For(siteCapacity, new UpdateSitesShader(
|
||||
grid.SitePositions, grid.SiteKinds, grid.SiteAccumulators, scratch,
|
||||
|
||||
@@ -18,6 +18,9 @@ internal static class LowPolyAbstractionSettings
|
||||
public const int ScratchAlphaCount = 9;
|
||||
public const int ScratchPendingCount = 10;
|
||||
public const int ScanBlockSize = 1024;
|
||||
public const int JumpFloodGroupWidth = 64;
|
||||
public const int AccumulateGroupDim = 8;
|
||||
public const int AccumulateGroupSize = AccumulateGroupDim * AccumulateGroupDim;
|
||||
public const float AlphaThreshold = 0.05f;
|
||||
public const float EdgeThreshold = 0.06f;
|
||||
public const float EdgeSampleSpacingFactor = 0.02f;
|
||||
|
||||
バイナリファイルは表示されません。
|
変更前 幅: | 高さ: | サイズ: 839 KiB 変更後 幅: | 高さ: | サイズ: 837 KiB |
新しいイシューから参照
ユーザーをブロックする