コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
ab7c822925
|
||
|
|
680e2b2324
|
||
|
|
8534f62528
|
||
|
|
aaa04dc778
|
||
|
|
aaa594db41
|
||
|
|
0f743a5717
|
||
|
|
9d94c6ccfa
|
||
|
|
7bf55035f3
|
||
|
|
aa75e5e88d
|
||
|
|
1d36f4005b
|
||
|
|
7c5aae0e0b
|
||
|
|
188df42dd2
|
||
|
|
a71f87e689
|
||
|
|
761ff9125f
|
||
|
|
7c8531a6ed
|
||
|
|
49370df38a
|
||
|
|
3a2b10a387
|
||
|
|
9b66307b8c
|
||
|
|
862cc93413
|
||
|
|
7dd997d3bd
|
||
|
|
c03fccc034
|
||
|
|
70a45c7ef0
|
||
|
|
4447521b0c
|
||
|
|
e410d21685
|
||
|
|
9ce6d5943c
|
||
|
|
2f65e4d9f6
|
||
|
|
48699496de
|
||
|
|
42a1b3a003
|
||
|
|
db0dd16f4d
|
||
|
|
91592d4e03
|
検索条件に一致するファイルはありません
@@ -0,0 +1,538 @@
|
||||
name: リリース
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: リリースするタグ
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: ソースコードのチェックアウト
|
||||
uses: actions/checkout@v7
|
||||
env:
|
||||
GIT_CONFIG_COUNT: "2"
|
||||
GIT_CONFIG_KEY_0: url.https://git.routersys.com/routersys/.insteadOf
|
||||
GIT_CONFIG_VALUE_0: https://github.com/routersys/
|
||||
GIT_CONFIG_KEY_1: url.https://git.routersys.com/manju-summoner/YukkuriMovieMaker.Generator.insteadOf
|
||||
GIT_CONFIG_VALUE_1: https://github.com/manju-summoner/YukkuriMovieMaker.Generator
|
||||
with:
|
||||
ref: ${{ inputs.tag || github.ref_name }}
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: MSBuild のセットアップ
|
||||
uses: microsoft/setup-msbuild@v3
|
||||
|
||||
- name: YMM4 最新リリースの取得と解凍
|
||||
id: ymm4
|
||||
shell: pwsh
|
||||
run: |
|
||||
$list = 'C:\runner\cache\ymm4\releases.json'
|
||||
New-Item -ItemType Directory -Force -Path (Split-Path $list) | Out-Null
|
||||
if (-not (Test-Path $list) -or (Get-Item $list).Length -lt 1000 -or ((Get-Date) - (Get-Item $list).LastWriteTime).TotalHours -gt 6) {
|
||||
$fetched = $null
|
||||
for ($attempt = 1; $attempt -le 6 -and -not $fetched; $attempt++) {
|
||||
try {
|
||||
$fetched = Invoke-RestMethod -Uri "https://api.github.com/repos/manju-summoner/YukkuriMovieMaker4/releases?per_page=100" `
|
||||
-Headers @{ "User-Agent" = "MangaScreentone-CI" } -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
$message = $_.Exception.Message
|
||||
Write-Host "リリース一覧の取得に失敗しました($attempt 回目): $($message.Substring(0, [Math]::Min(80, $message.Length)))"
|
||||
Start-Sleep -Seconds (5 * $attempt)
|
||||
}
|
||||
}
|
||||
if (@($fetched).Count -gt 0) {
|
||||
$fetched | Select-Object tag_name, published_at, prerelease, draft, assets |
|
||||
ConvertTo-Json -Depth 6 | Set-Content -Path $list -Encoding UTF8
|
||||
}
|
||||
elseif (-not (Test-Path $list)) { throw 'the list of releases could not be fetched' }
|
||||
else { Write-Host '保存済みのリリース一覧を使います' }
|
||||
}
|
||||
$when = [DateTimeOffset](git log -1 --format=%cI)
|
||||
$releases = @(Get-Content -Raw -Path $list | ConvertFrom-Json | Where-Object { -not $_.draft -and -not $_.prerelease })
|
||||
$release = $releases | Where-Object { [DateTimeOffset]$_.published_at -le $when } | Select-Object -First 1
|
||||
if (-not $release) { $release = $releases | Select-Object -Last 1 }
|
||||
Write-Host "最後のコミット $when に合わせた YMM4: $($release.tag_name)"
|
||||
$asset = $release.assets | Where-Object { $_.name -like "*_Lite.zip" } | Select-Object -First 1
|
||||
if (-not $asset) {
|
||||
$asset = $release.assets | Where-Object { $_.name -like "*.zip" } | Select-Object -First 1
|
||||
}
|
||||
Write-Host "ダウンロード対象: $($asset.name)"
|
||||
$cache = Join-Path 'C:\runner\cache\ymm4' $asset.name
|
||||
$extracted = "$cache.extracted"
|
||||
$lock = New-Object System.Threading.Mutex($false, 'Global\ci-ymm4-cache')
|
||||
[void]$lock.WaitOne()
|
||||
try {
|
||||
if (-not (Test-Path "$extracted\.complete")) {
|
||||
New-Item -ItemType Directory -Force -Path (Split-Path $cache) | Out-Null
|
||||
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $cache
|
||||
Remove-Item -Recurse -Force $extracted -ErrorAction SilentlyContinue
|
||||
Expand-Archive -Path $cache -DestinationPath $extracted -Force
|
||||
New-Item -ItemType File -Path "$extracted\.complete" | Out-Null
|
||||
}
|
||||
else {
|
||||
Write-Host "保存済みの YMM4 を使います: $extracted"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$lock.ReleaseMutex()
|
||||
}
|
||||
$ymm4Dir = (Get-ChildItem -Path $extracted -Recurse -Filter "YukkuriMovieMaker.dll" |
|
||||
Select-Object -First 1).DirectoryName
|
||||
Write-Host "YMM4 DLL ディレクトリ: $ymm4Dir"
|
||||
echo "YMM4_DIR=$ymm4Dir\" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: タグ名からバージョンを取得
|
||||
id: version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$tag = "${{ inputs.tag || github.ref_name }}"
|
||||
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
|
||||
echo "VERSION=$($tag.TrimStart('v'))" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: バージョン記載の照合
|
||||
shell: pwsh
|
||||
run: |
|
||||
$tag = "${{ steps.version.outputs.TAG }}"
|
||||
$version = "${{ steps.version.outputs.VERSION }}"
|
||||
$problems = @()
|
||||
|
||||
$csprojPath = "MangaScreentone/MangaScreentone.csproj"
|
||||
$csproj = Get-Content $csprojPath -Raw
|
||||
if (-not $csproj.Contains("<Version>$version</Version>")) {
|
||||
$current = if ($csproj -match '<Version>([^<]*)</Version>') { $Matches[1] } else { "記載なし" }
|
||||
$problems += "$csprojPath の <Version> が $current です。$version にしてください。"
|
||||
}
|
||||
|
||||
$readmePath = ".github/Plugin_Readme.txt"
|
||||
$readme = Get-Content $readmePath -Raw
|
||||
if (-not $readme.Contains(" 漫画(スクリーントーン) for YMM4 $tag")) {
|
||||
$current = if ($readme -match '(?m)^ 漫画(スクリーントーン) for YMM4 (\S+)') { $Matches[1] } else { "記載なし" }
|
||||
$problems += "$readmePath の見出しが $current です。$tag にしてください。"
|
||||
}
|
||||
|
||||
if ($problems.Count -eq 0) {
|
||||
Write-Host "バージョン記載は $tag と一致しています"
|
||||
exit 0
|
||||
}
|
||||
|
||||
foreach ($problem in $problems) {
|
||||
Write-Host "::error::$problem"
|
||||
}
|
||||
Write-Host "::error::リリースの対象は $tag が指すコミットです。タグを付けた後で main へ訂正を積んでも、その訂正はリリースに入りません。タグを削除し、記載を直したコミットを積んでから付け直してください。"
|
||||
exit 1
|
||||
|
||||
- name: シェーダーのビルド
|
||||
shell: pwsh
|
||||
run: |
|
||||
msbuild MangaScreentone.Shader/MangaScreentone.Shader.vcxproj `
|
||||
/p:Configuration=Release `
|
||||
/p:Platform=Win32 `
|
||||
/nologo
|
||||
|
||||
- name: プロジェクトのビルド
|
||||
shell: pwsh
|
||||
run: |
|
||||
$proj = "MangaScreentone/MangaScreentone.csproj"
|
||||
dotnet build "$proj" `
|
||||
-c Release `
|
||||
-p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" `
|
||||
-p:Platform=x64 `
|
||||
-p:SkipPluginDeploy=true
|
||||
|
||||
- name: テストプロジェクトのビルド
|
||||
shell: pwsh
|
||||
run: |
|
||||
dotnet build MangaScreentone.Tests/MangaScreentone.Tests.csproj `
|
||||
-c Release `
|
||||
-p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" `
|
||||
-p:Platform=x64 `
|
||||
-p:SkipPluginDeploy=true `
|
||||
-maxcpucount:1
|
||||
|
||||
- name: テストの実行
|
||||
shell: pwsh
|
||||
run: |
|
||||
dotnet test MangaScreentone.Tests/MangaScreentone.Tests.csproj `
|
||||
--no-build `
|
||||
--no-restore `
|
||||
-c Release `
|
||||
-p:Platform=x64 `
|
||||
-p:SkipPluginDeploy=true
|
||||
|
||||
- name: パッケージの作成
|
||||
id: package
|
||||
shell: pwsh
|
||||
run: |
|
||||
$version = "${{ steps.version.outputs.TAG }}"
|
||||
$outDir = "MangaScreentone/bin/x64/Release/net10.0-windows10.0.19041.0"
|
||||
$stageRoot = "stage/MangaScreentone"
|
||||
$pkgName = "MangaScreentone_$version.ymme"
|
||||
|
||||
New-Item -ItemType Directory -Path $stageRoot -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path "$stageRoot/LICENSE" -Force | Out-Null
|
||||
|
||||
$dll = "$outDir/plugin/MangaScreentone.dll"
|
||||
if (-not (Test-Path $dll)) {
|
||||
Write-Error "ビルド結果に MangaScreentone.dll が見つかりませんでした: $dll"
|
||||
exit 1
|
||||
}
|
||||
Copy-Item $dll "$stageRoot/"
|
||||
|
||||
foreach ($lang in @("ar-sa", "en-us", "es-es", "id-id", "ko-kr", "zh-cn", "zh-tw")) {
|
||||
$src = "$outDir/$lang"
|
||||
if (Test-Path $src) {
|
||||
New-Item -ItemType Directory -Path "$stageRoot/$lang" -Force | Out-Null
|
||||
Copy-Item "$src/*.dll" "$stageRoot/$lang/"
|
||||
}
|
||||
}
|
||||
|
||||
Copy-Item ".github/LICENSE/*.txt" "$stageRoot/LICENSE/"
|
||||
Copy-Item ".github/Plugin_Readme.txt" "$stageRoot/Readme.txt"
|
||||
|
||||
$readme = Get-Content "$stageRoot/Readme.txt" -Raw
|
||||
if (-not $readme.Contains(" 漫画(スクリーントーン) for YMM4 $version")) {
|
||||
Write-Error "同梱する Readme.txt の見出しが $version と一致しません"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Compress-Archive -Path "stage/*" -DestinationPath $pkgName -CompressionLevel Optimal
|
||||
echo "PKG_NAME=$pkgName" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: 変更履歴の作成
|
||||
id: changelog
|
||||
shell: pwsh
|
||||
env:
|
||||
GITEA_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ steps.version.outputs.TAG }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
PACKAGE: ${{ steps.package.outputs.PKG_NAME }}
|
||||
run: |
|
||||
$tag = $env:TAG
|
||||
$repository = $env:REPOSITORY
|
||||
$server = $env:SERVER_URL
|
||||
$code = [char]0x60
|
||||
$fence = [string]::new($code, 3)
|
||||
$unit = [char]0x1f
|
||||
$record = [char]0x1e
|
||||
|
||||
$previous = ""
|
||||
$candidates = @(git tag --list "v*" --merged $tag --sort=-creatordate | Where-Object { $_ -ne $tag })
|
||||
if ($candidates.Count -gt 0) {
|
||||
$previous = $candidates[0]
|
||||
}
|
||||
Write-Host "直前のタグ: $previous"
|
||||
|
||||
$range = if ($previous) { "$previous..$tag" } else { $tag }
|
||||
$log = (@(git log "--format=%H%x1f%s%x1f%an%x1f%ad%x1f%b%x1e" --date=short $range) -join "`n") -split $record
|
||||
|
||||
$commits = @()
|
||||
foreach ($entry in $log) {
|
||||
if (-not $entry.Trim()) { continue }
|
||||
$fields = $entry.TrimStart("`n") -split $unit
|
||||
if ($fields.Count -lt 5) { continue }
|
||||
$commits += [pscustomobject]@{
|
||||
Sha = $fields[0]
|
||||
Subject = $fields[1]
|
||||
Name = $fields[2]
|
||||
Date = $fields[3]
|
||||
Body = $fields[4]
|
||||
Login = ""
|
||||
Avatar = ""
|
||||
}
|
||||
}
|
||||
Write-Host "コミット数: $($commits.Count)"
|
||||
|
||||
$categories = [ordered]@{
|
||||
A = @{ Title = "追加"; Symbol = "+"; Items = [System.Collections.Generic.List[pscustomobject]]::new() }
|
||||
M = @{ Title = "変更"; Symbol = "~"; Items = [System.Collections.Generic.List[pscustomobject]]::new() }
|
||||
D = @{ Title = "削除"; Symbol = "-"; Items = [System.Collections.Generic.List[pscustomobject]]::new() }
|
||||
F = @{ Title = "修正"; Symbol = "!"; Items = [System.Collections.Generic.List[pscustomobject]]::new() }
|
||||
}
|
||||
foreach ($commit in $commits) {
|
||||
if (-not $commit.Body) { continue }
|
||||
foreach ($bodyLine in ($commit.Body -split "`n")) {
|
||||
$trimmed = $bodyLine.Trim()
|
||||
if ($trimmed -notmatch '^・(.+)-([AMDF])$') { continue }
|
||||
$categories[$Matches[2]].Items.Add([pscustomobject]@{ Text = $Matches[1]; Sha = $commit.Sha })
|
||||
}
|
||||
}
|
||||
|
||||
$pending = [System.Collections.Generic.HashSet[string]]::new()
|
||||
foreach ($commit in $commits) {
|
||||
[void]$pending.Add($commit.Sha)
|
||||
}
|
||||
|
||||
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
|
||||
|
||||
$accounts = @{}
|
||||
$page = 1
|
||||
while ($pending.Count -gt 0 -and $page -le 20) {
|
||||
$rows = @()
|
||||
try {
|
||||
$rows = @(Invoke-RestMethod -Uri "$server/api/v1/repos/$repository/commits?sha=$tag&limit=50&page=$page&stat=false&verification=false&files=false" -Headers $headers)
|
||||
}
|
||||
catch {
|
||||
Write-Host "コミットの作者を取得できませんでした: $($_.Exception.Message)"
|
||||
break
|
||||
}
|
||||
if ($rows.Count -eq 0) { break }
|
||||
|
||||
foreach ($row in $rows) {
|
||||
if ($pending.Remove($row.sha)) {
|
||||
$login = ""
|
||||
$avatar = ""
|
||||
if ($row.author) {
|
||||
$login = [string]$row.author.login
|
||||
$avatar = [string]$row.author.avatar_url
|
||||
}
|
||||
$accounts[$row.sha] = @{ Login = $login; Avatar = $avatar }
|
||||
}
|
||||
}
|
||||
|
||||
if ($rows.Count -lt 50) { break }
|
||||
$page++
|
||||
}
|
||||
|
||||
foreach ($commit in $commits) {
|
||||
if ($accounts.ContainsKey($commit.Sha)) {
|
||||
$commit.Login = $accounts[$commit.Sha].Login
|
||||
$commit.Avatar = $accounts[$commit.Sha].Avatar
|
||||
}
|
||||
}
|
||||
|
||||
$emptyTree = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
|
||||
$base = if ($previous) { $previous } else { $emptyTree }
|
||||
$shortstat = (@(git diff --shortstat $base $tag) -join " ")
|
||||
$changedFiles = 0
|
||||
$insertions = 0
|
||||
$deletions = 0
|
||||
if ($shortstat -match "(\d+) file") { $changedFiles = [int]$Matches[1] }
|
||||
if ($shortstat -match "(\d+) insertion") { $insertions = [int]$Matches[1] }
|
||||
if ($shortstat -match "(\d+) deletion") { $deletions = [int]$Matches[1] }
|
||||
$diffStat = @(git diff --stat $base $tag)
|
||||
$tagDate = (git log -1 "--format=%ad" --date=short $tag)
|
||||
|
||||
$contributors = @($commits |
|
||||
Group-Object -Property { if ($_.Login) { $_.Login } else { $_.Name } } |
|
||||
Sort-Object -Property Count -Descending)
|
||||
|
||||
function Get-Icon($avatar, $login, $size) {
|
||||
if (-not $avatar) { return "" }
|
||||
$sized = if ($avatar.Contains("?")) { "$avatar&s=$($size * 2)" } else { "$avatar" + "?s=$($size * 2)" }
|
||||
return "<img src=""$sized"" width=""$size"" height=""$size"" alt=""$login""> "
|
||||
}
|
||||
|
||||
$package = Get-Item $env:PACKAGE
|
||||
$size = [math]::Round($package.Length / 1MB, 2)
|
||||
|
||||
$body = [System.Collections.Generic.List[string]]::new()
|
||||
$body.Add("## 概要")
|
||||
$body.Add("")
|
||||
$body.Add("| 項目 | 内容 |")
|
||||
$body.Add("|---|---|")
|
||||
$body.Add("| タグ | [$tag]($server/$repository/tree/$tag) |")
|
||||
$body.Add("| 公開日 | $tagDate |")
|
||||
if ($previous) {
|
||||
$body.Add("| 直前のリリース | [$previous]($server/$repository/releases/tag/$previous) |")
|
||||
}
|
||||
$body.Add("| コミット数 | $($commits.Count) |")
|
||||
$body.Add("| 貢献者 | $($contributors.Count) 名 |")
|
||||
$body.Add("| 変更されたファイル | $changedFiles |")
|
||||
$body.Add("| 追加された行 | $insertions |")
|
||||
$body.Add("| 削除された行 | $deletions |")
|
||||
|
||||
$hasHighlights = ($categories.Values | ForEach-Object { $_.Items.Count } | Measure-Object -Sum).Sum -gt 0
|
||||
if ($hasHighlights) {
|
||||
$body.Add("")
|
||||
$body.Add("## 主な変更")
|
||||
foreach ($key in $categories.Keys) {
|
||||
$category = $categories[$key]
|
||||
if ($category.Items.Count -eq 0) { continue }
|
||||
$body.Add("")
|
||||
$body.Add("### [$($category.Symbol)] $($category.Title)")
|
||||
$body.Add("")
|
||||
foreach ($item in $category.Items) {
|
||||
$short = $item.Sha.Substring(0, 7)
|
||||
$body.Add("- $($item.Text) ([$code$short$code]($server/$repository/commit/$($item.Sha)))")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$body.Add("")
|
||||
$body.Add("## ダウンロード")
|
||||
$body.Add("")
|
||||
$body.Add("| ファイル | サイズ |")
|
||||
$body.Add("|---|---|")
|
||||
$body.Add("| $($package.Name) | $size MB |")
|
||||
|
||||
$body.Add("")
|
||||
$body.Add("## 貢献者")
|
||||
$body.Add("")
|
||||
$body.Add("| 貢献者 | コミット数 |")
|
||||
$body.Add("|---|---|")
|
||||
foreach ($contributor in $contributors) {
|
||||
$first = $contributor.Group[0]
|
||||
if ($first.Login) {
|
||||
$name = (Get-Icon $first.Avatar $first.Login 40) + "[@$($first.Login)]($server/$($first.Login))"
|
||||
}
|
||||
else {
|
||||
$name = $first.Name
|
||||
}
|
||||
$body.Add("| $name | $($contributor.Count) |")
|
||||
}
|
||||
|
||||
$body.Add("")
|
||||
$body.Add("## 変更履歴")
|
||||
$body.Add("")
|
||||
$body.Add("| コミット | 内容 | 貢献者 | 日付 |")
|
||||
$body.Add("|---|---|---|---|")
|
||||
$maximumCommits = 300
|
||||
$listed = 0
|
||||
foreach ($commit in $commits) {
|
||||
if ($listed -ge $maximumCommits) { break }
|
||||
$short = $commit.Sha.Substring(0, 7)
|
||||
$subject = $commit.Subject -replace '\|', '\|'
|
||||
if ($commit.Login) {
|
||||
$author = (Get-Icon $commit.Avatar $commit.Login 20) + "[@$($commit.Login)]($server/$($commit.Login))"
|
||||
}
|
||||
else {
|
||||
$author = $commit.Name
|
||||
}
|
||||
$body.Add("| [$code$short$code]($server/$repository/commit/$($commit.Sha)) | $subject | $author | $($commit.Date) |")
|
||||
$listed++
|
||||
}
|
||||
if ($commits.Count -gt $maximumCommits) {
|
||||
$body.Add("")
|
||||
$body.Add("残り $($commits.Count - $maximumCommits) 件のコミットは省略しました。")
|
||||
}
|
||||
|
||||
if ($diffStat.Count -gt 0) {
|
||||
$body.Add("")
|
||||
$body.Add("## 変更されたファイル")
|
||||
$body.Add("")
|
||||
$body.Add("<details>")
|
||||
$body.Add("<summary>差分の統計</summary>")
|
||||
$body.Add("")
|
||||
$body.Add($fence)
|
||||
$maximumStatLines = 200
|
||||
$shown = 0
|
||||
foreach ($line in $diffStat) {
|
||||
if ($shown -ge $maximumStatLines) { break }
|
||||
$body.Add($line)
|
||||
$shown++
|
||||
}
|
||||
if ($diffStat.Count -gt $maximumStatLines) {
|
||||
$body.Add("... 残り $($diffStat.Count - $maximumStatLines) 行は省略しました。")
|
||||
}
|
||||
$body.Add($fence)
|
||||
$body.Add("")
|
||||
$body.Add("</details>")
|
||||
}
|
||||
|
||||
if ($previous) {
|
||||
$body.Add("")
|
||||
$body.Add("## 全ての変更")
|
||||
$body.Add("")
|
||||
$body.Add("$server/$repository/compare/$previous...$tag")
|
||||
}
|
||||
|
||||
$path = "release-body.md"
|
||||
Set-Content -Path $path -Value ($body -join "`n") -Encoding utf8NoBOM
|
||||
if (-not (Test-Path $path)) {
|
||||
throw "変更履歴を作成できませんでした。"
|
||||
}
|
||||
Write-Host "変更履歴の行数: $($body.Count)"
|
||||
$global:LASTEXITCODE = 0
|
||||
|
||||
- name: Gitea リリースの作成
|
||||
shell: pwsh
|
||||
env:
|
||||
GITEA_TOKEN: ${{ github.token }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
WORKFLOW_NAME: ${{ github.workflow }}
|
||||
JOB_NAME: ${{ github.job }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_number }}
|
||||
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
|
||||
RELEASE_NAME: ${{ steps.version.outputs.TAG }}
|
||||
RELEASE_BODY: ''
|
||||
RELEASE_BODY_PATH: release-body.md
|
||||
RELEASE_DRAFT: false
|
||||
RELEASE_PRERELEASE: false
|
||||
RELEASE_FILES: |
|
||||
${{ steps.package.outputs.PKG_NAME }}
|
||||
run: |
|
||||
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
|
||||
$api = "$env:SERVER_URL/api/v1/repos/$env:REPOSITORY"
|
||||
$tag = $env:RELEASE_TAG
|
||||
|
||||
$body = $env:RELEASE_BODY
|
||||
if ($env:RELEASE_BODY_PATH -and (Test-Path $env:RELEASE_BODY_PATH)) {
|
||||
$body = Get-Content $env:RELEASE_BODY_PATH -Raw -Encoding utf8
|
||||
}
|
||||
|
||||
$files = @()
|
||||
foreach ($pattern in ($env:RELEASE_FILES -split "[`r`n,]+" | Where-Object { $_.Trim() })) {
|
||||
$found = @(Get-ChildItem -Path $pattern.Trim() -File -ErrorAction SilentlyContinue)
|
||||
if ($found.Count -eq 0) { throw "リリースに付けるファイルが見つかりません: $pattern" }
|
||||
$files += $found
|
||||
}
|
||||
|
||||
$payload = @{
|
||||
tag_name = $tag
|
||||
name = $env:RELEASE_NAME
|
||||
body = [string]$body
|
||||
draft = ($env:RELEASE_DRAFT -eq 'true')
|
||||
prerelease = ($env:RELEASE_PRERELEASE -eq 'true')
|
||||
} | ConvertTo-Json
|
||||
$bytes = [System.Text.Encoding]::UTF8.GetBytes($payload)
|
||||
|
||||
$existing = $null
|
||||
try { $existing = Invoke-RestMethod -Uri "$api/releases/tags/$([System.Uri]::EscapeDataString($tag))" -Headers $headers } catch { }
|
||||
if ($existing) {
|
||||
$release = Invoke-RestMethod -Method Patch -Uri "$api/releases/$($existing.id)" -Headers $headers -ContentType "application/json; charset=utf-8" -Body $bytes
|
||||
foreach ($asset in @($existing.assets)) {
|
||||
Invoke-RestMethod -Method Delete -Uri "$api/releases/$($existing.id)/assets/$($asset.id)" -Headers $headers | Out-Null
|
||||
}
|
||||
} else {
|
||||
$release = Invoke-RestMethod -Method Post -Uri "$api/releases" -Headers $headers -ContentType "application/json; charset=utf-8" -Body $bytes
|
||||
}
|
||||
foreach ($file in $files) {
|
||||
$name = [System.Uri]::EscapeDataString($file.Name)
|
||||
Invoke-RestMethod -Method Post -Uri "$api/releases/$($release.id)/assets?name=$name" -Headers $headers -Form @{ attachment = Get-Item $file.FullName } | Out-Null
|
||||
Write-Host "添付しました: $($file.Name)"
|
||||
}
|
||||
Write-Host "リリースを作成しました: $($release.html_url)"
|
||||
|
||||
if ($env:EVENT_NAME -eq 'workflow_dispatch') {
|
||||
try {
|
||||
$sha = (git rev-parse HEAD).Trim()
|
||||
$status = @{
|
||||
state = 'success'
|
||||
context = "$env:WORKFLOW_NAME / $env:JOB_NAME (workflow_dispatch)"
|
||||
description = "Actions がタグ $tag のコミットから作成しました"
|
||||
target_url = $env:RUN_URL
|
||||
} | ConvertTo-Json
|
||||
Invoke-RestMethod -Method Post -Uri "$api/statuses/$sha" -Headers $headers -ContentType "application/json; charset=utf-8" -Body ([System.Text.Encoding]::UTF8.GetBytes($status)) | Out-Null
|
||||
Write-Host "タグのコミット $sha に成功の状態を付けました"
|
||||
}
|
||||
catch {
|
||||
Write-Warning "タグのコミットに状態を付けられませんでした: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
+14
-5
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
漫画(スクリーントーン) for YMM4 v1.0.0
|
||||
漫画(スクリーントーン) for YMM4 v1.1.1
|
||||
========================================
|
||||
YukkuriMovieMaker4上で動作する、素材を白黒の漫画の原稿に仕上げる
|
||||
映像エフェクトプラグインです。
|
||||
@@ -49,11 +49,13 @@ Manga Levels、Manga Finish、Manga Panelの3つのノードに当たる処理
|
||||
切り抜きはYMM4のクロップで代えられます。
|
||||
|
||||
- 透明部分: 素材の透明な部分は、白い紙とみなして処理します。そのため、
|
||||
暗い素材を切り抜いた縁には、線が出ます。用紙が「透明」でなければ、
|
||||
暗い素材を切り抜いた縁には、線が出ます。既定では、用紙が「透明」でなければ、
|
||||
強さが100%のとき、出力は素材の範囲と余白をすべて不透明に埋めます。
|
||||
強さが100%未満のときは、その分だけ入力映像と混ざるため、
|
||||
入力が透明な部分と余白は半透明になります。背景を透明のまま残すときは、
|
||||
用紙を「透明」にします。
|
||||
「透明部分を保つ」をオンにします。オンにすると、用紙が「透明」でなければ、
|
||||
出力の不透明度は素材の不透明度と同じになります。素材の透明な部分と余白は、
|
||||
透明のまま出力されます。
|
||||
|
||||
- 動画での見え方: 線、ベタ、トーンの面は、フレームごとに独立して決めます。
|
||||
動画では、フレームの間で線や面の境が切り替わり、ちらつくことがあります。
|
||||
@@ -126,15 +128,22 @@ Manga Levels、Manga Finish、Manga Panelの3つのノードに当たる処理
|
||||
■ 不具合の報告
|
||||
--------------------------------------------------------------------------------
|
||||
本プラグインは、想定していない例外が起きたときに、その内容を開発者へ自動で
|
||||
送信します。同意は求めず、常に送信します。
|
||||
送信します。同意は求めません。止める設定もありません。
|
||||
|
||||
送信する数には上限があります。YMM4の1回の起動で送る報告は、
|
||||
YMM4-Telemetryで報告する別のプラグインと合わせて20件までです。
|
||||
例外の型と発生位置が同じ報告は3件までです。上限を超えた報告と、
|
||||
送信先から待つよう求められている間に起きた報告は、送信も退避もしません。
|
||||
|
||||
送信する情報は次のとおりです。
|
||||
例外 : 型の完全名、メッセージ、スタックトレース
|
||||
発生位置 : モジュール名、関数名、ファイル名、行番号
|
||||
発生位置 : モジュール名、関数名、ファイル名、行番号、
|
||||
プラグイン自身のコードかどうか
|
||||
プラグイン : アセンブリ名、バージョン
|
||||
実行環境 : OSの名前とバージョン、.NETのバージョン、
|
||||
CPUのアーキテクチャ、論理プロセッサ数
|
||||
識別子 : YMM4の起動ごとに決まるセッション識別子、報告ごとの識別子
|
||||
時刻 : 報告を作った時刻(UTC)
|
||||
|
||||
映像の中身とプロジェクトの内容は送信しません。継続して個人を追跡する
|
||||
識別子も持ちません。セッション識別子はYMM4を起動し直すと別の値に
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
[submodule "YukkuriMovieMaker.Generator"]
|
||||
path = YukkuriMovieMaker.Generator
|
||||
url = https://github.com/manju-summoner/YukkuriMovieMaker.Generator.git
|
||||
url = https://git.routersys.com/manju-summoner/YukkuriMovieMaker.Generator.git
|
||||
[submodule "YMM4-GitHubUpdateNotifier"]
|
||||
path = YMM4-GitHubUpdateNotifier
|
||||
url = https://github.com/routersys/YMM4-GitHubUpdateNotifier.git
|
||||
url = https://git.routersys.com/routersys/YMM4-GitHubUpdateNotifier.git
|
||||
[submodule "YMM4-Telemetry"]
|
||||
path = YMM4-Telemetry
|
||||
url = https://github.com/routersys/YMM4-Telemetry.git
|
||||
url = https://git.routersys.com/routersys/YMM4-Telemetry.git
|
||||
@@ -38,6 +38,12 @@ internal static class HarnessCases
|
||||
yield return ("paper-transparent", Create(effect => effect.Paper = MangaScreentonePaper.Transparent), [0]);
|
||||
yield return ("ink-0", Create(effect => effect.Ink.Values[0].Value = 0), [0]);
|
||||
yield return ("ink-100", Create(effect => effect.Ink.Values[0].Value = 100), [0]);
|
||||
yield return ("keep-transparent", Create(effect => effect.KeepTransparent = true), [0]);
|
||||
yield return ("keep-transparent-margin-60", Create(effect =>
|
||||
{
|
||||
effect.KeepTransparent = true;
|
||||
effect.Margin.Values[0].Value = 60;
|
||||
}), [0]);
|
||||
}
|
||||
|
||||
public static IEnumerable<(string Name, Func<IVideoEffect> Create, Action<IVideoEffect> Change, int Frame)> Transitions()
|
||||
@@ -55,6 +61,7 @@ internal static class HarnessCases
|
||||
yield return ("paper-white-to-cream", () => Create(), effect => Of(effect).Paper = MangaScreentonePaper.Cream, 0);
|
||||
yield return ("ink-50-to-0", () => Create(), effect => Of(effect).Ink.Values[0].Value = 0, 0);
|
||||
yield return ("amount-100-to-0", () => Create(), effect => Of(effect).Amount.Values[0].Value = 0, 0);
|
||||
yield return ("keep-transparent-off-to-on", () => Create(), effect => Of(effect).KeepTransparent = true, 0);
|
||||
}
|
||||
|
||||
public static IEnumerable<(string Name, IVideoEffect Effect)> Benchmarks()
|
||||
|
||||
@@ -174,6 +174,20 @@
|
||||
0
|
||||
],
|
||||
"hash": "B2D5C503D456FA1752194191E6930130185190743CB74D3CC79BE04BE065EE85"
|
||||
},
|
||||
{
|
||||
"name": "keep-transparent",
|
||||
"frames": [
|
||||
0
|
||||
],
|
||||
"hash": "5A02C2928ADE25F4F1A9E02A4CED8DAD6C3E61B2761DB016904FC5A04EB8A588"
|
||||
},
|
||||
{
|
||||
"name": "keep-transparent-margin-60",
|
||||
"frames": [
|
||||
0
|
||||
],
|
||||
"hash": "A5630628E788159C2F466800CC378C17EEAA41919267DC9A629608BB9318381B"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -6,7 +6,7 @@ SamplerState PageSampler : register(s1);
|
||||
cbuffer Constants : register(b0)
|
||||
{
|
||||
float amount : packoffset(c0.x);
|
||||
float pad0 : packoffset(c0.y);
|
||||
float keepTransparent : packoffset(c0.y);
|
||||
float pad1 : packoffset(c0.z);
|
||||
float pad2 : packoffset(c0.w);
|
||||
};
|
||||
@@ -24,5 +24,7 @@ float4 main(
|
||||
|
||||
float4 page = PageTexture.SampleLevel(PageSampler, uv1.xy, 0);
|
||||
page.rgb = min(page.rgb, page.a.xxx);
|
||||
if (keepTransparent > 0.5)
|
||||
page *= source.a;
|
||||
return lerp(source, page, amount);
|
||||
}
|
||||
@@ -9,18 +9,20 @@ namespace MangaScreentone.Tests;
|
||||
public sealed class MangaScreentoneCustomEffectTests
|
||||
{
|
||||
const int AmountIndex = 0;
|
||||
const int KeepTransparentIndex = 1;
|
||||
const int Width = 40;
|
||||
const int Height = 24;
|
||||
|
||||
static readonly Bgra Blue = Bgra.Opaque(255, 0, 0);
|
||||
static readonly Bgra HalfPage = new(0, 0, 0, 128);
|
||||
|
||||
static Rendering Render(IGraphicsDevicesAndContext devices, ID2D1Image source, ID2D1Image page, float amount)
|
||||
static Rendering Render(IGraphicsDevicesAndContext devices, ID2D1Image source, ID2D1Image page, float amount, bool keepTransparent = false)
|
||||
{
|
||||
using var effect = new MangaScreentoneCustomEffect(devices);
|
||||
effect.SetInput(0, source, true);
|
||||
effect.SetInput(1, page, true);
|
||||
effect.Amount = amount;
|
||||
effect.KeepTransparent = keepTransparent;
|
||||
using var output = effect.Output;
|
||||
return Rendering.Capture(devices, output);
|
||||
}
|
||||
@@ -168,4 +170,103 @@ public sealed class MangaScreentoneCustomEffectTests
|
||||
Assert.True(WithinRounding(Mixed(Bgra.Transparent, Blue.Premultiplied(), 0.5f), rendering[10, 10]), $"{rendering[10, 10]}");
|
||||
Assert.Equal(Bgra.Transparent, rendering[45, 10]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TransparencyIsNotKeptUntilItIsTurnedOn()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var effect = new MangaScreentoneCustomEffect(context);
|
||||
|
||||
Assert.Equal(0f, effect.GetFloatValue(KeepTransparentIndex));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, 1f)]
|
||||
[InlineData(false, 0f)]
|
||||
public void KeepingTransparencyIsReportedAsAFlag(bool keep, float expected)
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var effect = new MangaScreentoneCustomEffect(context);
|
||||
effect.KeepTransparent = !keep;
|
||||
|
||||
effect.KeepTransparent = keep;
|
||||
|
||||
Assert.Equal(expected, effect.GetFloatValue(KeepTransparentIndex));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void AnOpaquePageCoversTheTransparentPartsOfTheSourceOnlyWhenTransparencyIsNotKept(bool keep)
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
var pageColor = Bgra.Opaque(10, 20, 30);
|
||||
using var source = new SourceImage(context, Width, Height, (x, _) => x < 10 ? Bgra.Transparent : Blue);
|
||||
using var page = SourceImage.Solid(context, Width, Height, pageColor);
|
||||
|
||||
var rendering = Render(context, source.Bitmap, page.Bitmap, 1f, keep);
|
||||
|
||||
Assert.All(rendering.Coordinates(), point => Assert.Equal(point.X < 10 && keep ? Bgra.Transparent : pageColor, rendering[point.X, point.Y]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ASemiTransparentSourceScalesThePageByItsOpacityWhenTransparencyIsKept()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = SourceImage.Solid(context, Width, Height, new Bgra(0, 0, 255, 128));
|
||||
using var page = SourceImage.Solid(context, Width, Height, Bgra.Opaque(200, 100, 50));
|
||||
var expected = new Bgra(100, 50, 25, 128);
|
||||
|
||||
var rendering = Render(context, source.Bitmap, page.Bitmap, 1f, true);
|
||||
|
||||
Assert.All(rendering.Coordinates(), point => Assert.True(WithinRounding(expected, rendering[point.X, point.Y]), $"({point.X}, {point.Y}) {rendering[point.X, point.Y]}"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThePageOutsideTheSourceIsNotDrawnWhenTransparencyIsKept()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = SourceImage.Solid(context, Width, Height, Blue);
|
||||
using var page = SourceImage.Solid(context, 8, 8, Bgra.Opaque(10, 20, 30));
|
||||
using var moved = Translate(context, page.Bitmap, 50f, 4f);
|
||||
using var movedOutput = moved.Output;
|
||||
|
||||
var rendering = Render(context, source.Bitmap, movedOutput, 1f, true);
|
||||
|
||||
Assert.Equal(Bgra.Transparent, rendering[53, 7]);
|
||||
Assert.Equal(Bgra.Transparent, rendering[45, 10]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThePartialAmountKeepsTransparentPartsTransparentWhenTransparencyIsKept()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
var pageColor = Bgra.Opaque(10, 20, 30);
|
||||
using var source = new SourceImage(context, Width, Height, (x, _) => x < 10 ? Bgra.Transparent : Blue);
|
||||
using var page = SourceImage.Solid(context, Width, Height, pageColor);
|
||||
|
||||
var rendering = Render(context, source.Bitmap, page.Bitmap, 0.5f, true);
|
||||
|
||||
Assert.Equal(Bgra.Transparent, rendering[3, 5]);
|
||||
Assert.True(WithinRounding(Mixed(pageColor, Blue.Premultiplied(), 0.5f), rendering[20, 5]), $"{rendering[20, 5]}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithoutAmountTheSourcePassesThroughEvenWhenTransparencyIsKept()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, (x, _) => x < 10 ? Bgra.Transparent : Blue);
|
||||
using var page = SourceImage.Solid(context, Width, Height, Bgra.Opaque(10, 20, 30));
|
||||
|
||||
var rendering = Render(context, source.Bitmap, page.Bitmap, 0f, true);
|
||||
|
||||
Assert.All(rendering.Coordinates(), point => Assert.Equal(source[point.X, point.Y], rendering[point.X, point.Y]));
|
||||
}
|
||||
}
|
||||
@@ -326,6 +326,7 @@ public sealed class MangaScreentoneEffectProcessorTests
|
||||
{ nameof(MangaScreentoneEffect.Margin), effect => effect.Margin.Values[0].Value = 80d },
|
||||
{ nameof(MangaScreentoneEffect.Paper), effect => effect.Paper = MangaScreentonePaper.Cream },
|
||||
{ nameof(MangaScreentoneEffect.Ink), effect => effect.Ink.Values[0].Value = 100d },
|
||||
{ nameof(MangaScreentoneEffect.KeepTransparent), effect => effect.KeepTransparent = true },
|
||||
};
|
||||
|
||||
[Theory]
|
||||
@@ -568,4 +569,70 @@ public sealed class MangaScreentoneEffectProcessorTests
|
||||
Assert.Equal((0, 0, MangaScreentoneSettings.MaximumCanvasSize, 4), (rendering.Left, rendering.Top, rendering.Width, rendering.Height));
|
||||
Assert.All(rendering.Coordinates(), point => Assert.NotEqual(source[point.X, point.Y], rendering[point.X, point.Y]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepingTransparencyLeavesTheTransparentPartsOfTheImageTransparent()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
RequireInterop(context);
|
||||
using var source = CreateSource(context);
|
||||
var effect = Plain();
|
||||
effect.KeepTransparent = true;
|
||||
using var processor = effect.CreateVideoEffect(context);
|
||||
processor.SetInput(source.Bitmap);
|
||||
|
||||
var rendering = RenderFrame(context, processor, 0);
|
||||
|
||||
Assert.Equal((0, 0, Width, Height), (rendering.Left, rendering.Top, rendering.Width, rendering.Height));
|
||||
Assert.Contains(rendering.Coordinates(), point => source[point.X, point.Y].Alpha == 0);
|
||||
Assert.All(rendering.Coordinates(), point =>
|
||||
{
|
||||
var pixel = rendering[point.X, point.Y];
|
||||
var expected = source[point.X, point.Y].Alpha == 0 ? Bgra.Transparent : pixel;
|
||||
Assert.True(pixel == expected && (pixel.Alpha == 0 || pixel == Bgra.Opaque(0, 0, 0) || pixel == Bgra.Opaque(255, 255, 255)), $"({point.X}, {point.Y}) {pixel}");
|
||||
});
|
||||
Assert.Contains(rendering.Coordinates(), point => rendering[point.X, point.Y] == Bgra.Opaque(0, 0, 0));
|
||||
Assert.Contains(rendering.Coordinates(), point => rendering[point.X, point.Y] == Bgra.Opaque(255, 255, 255));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepingTransparencyLeavesTheMarginTransparent()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
RequireInterop(context);
|
||||
using var source = CreateSource(context);
|
||||
var effect = Plain();
|
||||
effect.Margin.Values[0].Value = 100d;
|
||||
effect.KeepTransparent = true;
|
||||
using var processor = effect.CreateVideoEffect(context);
|
||||
processor.SetInput(source.Bitmap);
|
||||
var margin = MangaScreentonePipeline.GetCanvasSize(Width, Height, DefaultParameters with { Margin = 100f }).Width - Width;
|
||||
|
||||
var rendering = RenderFrame(context, processor, 0);
|
||||
|
||||
Assert.True(margin > 0);
|
||||
Assert.Equal((-margin / 2, -margin / 2, Width + margin, Height + margin), (rendering.Left, rendering.Top, rendering.Width, rendering.Height));
|
||||
Assert.All(rendering.Coordinates().Where(point => !source.Contains(point.X, point.Y)), point => Assert.Equal(Bgra.Transparent, rendering[point.X, point.Y]));
|
||||
Assert.Equal(Bgra.Opaque(255, 255, 255), rendering[Width - 1, Height / 2]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepingTransparencyKeepsTheOpacityOfASemiTransparentEdge()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
RequireInterop(context);
|
||||
using var source = new SourceImage(context, Width, Height, (x, _) => new Bgra(128, 128, 128, (byte)(x * 255 / (Width - 1))));
|
||||
var effect = Plain();
|
||||
effect.KeepTransparent = true;
|
||||
using var processor = effect.CreateVideoEffect(context);
|
||||
processor.SetInput(source.Bitmap);
|
||||
|
||||
var rendering = RenderFrame(context, processor, 0);
|
||||
|
||||
Assert.All(rendering.Coordinates(), point => Assert.InRange(Math.Abs(rendering[point.X, point.Y].Alpha - source[point.X, point.Y].Alpha), 0, 1));
|
||||
Assert.Contains(rendering.Coordinates(), point => rendering[point.X, point.Y].Alpha is > 0 and < 255);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,25 @@ public sealed class MangaScreentoneEffectTests
|
||||
Assert.Equal(MangaScreentonePaper.White, effect.Paper);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TransparencyIsNotKeptByDefault()
|
||||
{
|
||||
Assert.False(new MangaScreentoneEffect().KeepTransparent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChangingKeepTransparentNotifiesTheEditor()
|
||||
{
|
||||
var effect = new MangaScreentoneEffect();
|
||||
var changed = new List<string?>();
|
||||
effect.PropertyChanged += (_, e) => changed.Add(e.PropertyName);
|
||||
|
||||
effect.KeepTransparent = true;
|
||||
effect.KeepTransparent = true;
|
||||
|
||||
Assert.Equal([nameof(MangaScreentoneEffect.KeepTransparent)], changed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChangingWhiteLinesOrPaperNotifiesTheEditor()
|
||||
{
|
||||
@@ -150,6 +169,7 @@ public sealed class MangaScreentoneEffectTests
|
||||
[InlineData(nameof(MangaScreentoneEffect.Margin), nameof(Texts.PageGroup), nameof(Texts.Margin), nameof(Texts.MarginDescription), 31)]
|
||||
[InlineData(nameof(MangaScreentoneEffect.Paper), nameof(Texts.PageGroup), nameof(Texts.Paper), nameof(Texts.PaperDescription), 32)]
|
||||
[InlineData(nameof(MangaScreentoneEffect.Ink), nameof(Texts.PageGroup), nameof(Texts.Ink), nameof(Texts.InkDescription), 33)]
|
||||
[InlineData(nameof(MangaScreentoneEffect.KeepTransparent), nameof(Texts.PageGroup), nameof(Texts.KeepTransparent), nameof(Texts.KeepTransparentDescription), 34)]
|
||||
public void EveryParameterIsDisplayedInItsGroupInOrder(string property, string group, string name, string description, int order)
|
||||
{
|
||||
var display = Attribute<DisplayAttribute>(property);
|
||||
@@ -207,6 +227,12 @@ public sealed class MangaScreentoneEffectTests
|
||||
Assert.NotNull(Attribute<ToggleSliderAttribute>(nameof(MangaScreentoneEffect.WhiteLines)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepingTransparencyIsSwitchedWithAToggle()
|
||||
{
|
||||
Assert.NotNull(Attribute<ToggleSliderAttribute>(nameof(MangaScreentoneEffect.KeepTransparent)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThePaperIsChosenFromACombo()
|
||||
{
|
||||
@@ -233,7 +259,7 @@ public sealed class MangaScreentoneEffectTests
|
||||
[Fact]
|
||||
public void EverySettingSurvivesAProjectRoundTrip()
|
||||
{
|
||||
var effect = new MangaScreentoneEffect { WhiteLines = false, Paper = MangaScreentonePaper.Cream };
|
||||
var effect = new MangaScreentoneEffect { WhiteLines = false, Paper = MangaScreentonePaper.Cream, KeepTransparent = true };
|
||||
var values = new[] { 55d, 320d, 70d, 40d, 25d, 66d, 15d, 35d, 90d, 2.5d, 12d, 80d, 35d };
|
||||
foreach (var (animation, value) in Animations(effect).Zip(values))
|
||||
animation.Values[0].Value = value;
|
||||
@@ -243,6 +269,7 @@ public sealed class MangaScreentoneEffectTests
|
||||
Assert.NotSame(effect, clone);
|
||||
Assert.False(clone.WhiteLines);
|
||||
Assert.Equal(MangaScreentonePaper.Cream, clone.Paper);
|
||||
Assert.True(clone.KeepTransparent);
|
||||
Assert.Equal(values, Animations(clone).Select(animation => animation.GetValue(0, 1, EffectDescriptions.Fps)));
|
||||
}
|
||||
}
|
||||
@@ -353,9 +353,34 @@ public sealed class MangaScreentoneShaderTests
|
||||
[InlineData(45, 31, 13, 0u)]
|
||||
[InlineData(14, 11, 39, 1u)]
|
||||
public void SmallRegionsOfTheTargetLevelAreFilledFromTheirSurroundingsAndTheRestStays(int width, int height, int size, uint target)
|
||||
{
|
||||
AssertSmallRegionsFilled(Levels(width, height, 0x42u), width, height, size, target);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(5)]
|
||||
[InlineData(13)]
|
||||
[InlineData(21)]
|
||||
public void SmallRegionsFarApartAreFilledWhileTheGroupsBetweenThemHaveNoHolesToCount(int size)
|
||||
{
|
||||
const int width = 130;
|
||||
const int height = 100;
|
||||
var levels = Enumerable.Repeat(3u, width * height).ToArray();
|
||||
foreach (var (left, top, regionWidth, regionHeight) in new[] { (9, 7, 3, 3), (118, 90, 2, 4), (64, 2, 1, 1), (3, 60, 4, 2) })
|
||||
{
|
||||
for (var y = top; y < top + regionHeight; y++)
|
||||
{
|
||||
for (var x = left; x < left + regionWidth; x++)
|
||||
levels[y * width + x] = 1u;
|
||||
}
|
||||
}
|
||||
|
||||
AssertSmallRegionsFilled(levels, width, height, size, 1u);
|
||||
}
|
||||
|
||||
static void AssertSmallRegionsFilled(uint[] levels, int width, int height, int size, uint target)
|
||||
{
|
||||
var device = Device();
|
||||
var levels = Levels(width, height, 0x42u);
|
||||
var components = MangaScreentoneReference.Label(levels.Select(level => level == target ? 0u : MangaScreentoneSettings.InactiveClass).ToArray(), width, height, false);
|
||||
const float minimumRegion = 24f;
|
||||
var expectedMedian = MangaScreentoneReference.Median(levels, width, height, size, index => levels[index] == target && components.Area[components.Labels[index]] < minimumRegion);
|
||||
@@ -378,7 +403,7 @@ public sealed class MangaScreentoneShaderTests
|
||||
device.For(ThreadGroupAlignment.AlignX<ComponentAreaShader>(width), ThreadGroupAlignment.AlignY<ComponentAreaShader>(height), new ComponentAreaShader(classBuffer, labels, area, width, height));
|
||||
|
||||
device.For(width, height, new HoleMarkShader(levelBuffer, labels, area, classBuffer, width, height, target, minimumRegion));
|
||||
device.For(width, height, new HoleCountShader(classBuffer, low, high, width, height, size / 2));
|
||||
device.For(ThreadGroupAlignment.AlignX<HoleCountShader>(width), ThreadGroupAlignment.AlignY<HoleCountShader>(height), new HoleCountShader(classBuffer, low, high, width, height, size / 2));
|
||||
device.For(width, height, new HoleResolveShader(levelBuffer, classBuffer, low, high, output, width, height, size / 2));
|
||||
|
||||
Assert.Equal(expected, Download(output));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.0.0</Version>
|
||||
<Version>1.1.1</Version>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
|
||||
@@ -11,6 +11,8 @@ internal sealed class MangaScreentoneCustomEffect(IGraphicsDevicesAndContext dev
|
||||
{
|
||||
public float Amount { set => SetValue((int)EffectImpl.Properties.Amount, value); }
|
||||
|
||||
public bool KeepTransparent { set => SetValue((int)EffectImpl.Properties.KeepTransparent, value ? 1f : 0f); }
|
||||
|
||||
[CustomEffect(2)]
|
||||
private sealed class EffectImpl : D2D1CustomShaderEffectImplBase<EffectImpl>
|
||||
{
|
||||
@@ -27,6 +29,17 @@ internal sealed class MangaScreentoneCustomEffect(IGraphicsDevicesAndContext dev
|
||||
}
|
||||
}
|
||||
|
||||
[CustomEffectProperty(PropertyType.Float, (int)Properties.KeepTransparent)]
|
||||
public float KeepTransparent
|
||||
{
|
||||
get => _cb.KeepTransparent;
|
||||
set
|
||||
{
|
||||
_cb.KeepTransparent = value > 0.5f ? 1f : 0f;
|
||||
UpdateConstants();
|
||||
}
|
||||
}
|
||||
|
||||
public EffectImpl() : base(ShaderResourceUri.Get("MangaScreentone"))
|
||||
{
|
||||
}
|
||||
@@ -84,7 +97,7 @@ internal sealed class MangaScreentoneCustomEffect(IGraphicsDevicesAndContext dev
|
||||
private struct ConstantBuffer
|
||||
{
|
||||
public float Amount;
|
||||
public float Pad0;
|
||||
public float KeepTransparent;
|
||||
public float Pad1;
|
||||
public float Pad2;
|
||||
}
|
||||
@@ -92,6 +105,7 @@ internal sealed class MangaScreentoneCustomEffect(IGraphicsDevicesAndContext dev
|
||||
public enum Properties
|
||||
{
|
||||
Amount = 0,
|
||||
KeepTransparent = 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,11 @@ public sealed class MangaScreentoneEffect : VideoEffectBase
|
||||
[AnimationSlider("F1", "%", 0, 100)]
|
||||
public Animation Ink { get; } = new Animation(50, 0, 100);
|
||||
|
||||
[Display(GroupName = nameof(Texts.PageGroup), Name = nameof(Texts.KeepTransparent), Description = nameof(Texts.KeepTransparentDescription), Order = 34, ResourceType = typeof(Texts))]
|
||||
[ToggleSlider]
|
||||
public bool KeepTransparent { get => _keepTransparent; set => Set(ref _keepTransparent, value); }
|
||||
private bool _keepTransparent;
|
||||
|
||||
private IAnimatable[]? _animatables;
|
||||
|
||||
public override IEnumerable<string> CreateExoVideoFilters(int keyFrameIndex, ExoOutputDescription exoOutputDescription) => [];
|
||||
|
||||
@@ -29,6 +29,7 @@ internal sealed class MangaScreentoneEffectProcessor : VideoEffectProcessorBase
|
||||
private bool _hasOutputOffset;
|
||||
private bool _hasCropRect;
|
||||
private float _amount;
|
||||
private bool _keepTransparent;
|
||||
private Vector2 _outputOffset;
|
||||
private Vector4 _cropRect;
|
||||
|
||||
@@ -66,6 +67,11 @@ internal sealed class MangaScreentoneEffectProcessor : VideoEffectProcessorBase
|
||||
_effect.Amount = amount;
|
||||
_amount = amount;
|
||||
|
||||
var keepTransparent = _item.KeepTransparent;
|
||||
if (_isFirst || _keepTransparent != keepTransparent)
|
||||
_effect.KeepTransparent = keepTransparent;
|
||||
_keepTransparent = keepTransparent;
|
||||
|
||||
if (amount <= 0f)
|
||||
{
|
||||
_effect.Amount = 0f;
|
||||
|
||||
@@ -113,15 +113,30 @@ internal readonly partial struct GaussianBlurShader(
|
||||
if (x >= width || y >= height)
|
||||
return;
|
||||
|
||||
var along = vertical == 0 ? x : y;
|
||||
var length = vertical == 0 ? width : height;
|
||||
var stride = vertical == 0 ? 1 : width;
|
||||
var sum = 0f;
|
||||
var weighted = 0f;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
if (along >= radius && along < length - radius)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var sampleX = vertical == 0 ? MangaScreentoneShaderMath.Reflect(x + offset, width) : x;
|
||||
var sampleY = vertical == 0 ? y : MangaScreentoneShaderMath.Reflect(y + offset, height);
|
||||
weighted += weight * input[sampleY * width + sampleX];
|
||||
sum += weight;
|
||||
var origin = y * width + x;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
weighted += weight * input[origin + offset * stride];
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var reflected = MangaScreentoneShaderMath.Reflect(along + offset, length);
|
||||
weighted += weight * input[vertical == 0 ? y * width + reflected : reflected * width + x];
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
output[y * width + x] = weighted / sum;
|
||||
}
|
||||
@@ -151,12 +166,23 @@ internal readonly partial struct BoxBlurShader(
|
||||
if (x >= width || y >= height)
|
||||
return;
|
||||
|
||||
var along = vertical == 0 ? x : y;
|
||||
var length = vertical == 0 ? width : height;
|
||||
var stride = vertical == 0 ? 1 : width;
|
||||
var sum = 0f;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
if (along >= radius && along < length - radius)
|
||||
{
|
||||
var sampleX = vertical == 0 ? MangaScreentoneShaderMath.Reflect(x + offset, width) : x;
|
||||
var sampleY = vertical == 0 ? y : MangaScreentoneShaderMath.Reflect(y + offset, height);
|
||||
sum += input[sampleY * width + sampleX];
|
||||
var origin = y * width + x;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
sum += input[origin + offset * stride];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
{
|
||||
var reflected = MangaScreentoneShaderMath.Reflect(along + offset, length);
|
||||
sum += input[vertical == 0 ? y * width + reflected : reflected * width + x];
|
||||
}
|
||||
}
|
||||
output[y * width + x] = sum / (2 * radius + 1);
|
||||
}
|
||||
@@ -204,14 +230,30 @@ internal readonly partial struct MaskedBlurHorizontalShader(
|
||||
var sum = 0f;
|
||||
var weightedGray = 0f;
|
||||
var weightedMask = 0f;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
if (x >= radius && x < width - radius)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var index = y * width + MangaScreentoneShaderMath.Reflect(x + offset, width);
|
||||
var open = ink[index] == 0u ? 1f : 0f;
|
||||
weightedGray += weight * gray[index] * open;
|
||||
weightedMask += weight * open;
|
||||
sum += weight;
|
||||
var origin = y * width + x;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var index = origin + offset;
|
||||
var open = ink[index] == 0u ? 1f : 0f;
|
||||
weightedGray += weight * gray[index] * open;
|
||||
weightedMask += weight * open;
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var index = y * width + MangaScreentoneShaderMath.Reflect(x + offset, width);
|
||||
var open = ink[index] == 0u ? 1f : 0f;
|
||||
weightedGray += weight * gray[index] * open;
|
||||
weightedMask += weight * open;
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
numerator[y * width + x] = weightedGray / sum;
|
||||
denominator[y * width + x] = weightedMask / sum;
|
||||
@@ -260,13 +302,28 @@ internal readonly partial struct MaskedBlurVerticalShader(
|
||||
var sum = 0f;
|
||||
var weightedNumerator = 0f;
|
||||
var weightedDenominator = 0f;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
if (y >= radius && y < height - radius)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var index = MangaScreentoneShaderMath.Reflect(y + offset, height) * width + x;
|
||||
weightedNumerator += weight * numerator[index];
|
||||
weightedDenominator += weight * denominator[index];
|
||||
sum += weight;
|
||||
var origin = y * width + x;
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var index = origin + offset * width;
|
||||
weightedNumerator += weight * numerator[index];
|
||||
weightedDenominator += weight * denominator[index];
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var offset = -radius; offset <= radius; offset++)
|
||||
{
|
||||
var weight = weights[offset + radius];
|
||||
var index = MangaScreentoneShaderMath.Reflect(y + offset, height) * width + x;
|
||||
weightedNumerator += weight * numerator[index];
|
||||
weightedDenominator += weight * denominator[index];
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
output[y * width + x] = (weightedNumerator / sum) / Hlsl.Max(weightedDenominator / sum, minimumWeight);
|
||||
}
|
||||
@@ -315,18 +372,38 @@ internal readonly partial struct BilateralShader(
|
||||
var center = input[y * width + x];
|
||||
var sum = 0f;
|
||||
var weighted = 0f;
|
||||
for (var dy = -radius; dy <= radius; dy++)
|
||||
if (x >= radius && x < width - radius && y >= radius && y < height - radius)
|
||||
{
|
||||
var row = MangaScreentoneShaderMath.Reflect(y + dy, height) * width;
|
||||
var limit = reach[dy + radius];
|
||||
for (var dx = -limit; dx <= limit; dx++)
|
||||
for (var dy = -radius; dy <= radius; dy++)
|
||||
{
|
||||
var distance = dx * dx + dy * dy;
|
||||
var value = input[row + MangaScreentoneShaderMath.Reflect(x + dx, width)];
|
||||
var difference = value - center;
|
||||
var weight = Hlsl.Exp(distance * spaceCoefficient + difference * difference * colorCoefficient);
|
||||
weighted += weight * value;
|
||||
sum += weight;
|
||||
var origin = (y + dy) * width + x;
|
||||
var limit = reach[dy + radius];
|
||||
for (var dx = -limit; dx <= limit; dx++)
|
||||
{
|
||||
var distance = dx * dx + dy * dy;
|
||||
var value = input[origin + dx];
|
||||
var difference = value - center;
|
||||
var weight = Hlsl.Exp(distance * spaceCoefficient + difference * difference * colorCoefficient);
|
||||
weighted += weight * value;
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var dy = -radius; dy <= radius; dy++)
|
||||
{
|
||||
var row = MangaScreentoneShaderMath.Reflect(y + dy, height) * width;
|
||||
var limit = reach[dy + radius];
|
||||
for (var dx = -limit; dx <= limit; dx++)
|
||||
{
|
||||
var distance = dx * dx + dy * dy;
|
||||
var value = input[row + MangaScreentoneShaderMath.Reflect(x + dx, width)];
|
||||
var difference = value - center;
|
||||
var weight = Hlsl.Exp(distance * spaceCoefficient + difference * difference * colorCoefficient);
|
||||
weighted += weight * value;
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
output[y * width + x] = weighted / sum;
|
||||
|
||||
@@ -91,8 +91,8 @@ internal readonly partial struct PanelShader(
|
||||
coverage = Hlsl.Saturate((coverage - MangaScreentoneSettings.InkSpreadFloor) / MangaScreentoneSettings.InkSpreadRange);
|
||||
if (coverage > 0f)
|
||||
{
|
||||
var mottle = MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, mottleCoarse, MangaScreentoneSettings.NoiseSeedInk, 0x51ED270Bu)
|
||||
+ MangaScreentoneSettings.InkMottleFineWeight * MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, mottleFine, MangaScreentoneSettings.NoiseSeedInk, 0x2C1B3C6Du);
|
||||
var mottle = MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, mottleCoarse, MangaScreentoneSettings.NoiseSeedInk, MangaScreentoneSettings.NoiseSaltInkCoarse)
|
||||
+ MangaScreentoneSettings.InkMottleFineWeight * MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, mottleFine, MangaScreentoneSettings.NoiseSeedInk, MangaScreentoneSettings.NoiseSaltInkFine);
|
||||
coverage *= 1f - MangaScreentoneSettings.InkMottleDepth * inkStrength * (0.5f + 0.5f * Hlsl.Tanh(mottle));
|
||||
}
|
||||
}
|
||||
@@ -109,8 +109,8 @@ internal readonly partial struct PanelShader(
|
||||
var grain = 0f;
|
||||
if (fibre > 0f)
|
||||
{
|
||||
grain = fibre * (MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, 3, MangaScreentoneSettings.NoiseSeedFibre, 0x297A2D39u)
|
||||
+ MangaScreentoneSettings.FibreFineWeight * MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, 1, MangaScreentoneSettings.NoiseSeedFibre, 0x68E31DA4u));
|
||||
grain = fibre * (MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, (int)MangaScreentoneSettings.FibreCoarse, MangaScreentoneSettings.NoiseSeedFibre, MangaScreentoneSettings.NoiseSaltFibreCoarse)
|
||||
+ MangaScreentoneSettings.FibreFineWeight * MangaScreentoneShaderMath.CubicNoise(x, y, canvasWidth, canvasHeight, (int)MangaScreentoneSettings.FibreFine, MangaScreentoneSettings.NoiseSeedFibre, MangaScreentoneSettings.NoiseSaltFibreFine));
|
||||
}
|
||||
var open = 1f - coverage;
|
||||
output[ThreadIds.XY] = new Float4(
|
||||
|
||||
@@ -21,7 +21,6 @@ internal sealed class MangaScreentonePipeline : IDisposable
|
||||
private ToneKey? _toneKey;
|
||||
private PrintKey? _printKey;
|
||||
private PanelKey? _panelKey;
|
||||
private PanelKey _pendingPanelKey;
|
||||
private int _analysisVersion;
|
||||
private int _cutVersion = -1;
|
||||
private int _toneVersion;
|
||||
@@ -112,12 +111,11 @@ internal sealed class MangaScreentonePipeline : IDisposable
|
||||
|
||||
var derived = MangaScreentoneSettings.Derive(width, height, in parameters);
|
||||
_host.RecordSource(source, _scratch, width, height, in derived).Wait();
|
||||
if (!RunStages(width, height, in derived, in parameters, true))
|
||||
if (!RunStages(width, height, in derived, true, out var panelKey))
|
||||
return RenderOutcome.Unchanged;
|
||||
|
||||
_host.RecordPanel(destination, width, height, in derived, in parameters).Wait();
|
||||
_panelKey = _pendingPanelKey;
|
||||
PanelRuns++;
|
||||
_host.RecordPanel(destination, width, height, in derived).Wait();
|
||||
CompletePanel(panelKey);
|
||||
return RenderOutcome.Rendered;
|
||||
}
|
||||
|
||||
@@ -134,12 +132,11 @@ internal sealed class MangaScreentonePipeline : IDisposable
|
||||
|
||||
var derived = MangaScreentoneSettings.Derive(width, height, in parameters);
|
||||
_host.RecordSharedSource(source, _scratch, width, height, in derived).Wait();
|
||||
if (!RunStages(width, height, in derived, in parameters, outputFresh))
|
||||
if (!RunStages(width, height, in derived, outputFresh, out var panelKey))
|
||||
return RenderOutcome.Unchanged;
|
||||
|
||||
_host.RecordSharedPanel(output, width, height, in derived, in parameters).Wait();
|
||||
_panelKey = _pendingPanelKey;
|
||||
PanelRuns++;
|
||||
_host.RecordSharedPanel(output, width, height, in derived).Wait();
|
||||
CompletePanel(panelKey);
|
||||
return RenderOutcome.Rendered;
|
||||
}
|
||||
|
||||
@@ -147,8 +144,8 @@ internal sealed class MangaScreentonePipeline : IDisposable
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived,
|
||||
in MangaScreentoneSettings.Parameters parameters,
|
||||
bool outputFresh)
|
||||
bool outputFresh,
|
||||
out PanelKey panelKey)
|
||||
{
|
||||
_scratchReadBack.CopyFrom(_scratch);
|
||||
var hashed = _scratchReadBack.Span;
|
||||
@@ -177,7 +174,7 @@ internal sealed class MangaScreentonePipeline : IDisposable
|
||||
ToneRuns++;
|
||||
}
|
||||
|
||||
if (parameters.WhiteLines && _cutVersion != _analysisVersion)
|
||||
if (derived.WhiteLines && _cutVersion != _analysisVersion)
|
||||
{
|
||||
_ = _host.RecordCut(width, height, in derived);
|
||||
_cutVersion = _analysisVersion;
|
||||
@@ -186,57 +183,41 @@ internal sealed class MangaScreentonePipeline : IDisposable
|
||||
|
||||
var printKey = new PrintKey(
|
||||
_toneVersion,
|
||||
parameters.WhiteLines ? _cutVersion : -1,
|
||||
derived.WhiteLines ? _cutVersion : -1,
|
||||
derived.Pitch,
|
||||
Math.Clamp(parameters.LightTone, 0f, 1f),
|
||||
Math.Clamp(parameters.DarkTone, 0f, 1f),
|
||||
Math.Clamp(parameters.Gradation, 0f, 1f),
|
||||
parameters.WhiteLines);
|
||||
derived.LightTone,
|
||||
derived.DarkTone,
|
||||
derived.Gradation,
|
||||
derived.WhiteLines);
|
||||
if (_printKey != printKey)
|
||||
{
|
||||
_ = _host.RecordPrint(width, height, in derived, in parameters);
|
||||
_ = _host.RecordPrint(width, height, in derived);
|
||||
_printKey = printKey;
|
||||
_printVersion++;
|
||||
PrintRuns++;
|
||||
}
|
||||
|
||||
_pendingPanelKey = new PanelKey(
|
||||
panelKey = new PanelKey(
|
||||
_printVersion,
|
||||
width,
|
||||
height,
|
||||
derived.MarginPixels,
|
||||
derived.BorderPixels,
|
||||
parameters.Paper,
|
||||
Math.Clamp(parameters.Ink, 0f, 1f));
|
||||
return outputFresh || _panelKey != _pendingPanelKey;
|
||||
derived.Paper,
|
||||
derived.InkStrength);
|
||||
return outputFresh || _panelKey != panelKey;
|
||||
}
|
||||
|
||||
private void CompletePanel(PanelKey panelKey)
|
||||
{
|
||||
_panelKey = panelKey;
|
||||
PanelRuns++;
|
||||
}
|
||||
|
||||
private bool EnsureGrid(int width, int height)
|
||||
{
|
||||
var length = checked(width * height);
|
||||
if (!_host.TryEnsureGrid(
|
||||
new MangaScreentoneResources.Plan(
|
||||
accentLength: length,
|
||||
blurALength: length,
|
||||
blurBLength: length,
|
||||
classesLength: length,
|
||||
cutLength: length,
|
||||
grayLength: length,
|
||||
inkLength: length,
|
||||
labelsLength: length,
|
||||
levelLength: length,
|
||||
levelNextLength: length,
|
||||
pageLength: length,
|
||||
smoothLength: length,
|
||||
solidLength: length,
|
||||
statALength: length,
|
||||
statBLength: length,
|
||||
statCLength: length,
|
||||
statDLength: length,
|
||||
statELength: length,
|
||||
valueALength: length,
|
||||
valueBLength: length),
|
||||
out var changed))
|
||||
if (!_host.TryEnsureGrid(MangaScreentoneResources.PerPixel(length), out var changed))
|
||||
return false;
|
||||
|
||||
if (changed || _gridLength != length)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ComputeWeave;
|
||||
using ComputeWeave.Descriptors;
|
||||
|
||||
namespace MangaScreentone;
|
||||
|
||||
@@ -64,14 +65,34 @@ internal sealed partial class MangaScreentoneResources
|
||||
|
||||
[ComputePipelineResource(ComputeResourceAccess.ReadWrite)]
|
||||
internal ReadWriteBuffer<uint> Cut { get; }
|
||||
|
||||
internal static Plan PerPixel(int length)
|
||||
=> new(
|
||||
accentLength: length,
|
||||
blurALength: length,
|
||||
blurBLength: length,
|
||||
classesLength: length,
|
||||
cutLength: length,
|
||||
grayLength: length,
|
||||
inkLength: length,
|
||||
labelsLength: length,
|
||||
levelLength: length,
|
||||
levelNextLength: length,
|
||||
pageLength: length,
|
||||
smoothLength: length,
|
||||
solidLength: length,
|
||||
statALength: length,
|
||||
statBLength: length,
|
||||
statCLength: length,
|
||||
statDLength: length,
|
||||
statELength: length,
|
||||
valueALength: length,
|
||||
valueBLength: length);
|
||||
}
|
||||
|
||||
[ComputePipelineHost("_device", 1)]
|
||||
internal sealed partial class MangaScreentonePipelineHost
|
||||
{
|
||||
private const int AreaOnly = 0;
|
||||
private const int Bounds = 1;
|
||||
private const int Moments = 2;
|
||||
private static readonly uint[] PlanOrder = [1u, 2u, 3u, 0u];
|
||||
|
||||
private readonly GraphicsDevice _device;
|
||||
@@ -155,12 +176,11 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
[ComputeOwnedResource(nameof(_grid))] MangaScreentoneResources grid,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived,
|
||||
in MangaScreentoneSettings.Parameters parameters)
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
_ = _device;
|
||||
|
||||
RecordPrintStage(in context, grid, width, height, in derived, in parameters);
|
||||
RecordPrintStage(in context, grid, width, height, in derived);
|
||||
}
|
||||
|
||||
[ComputePipeline]
|
||||
@@ -170,12 +190,11 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
[ComputeResource(ComputeResourceAccess.ReadWrite)] ReadWriteTexture2D<Bgra32, Float4> output,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived,
|
||||
in MangaScreentoneSettings.Parameters parameters)
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
_ = _device;
|
||||
|
||||
RecordPanelStage(in context, grid, output, width, height, in derived, in parameters);
|
||||
RecordPanelStage(in context, grid, output, width, height, in derived);
|
||||
}
|
||||
|
||||
[ComputePipeline]
|
||||
@@ -186,12 +205,17 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
[ComputeResource(ComputeResourceAccess.ReadWrite, Sharing = ComputeResourceSharing.External)] ReadWriteTexture2D<Bgra32, Float4> output,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived,
|
||||
in MangaScreentoneSettings.Parameters parameters)
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
_ = _device;
|
||||
|
||||
RecordPanelStage(in context, grid, output, width, height, in derived, in parameters);
|
||||
RecordPanelStage(in context, grid, output, width, height, in derived);
|
||||
}
|
||||
|
||||
private static void ForAligned<TShader>(in ComputeContext context, int width, int height, in TShader shader)
|
||||
where TShader : struct, IComputeShader, IComputeShaderDescriptor<TShader>
|
||||
{
|
||||
context.For(ThreadGroupAlignment.AlignX<TShader>(width), ThreadGroupAlignment.AlignY<TShader>(height), in shader);
|
||||
}
|
||||
|
||||
private static void RecordSourceStage(
|
||||
@@ -205,9 +229,10 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
{
|
||||
context.For(MangaScreentoneSettings.ScratchLength, new ScratchResetShader(scratch, MangaScreentoneSettings.ScratchLength));
|
||||
context.Barrier(scratch);
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<GrayShader>(width),
|
||||
ThreadGroupAlignment.AlignY<GrayShader>(height),
|
||||
ForAligned(
|
||||
in context,
|
||||
width,
|
||||
height,
|
||||
new GrayShader(
|
||||
source,
|
||||
grid.Gray,
|
||||
@@ -231,15 +256,25 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
float sigma,
|
||||
int radius)
|
||||
{
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<GaussianBlurShader>(width),
|
||||
ThreadGroupAlignment.AlignY<GaussianBlurShader>(height),
|
||||
new GaussianBlurShader(input, temporary, width, height, sigma, radius, 0));
|
||||
ForAligned(in context, width, height, new GaussianBlurShader(input, temporary, width, height, sigma, radius, 0));
|
||||
context.Barrier(temporary);
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<GaussianBlurShader>(width),
|
||||
ThreadGroupAlignment.AlignY<GaussianBlurShader>(height),
|
||||
new GaussianBlurShader(temporary, output, width, height, sigma, radius, 1));
|
||||
ForAligned(in context, width, height, new GaussianBlurShader(temporary, output, width, height, sigma, radius, 1));
|
||||
context.Barrier(output);
|
||||
}
|
||||
|
||||
private static void RecordBilateral(
|
||||
in ComputeContext context,
|
||||
ReadWriteBuffer<float> input,
|
||||
ReadWriteBuffer<float> output,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
ForAligned(
|
||||
in context,
|
||||
width,
|
||||
height,
|
||||
new BilateralShader(input, output, width, height, derived.BilateralRadius, derived.BilateralSpaceCoefficient, derived.BilateralColorCoefficient));
|
||||
context.Barrier(output);
|
||||
}
|
||||
|
||||
@@ -249,37 +284,39 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
ReadWriteBuffer<uint> classes,
|
||||
int width,
|
||||
int height,
|
||||
int diagonal,
|
||||
int mode)
|
||||
bool diagonal,
|
||||
ComponentStatistic statistic)
|
||||
{
|
||||
context.For(width, height, new ComponentInitShader(classes, grid.Labels, width, height, diagonal));
|
||||
context.For(width, height, new ComponentInitShader(classes, grid.Labels, width, height, diagonal ? 1 : 0));
|
||||
context.Barrier(grid.Labels);
|
||||
context.For(width, height, new ComponentUnionShader(classes, grid.Labels, width, height, diagonal));
|
||||
context.For(width, height, new ComponentUnionShader(classes, grid.Labels, width, height, diagonal ? 1 : 0));
|
||||
context.Barrier(grid.Labels);
|
||||
context.For(width, height, new ComponentFlattenShader(
|
||||
classes, grid.Labels, grid.StatA, grid.StatB, grid.StatC, grid.StatD, grid.StatE, width, height, mode == Bounds ? 1 : 0));
|
||||
classes, grid.Labels, grid.StatA, grid.StatB, grid.StatC, grid.StatD, grid.StatE, width, height, statistic == ComponentStatistic.Bounds ? 1 : 0));
|
||||
context.Barrier(grid.Labels);
|
||||
context.Barrier(grid.StatA);
|
||||
context.Barrier(grid.StatB);
|
||||
context.Barrier(grid.StatC);
|
||||
context.Barrier(grid.StatD);
|
||||
context.Barrier(grid.StatE);
|
||||
if (mode == Bounds)
|
||||
if (statistic == ComponentStatistic.Bounds)
|
||||
{
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<ComponentBoundsShader>(width),
|
||||
ThreadGroupAlignment.AlignY<ComponentBoundsShader>(height),
|
||||
ForAligned(
|
||||
in context,
|
||||
width,
|
||||
height,
|
||||
new ComponentBoundsShader(classes, grid.Labels, grid.StatA, grid.StatB, grid.StatC, grid.StatD, grid.StatE, width, height));
|
||||
context.Barrier(grid.StatB);
|
||||
context.Barrier(grid.StatC);
|
||||
context.Barrier(grid.StatD);
|
||||
context.Barrier(grid.StatE);
|
||||
}
|
||||
else if (mode == Moments)
|
||||
else if (statistic == ComponentStatistic.Moments)
|
||||
{
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<ComponentMomentShader>(width),
|
||||
ThreadGroupAlignment.AlignY<ComponentMomentShader>(height),
|
||||
ForAligned(
|
||||
in context,
|
||||
width,
|
||||
height,
|
||||
new ComponentMomentShader(classes, grid.Labels, grid.Smooth, grid.StatA, grid.StatB, grid.StatC, grid.StatD, width, height));
|
||||
context.Barrier(grid.StatB);
|
||||
context.Barrier(grid.StatC);
|
||||
@@ -287,10 +324,7 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
}
|
||||
else
|
||||
{
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<ComponentAreaShader>(width),
|
||||
ThreadGroupAlignment.AlignY<ComponentAreaShader>(height),
|
||||
new ComponentAreaShader(classes, grid.Labels, grid.StatA, width, height));
|
||||
ForAligned(in context, width, height, new ComponentAreaShader(classes, grid.Labels, grid.StatA, width, height));
|
||||
}
|
||||
context.Barrier(grid.StatA);
|
||||
}
|
||||
@@ -301,11 +335,31 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
RecordSolid(in context, grid, width, height, in derived);
|
||||
RecordInk(in context, grid, width, height, in derived);
|
||||
RecordValueMap(in context, grid, width, height, in derived);
|
||||
}
|
||||
|
||||
private static void RecordSolid(
|
||||
in ComputeContext context,
|
||||
MangaScreentoneResources grid,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
RecordBlur(in context, grid.Gray, grid.BlurA, grid.BlurB, width, height, derived.SolidSigma, derived.SolidRadius);
|
||||
context.For(width, height, new SolidShader(grid.BlurB, grid.Solid, width, height, MangaScreentoneSettings.SolidThreshold));
|
||||
context.Barrier(grid.Solid);
|
||||
}
|
||||
|
||||
private static void RecordInk(
|
||||
in ComputeContext context,
|
||||
MangaScreentoneResources grid,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
RecordBlur(in context, grid.Gray, grid.BlurA, grid.BlurB, width, height, derived.LineSigma, derived.LineRadius);
|
||||
var meanRadius = derived.LineMeanSize / 2;
|
||||
context.For(width, height, new BoxBlurShader(grid.BlurB, grid.BlurA, width, height, meanRadius, 0));
|
||||
@@ -316,37 +370,39 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
grid.BlurB, grid.ValueB, grid.Classes, width, height, MangaScreentoneSettings.LineContrast, MangaScreentoneSettings.LineCeiling));
|
||||
context.Barrier(grid.Classes);
|
||||
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, 1, Bounds);
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, true, ComponentStatistic.Bounds);
|
||||
context.For(width, height, new LineKeepShader(
|
||||
grid.Classes, grid.Labels, grid.StatA, grid.StatB, grid.StatC, grid.StatD, grid.StatE, grid.Solid, width, height,
|
||||
derived.StrokeMinLength, derived.StrokeMinArea, MangaScreentoneSettings.StrokeFillRatio, derived.StrokeFillBias, derived.StrokeLargeArea));
|
||||
context.Barrier(grid.Classes);
|
||||
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, 1, AreaOnly);
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, true, ComponentStatistic.Area);
|
||||
context.For(width, height, new InkFinalShader(grid.Classes, grid.Labels, grid.StatA, grid.Ink, width, height, derived.InkMinArea));
|
||||
context.Barrier(grid.Ink);
|
||||
}
|
||||
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<MaskedBlurHorizontalShader>(width),
|
||||
ThreadGroupAlignment.AlignY<MaskedBlurHorizontalShader>(height),
|
||||
private static void RecordValueMap(
|
||||
in ComputeContext context,
|
||||
MangaScreentoneResources grid,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
ForAligned(
|
||||
in context,
|
||||
width,
|
||||
height,
|
||||
new MaskedBlurHorizontalShader(grid.Gray, grid.Ink, grid.BlurA, grid.BlurB, width, height, derived.ValueSigma, derived.ValueRadius));
|
||||
context.Barrier(grid.BlurA);
|
||||
context.Barrier(grid.BlurB);
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<MaskedBlurVerticalShader>(width),
|
||||
ThreadGroupAlignment.AlignY<MaskedBlurVerticalShader>(height),
|
||||
ForAligned(
|
||||
in context,
|
||||
width,
|
||||
height,
|
||||
new MaskedBlurVerticalShader(grid.BlurA, grid.BlurB, grid.ValueA, width, height, derived.ValueSigma, derived.ValueRadius, MangaScreentoneSettings.ValueMinWeight));
|
||||
context.Barrier(grid.ValueA);
|
||||
for (var pass = 0; pass < 2; pass++)
|
||||
{
|
||||
var reading = pass == 0 ? grid.ValueA : grid.ValueB;
|
||||
var writing = pass == 0 ? grid.ValueB : grid.ValueA;
|
||||
context.For(
|
||||
ThreadGroupAlignment.AlignX<BilateralShader>(width),
|
||||
ThreadGroupAlignment.AlignY<BilateralShader>(height),
|
||||
new BilateralShader(reading, writing, width, height, derived.BilateralRadius, derived.BilateralSpaceCoefficient, derived.BilateralColorCoefficient));
|
||||
context.Barrier(writing);
|
||||
}
|
||||
RecordBilateral(in context, grid.ValueA, grid.ValueB, width, height, in derived);
|
||||
RecordBilateral(in context, grid.ValueB, grid.ValueA, width, height, in derived);
|
||||
}
|
||||
|
||||
private static void RecordCutStage(
|
||||
@@ -358,7 +414,7 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
{
|
||||
context.For(width, height, new StrokeClassShader(grid.Ink, grid.Solid, grid.Classes, width, height));
|
||||
context.Barrier(grid.Classes);
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, 1, Bounds);
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, true, ComponentStatistic.Bounds);
|
||||
context.For(width, height, new CutKeepShader(
|
||||
grid.Classes, grid.Labels, grid.StatB, grid.StatC, grid.StatD, grid.StatE, grid.LevelNext, width, height, derived.CutMinLength));
|
||||
context.Barrier(grid.LevelNext);
|
||||
@@ -372,6 +428,18 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
RecordToneLevels(in context, grid, width, height, in derived);
|
||||
var level = RecordSmallRegionFill(in context, grid, width, height, in derived);
|
||||
RecordRegionSpread(in context, grid, level, width, height, in derived);
|
||||
}
|
||||
|
||||
private static void RecordToneLevels(
|
||||
in ComputeContext context,
|
||||
MangaScreentoneResources grid,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
context.For(width, height, new DigitizeShader(
|
||||
grid.ValueA, grid.Level, width, height, derived.White, (derived.White + derived.Black) * 0.5f, derived.Black));
|
||||
@@ -382,7 +450,15 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
context.Barrier(grid.StatC);
|
||||
context.For(width, height, new MedianResolveShader(grid.StatB, grid.StatC, grid.Level, width, height, planRadius));
|
||||
context.Barrier(grid.Level);
|
||||
}
|
||||
|
||||
private static ReadWriteBuffer<uint> RecordSmallRegionFill(
|
||||
in ComputeContext context,
|
||||
MangaScreentoneResources grid,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
var fillRadius = derived.PlanFillMedianSize / 2;
|
||||
var current = grid.Level;
|
||||
var next = grid.LevelNext;
|
||||
@@ -390,10 +466,10 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
{
|
||||
context.For(width, height, new ClassFromLevelShader(current, grid.Classes, width, height, target));
|
||||
context.Barrier(grid.Classes);
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, 0, AreaOnly);
|
||||
RecordComponents(in context, grid, grid.Classes, width, height, false, ComponentStatistic.Area);
|
||||
context.For(width, height, new HoleMarkShader(current, grid.Labels, grid.StatA, grid.Classes, width, height, target, derived.PlanMinRegion));
|
||||
context.Barrier(grid.Classes);
|
||||
context.For(width, height, new HoleCountShader(grid.Classes, grid.StatB, grid.StatC, width, height, fillRadius));
|
||||
ForAligned(in context, width, height, new HoleCountShader(grid.Classes, grid.StatB, grid.StatC, width, height, fillRadius));
|
||||
context.Barrier(grid.StatB);
|
||||
context.Barrier(grid.StatC);
|
||||
context.For(width, height, new HoleResolveShader(current, grid.Classes, grid.StatB, grid.StatC, next, width, height, fillRadius));
|
||||
@@ -401,10 +477,21 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
(current, next) = (next, current);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
private static void RecordRegionSpread(
|
||||
in ComputeContext context,
|
||||
MangaScreentoneResources grid,
|
||||
ReadWriteBuffer<uint> level,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
RecordBlur(in context, grid.ValueA, grid.BlurA, grid.Smooth, width, height, derived.SpreadSigma, derived.SpreadRadius);
|
||||
RecordComponents(in context, grid, current, width, height, 0, Moments);
|
||||
RecordComponents(in context, grid, level, width, height, false, ComponentStatistic.Moments);
|
||||
context.For(width, height, new SpreadResolveShader(
|
||||
current, grid.Labels, grid.StatA, grid.StatB, grid.StatC, grid.StatD, grid.BlurA, width, height,
|
||||
level, grid.Labels, grid.StatA, grid.StatB, grid.StatC, grid.StatD, grid.BlurA, width, height,
|
||||
MangaScreentoneSettings.SpreadFloor, MangaScreentoneSettings.SpreadRange));
|
||||
context.Barrier(grid.BlurA);
|
||||
RecordBlur(in context, grid.BlurA, grid.BlurB, grid.Accent, width, height, derived.SmoothSigma, derived.SmoothRadius);
|
||||
@@ -415,21 +502,20 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
MangaScreentoneResources grid,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived,
|
||||
in MangaScreentoneSettings.Parameters parameters)
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
context.For(width, height, new CoverShader(
|
||||
grid.Level, grid.Smooth, grid.Accent, grid.BlurA, width, height, derived.White, derived.Black,
|
||||
Math.Clamp(parameters.LightTone, 0f, 1f), Math.Clamp(parameters.DarkTone, 0f, 1f), Math.Clamp(parameters.Gradation, 0f, 1f)));
|
||||
derived.LightTone, derived.DarkTone, derived.Gradation));
|
||||
context.Barrier(grid.BlurA);
|
||||
context.For(width, height, new PrintShader(grid.BlurA, grid.Page, width, height, derived.Pitch));
|
||||
context.Barrier(grid.Page);
|
||||
if (parameters.WhiteLines)
|
||||
if (derived.WhiteLines)
|
||||
{
|
||||
context.For(width, height, new ErodeShader(grid.Level, grid.LevelNext, width, height, derived.BetaSize, 3u));
|
||||
context.Barrier(grid.LevelNext);
|
||||
}
|
||||
context.For(width, height, new PageShader(grid.Page, grid.Ink, grid.LevelNext, grid.Cut, width, height, parameters.WhiteLines ? 1 : 0));
|
||||
context.For(width, height, new PageShader(grid.Page, grid.Ink, grid.LevelNext, grid.Cut, width, height, derived.WhiteLines ? 1 : 0));
|
||||
context.Barrier(grid.Page);
|
||||
}
|
||||
|
||||
@@ -439,11 +525,9 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
ReadWriteTexture2D<Bgra32, Float4> output,
|
||||
int width,
|
||||
int height,
|
||||
in MangaScreentoneSettings.Derived derived,
|
||||
in MangaScreentoneSettings.Parameters parameters)
|
||||
in MangaScreentoneSettings.Derived derived)
|
||||
{
|
||||
var paper = MangaScreentoneSettings.GetPaper(parameters.Paper);
|
||||
var ink = Math.Clamp(parameters.Ink, 0f, 1f);
|
||||
var paper = MangaScreentoneSettings.GetPaper(derived.Paper);
|
||||
var canvasWidth = width + derived.MarginPixels * 2;
|
||||
var canvasHeight = height + derived.MarginPixels * 2;
|
||||
context.For(canvasWidth, canvasHeight, new PanelShader(
|
||||
@@ -457,16 +541,23 @@ internal sealed partial class MangaScreentonePipelineHost
|
||||
derived.BorderPixels,
|
||||
derived.InkRadius,
|
||||
derived.InkSigma,
|
||||
ink,
|
||||
derived.InkStrength,
|
||||
derived.InkMottleCoarse,
|
||||
derived.InkMottleFine,
|
||||
paper.R,
|
||||
paper.G,
|
||||
paper.B,
|
||||
paper.Fibre,
|
||||
parameters.Paper == MangaScreentonePaper.Transparent ? 1 : 0,
|
||||
derived.Paper == MangaScreentonePaper.Transparent ? 1 : 0,
|
||||
MangaScreentoneSettings.InkColor.R,
|
||||
MangaScreentoneSettings.InkColor.G,
|
||||
MangaScreentoneSettings.InkColor.B));
|
||||
}
|
||||
|
||||
private enum ComponentStatistic
|
||||
{
|
||||
Area,
|
||||
Bounds,
|
||||
Moments,
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ internal readonly partial struct PrintShader(
|
||||
|
||||
var u = (sampleX * cosine + sampleY * sine) * scale;
|
||||
var v = (-sampleX * sine + sampleY * cosine) * scale;
|
||||
var spot = 1f - (Hlsl.Cos(6.2831855f * Hlsl.Frac(u)) + Hlsl.Cos(6.2831855f * Hlsl.Frac(v)) + 2f) * 0.25f;
|
||||
var spot = 1f - (Hlsl.Cos(MangaScreentoneShaderMath.TwoPi * Hlsl.Frac(u)) + Hlsl.Cos(MangaScreentoneShaderMath.TwoPi * Hlsl.Frac(v)) + 2f) * 0.25f;
|
||||
if (spot < coverage)
|
||||
dots++;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,14 @@ internal static class MangaScreentoneSettings
|
||||
public const float MinimumToneGap = 0.02f;
|
||||
public const float MinimumLevelGap = 1e-3f;
|
||||
public const float MinimumScreenLines = 1f;
|
||||
public const float MinimumWhitePoint = 0.3f;
|
||||
public const float MaximumBlackPoint = 0.7f;
|
||||
public const float MaximumBlackLevel = 0.9f;
|
||||
public const float MinimumWhiteLevel = 0.1f;
|
||||
public const float MinimumGamma = 0.3f;
|
||||
public const float MaximumGamma = 3f;
|
||||
public const float MaximumBorder = 40f;
|
||||
public const float MaximumMargin = 400f;
|
||||
public const int MaximumMedianSize = 255;
|
||||
public const int BlurGroupSize = 8;
|
||||
public const int MaximumGaussianRadius = 128;
|
||||
@@ -52,6 +60,10 @@ internal static class MangaScreentoneSettings
|
||||
public const int MaximumCanvasSize = 8192;
|
||||
public const int NoiseSeedInk = 1;
|
||||
public const int NoiseSeedFibre = 2;
|
||||
public const uint NoiseSaltInkCoarse = 0x51ED270Bu;
|
||||
public const uint NoiseSaltInkFine = 0x2C1B3C6Du;
|
||||
public const uint NoiseSaltFibreCoarse = 0x297A2D39u;
|
||||
public const uint NoiseSaltFibreFine = 0x68E31DA4u;
|
||||
public const int ScratchLength = 8;
|
||||
public const int ScratchHashSum = 0;
|
||||
public const int ScratchHashMix = 1;
|
||||
@@ -78,16 +90,16 @@ internal static class MangaScreentoneSettings
|
||||
|
||||
public static (float White, float Black) NormalizeTonePoints(float white, float black)
|
||||
{
|
||||
var clampedWhite = Math.Clamp(white, 0.3f, 1f);
|
||||
var clampedBlack = Math.Clamp(black, 0f, 0.7f);
|
||||
var clampedWhite = Math.Clamp(white, MinimumWhitePoint, 1f);
|
||||
var clampedBlack = Math.Clamp(black, 0f, MaximumBlackPoint);
|
||||
return (Math.Max(clampedWhite, clampedBlack + MinimumToneGap), clampedBlack);
|
||||
}
|
||||
|
||||
public static (float Black, float White, float Gamma) NormalizeLevels(float black, float white, float gamma)
|
||||
{
|
||||
var clampedBlack = Math.Clamp(black, 0f, 0.9f);
|
||||
var clampedWhite = Math.Clamp(white, 0.1f, 1f);
|
||||
return (clampedBlack, Math.Max(clampedWhite, clampedBlack + MinimumLevelGap), Math.Clamp(gamma, 0.3f, 3f));
|
||||
var clampedBlack = Math.Clamp(black, 0f, MaximumBlackLevel);
|
||||
var clampedWhite = Math.Clamp(white, MinimumWhiteLevel, 1f);
|
||||
return (clampedBlack, Math.Max(clampedWhite, clampedBlack + MinimumLevelGap), Math.Clamp(gamma, MinimumGamma, MaximumGamma));
|
||||
}
|
||||
|
||||
public static Derived Derive(int width, int height, in Parameters parameters)
|
||||
@@ -100,50 +112,56 @@ internal static class MangaScreentoneSettings
|
||||
var bilateralWindow = OddKernel(BilateralWindow * k);
|
||||
var bilateralSpace = BilateralSigmaSpace * k;
|
||||
var bilateralColor = (double)BilateralSigmaColor;
|
||||
var borderPixels = Math.Max((int)Math.Round(Math.Clamp(parameters.Border, 0f, 40f) * k, MidpointRounding.ToEven), 0);
|
||||
var borderPixels = Math.Max((int)Math.Round(Math.Clamp(parameters.Border, 0f, MaximumBorder) * k, MidpointRounding.ToEven), 0);
|
||||
var marginLimit = Math.Max((MaximumCanvasSize - Math.Max(width, height)) / 2, 0);
|
||||
var marginPixels = Math.Clamp((int)Math.Round(Math.Clamp(parameters.Margin, 0f, 400f) * k, MidpointRounding.ToEven), 0, marginLimit);
|
||||
var marginPixels = Math.Clamp((int)Math.Round(Math.Clamp(parameters.Margin, 0f, MaximumMargin) * k, MidpointRounding.ToEven), 0, marginLimit);
|
||||
var ink = Math.Clamp(parameters.Ink, 0f, 1f);
|
||||
var inkSigma = InkSpreadSigma * k * ink;
|
||||
return new Derived(
|
||||
(float)k,
|
||||
(float)(SolidBlurSigma * k),
|
||||
GaussianRadius(SolidBlurSigma * k),
|
||||
(float)(LineBlurSigma * k),
|
||||
GaussianRadius(LineBlurSigma * k),
|
||||
OddKernel(LineMeanSize * k),
|
||||
(float)(StrokeMinLength * k),
|
||||
(float)(StrokeMinArea * squared),
|
||||
(float)(StrokeFillBias * squared),
|
||||
(float)(StrokeLargeArea * squared),
|
||||
(float)(InkMinArea * squared),
|
||||
(float)(ValueBlurSigma * k),
|
||||
GaussianRadius(ValueBlurSigma * k),
|
||||
bilateralWindow / 2,
|
||||
(float)(-0.5d / (bilateralSpace * bilateralSpace)),
|
||||
(float)(-0.5d / (bilateralColor * bilateralColor)),
|
||||
Math.Min(OddKernel(PlanMedianSize * k), MaximumMedianSize),
|
||||
Math.Min(OddKernel(PlanFillMedianSize * k), MaximumMedianSize),
|
||||
(float)(PlanMinRegion * squared),
|
||||
(float)(SpreadBlurSigma * k),
|
||||
GaussianRadius(SpreadBlurSigma * k),
|
||||
(float)(SpreadSmoothSigma * k),
|
||||
GaussianRadius(SpreadSmoothSigma * k),
|
||||
OddKernel(BetaSize * k),
|
||||
(float)(CutMinLength * k),
|
||||
k < CutErodeThreshold ? 2 : 3,
|
||||
(float)(width / (double)lines),
|
||||
white,
|
||||
black,
|
||||
levelBlack,
|
||||
levelWhite,
|
||||
gamma,
|
||||
borderPixels,
|
||||
marginPixels,
|
||||
(float)inkSigma,
|
||||
GaussianRadius(inkSigma),
|
||||
Math.Max((int)(InkMottleCoarse * k), 1),
|
||||
Math.Max((int)(InkMottleFine * k), 1));
|
||||
Scale: (float)k,
|
||||
SolidSigma: (float)(SolidBlurSigma * k),
|
||||
SolidRadius: GaussianRadius(SolidBlurSigma * k),
|
||||
LineSigma: (float)(LineBlurSigma * k),
|
||||
LineRadius: GaussianRadius(LineBlurSigma * k),
|
||||
LineMeanSize: OddKernel(LineMeanSize * k),
|
||||
StrokeMinLength: (float)(StrokeMinLength * k),
|
||||
StrokeMinArea: (float)(StrokeMinArea * squared),
|
||||
StrokeFillBias: (float)(StrokeFillBias * squared),
|
||||
StrokeLargeArea: (float)(StrokeLargeArea * squared),
|
||||
InkMinArea: (float)(InkMinArea * squared),
|
||||
ValueSigma: (float)(ValueBlurSigma * k),
|
||||
ValueRadius: GaussianRadius(ValueBlurSigma * k),
|
||||
BilateralRadius: bilateralWindow / 2,
|
||||
BilateralSpaceCoefficient: (float)(-0.5d / (bilateralSpace * bilateralSpace)),
|
||||
BilateralColorCoefficient: (float)(-0.5d / (bilateralColor * bilateralColor)),
|
||||
PlanMedianSize: Math.Min(OddKernel(PlanMedianSize * k), MaximumMedianSize),
|
||||
PlanFillMedianSize: Math.Min(OddKernel(PlanFillMedianSize * k), MaximumMedianSize),
|
||||
PlanMinRegion: (float)(PlanMinRegion * squared),
|
||||
SpreadSigma: (float)(SpreadBlurSigma * k),
|
||||
SpreadRadius: GaussianRadius(SpreadBlurSigma * k),
|
||||
SmoothSigma: (float)(SpreadSmoothSigma * k),
|
||||
SmoothRadius: GaussianRadius(SpreadSmoothSigma * k),
|
||||
BetaSize: OddKernel(BetaSize * k),
|
||||
CutMinLength: (float)(CutMinLength * k),
|
||||
CutErodeSize: k < CutErodeThreshold ? 2 : 3,
|
||||
Pitch: (float)(width / (double)lines),
|
||||
White: white,
|
||||
Black: black,
|
||||
LevelBlack: levelBlack,
|
||||
LevelWhite: levelWhite,
|
||||
Gamma: gamma,
|
||||
BorderPixels: borderPixels,
|
||||
MarginPixels: marginPixels,
|
||||
InkSigma: (float)inkSigma,
|
||||
InkRadius: GaussianRadius(inkSigma),
|
||||
InkMottleCoarse: Math.Max((int)(InkMottleCoarse * k), 1),
|
||||
InkMottleFine: Math.Max((int)(InkMottleFine * k), 1),
|
||||
LightTone: Math.Clamp(parameters.LightTone, 0f, 1f),
|
||||
DarkTone: Math.Clamp(parameters.DarkTone, 0f, 1f),
|
||||
Gradation: Math.Clamp(parameters.Gradation, 0f, 1f),
|
||||
InkStrength: ink,
|
||||
WhiteLines: parameters.WhiteLines,
|
||||
Paper: parameters.Paper);
|
||||
}
|
||||
|
||||
internal readonly record struct Derived(
|
||||
@@ -184,7 +202,13 @@ internal static class MangaScreentoneSettings
|
||||
float InkSigma,
|
||||
int InkRadius,
|
||||
int InkMottleCoarse,
|
||||
int InkMottleFine);
|
||||
int InkMottleFine,
|
||||
float LightTone,
|
||||
float DarkTone,
|
||||
float Gradation,
|
||||
float InkStrength,
|
||||
bool WhiteLines,
|
||||
MangaScreentonePaper Paper);
|
||||
|
||||
internal readonly record struct Parameters(
|
||||
float ScreenLines,
|
||||
|
||||
@@ -5,6 +5,12 @@ namespace MangaScreentone;
|
||||
|
||||
internal static class MangaScreentoneShaderMath
|
||||
{
|
||||
public const float TwoPi = 6.2831855f;
|
||||
public const float Sqrt3 = 1.7320508f;
|
||||
public const uint LaneBits = 16u;
|
||||
public const uint LaneUnit = 1u << 16;
|
||||
public const uint LaneMask = LaneUnit - 1u;
|
||||
|
||||
public static int Reflect(int index, int length)
|
||||
{
|
||||
if (index >= 0 && index < length)
|
||||
@@ -49,7 +55,7 @@ internal static class MangaScreentoneShaderMath
|
||||
{
|
||||
var key = ((uint)x * 0x9E3779B9u) ^ ((uint)y * 0x85EBCA6Bu) ^ (seed * 0xC2B2AE35u) ^ salt;
|
||||
var sum = Hash01(key) + Hash01(key ^ 0x27D4EB2Fu) + Hash01(key ^ 0x165667B1u) + Hash01(key ^ 0x1B873593u);
|
||||
return (sum - 2f) * 1.7320508f;
|
||||
return (sum - 2f) * Sqrt3;
|
||||
}
|
||||
|
||||
public static float CubicWeight(int tap, float t)
|
||||
@@ -101,4 +107,26 @@ internal static class MangaScreentoneShaderMath
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static uint Median(uint low, uint high, uint total)
|
||||
{
|
||||
var threshold = (total + 1u) / 2u;
|
||||
var level0 = low & LaneMask;
|
||||
var level1 = low >> (int)LaneBits;
|
||||
var level2 = high & LaneMask;
|
||||
var level3 = high >> (int)LaneBits;
|
||||
var cumulative = level0;
|
||||
if (cumulative >= threshold)
|
||||
return 0u;
|
||||
cumulative += level1;
|
||||
if (cumulative >= threshold)
|
||||
return 1u;
|
||||
cumulative += level2;
|
||||
if (cumulative >= threshold)
|
||||
return 2u;
|
||||
cumulative += level3;
|
||||
if (cumulative >= threshold)
|
||||
return 3u;
|
||||
return 255u;
|
||||
}
|
||||
}
|
||||
@@ -227,11 +227,11 @@ internal readonly partial struct MedianCountShader(
|
||||
if (value == 0u)
|
||||
low += 1u;
|
||||
else if (value == 1u)
|
||||
low += 65536u;
|
||||
low += MangaScreentoneShaderMath.LaneUnit;
|
||||
else if (value == 2u)
|
||||
high += 1u;
|
||||
else
|
||||
high += 65536u;
|
||||
high += MangaScreentoneShaderMath.LaneUnit;
|
||||
}
|
||||
countLow[row + x] = low;
|
||||
countHigh[row + x] = high;
|
||||
@@ -270,7 +270,7 @@ internal readonly partial struct MedianResolveShader(
|
||||
low += countLow[index];
|
||||
high += countHigh[index];
|
||||
}
|
||||
output[y * width + x] = MangaScreentoneToneMath.Median(low, high, (uint)((2 * radius + 1) * (2 * radius + 1)));
|
||||
output[y * width + x] = MangaScreentoneShaderMath.Median(low, high, (uint)((2 * radius + 1) * (2 * radius + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ internal readonly partial struct HoleMarkShader(
|
||||
}
|
||||
}
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.XY)]
|
||||
[ThreadGroupSize(MangaScreentoneSettings.BlurGroupSize, MangaScreentoneSettings.BlurGroupSize, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct HoleCountShader(
|
||||
ReadWriteBuffer<uint> marked,
|
||||
@@ -353,8 +353,29 @@ internal readonly partial struct HoleCountShader(
|
||||
private readonly int height = height;
|
||||
private readonly int radius = radius;
|
||||
|
||||
[GroupShared(1)]
|
||||
private static readonly int[] holeNearby = null!;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (GroupIds.Index == 0)
|
||||
holeNearby[0] = 0;
|
||||
Hlsl.GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
var left = ThreadIds.X - GroupIds.X;
|
||||
var top = ThreadIds.Y - GroupIds.Y;
|
||||
var span = MangaScreentoneSettings.BlurGroupSize + 2 * radius;
|
||||
for (var cell = GroupIds.Index; cell < MangaScreentoneSettings.BlurGroupSize * span; cell += MangaScreentoneSettings.BlurGroupSize * MangaScreentoneSettings.BlurGroupSize)
|
||||
{
|
||||
var column = left + cell % MangaScreentoneSettings.BlurGroupSize;
|
||||
var line = top - radius + cell / MangaScreentoneSettings.BlurGroupSize;
|
||||
if (column < width && line >= 0 && line < height && marked[line * width + column] == MangaScreentoneSettings.HoleMarker)
|
||||
Hlsl.InterlockedOr(ref holeNearby[0], 1);
|
||||
}
|
||||
Hlsl.GroupMemoryBarrierWithGroupSync();
|
||||
if (holeNearby[0] == 0)
|
||||
return;
|
||||
|
||||
var x = ThreadIds.X;
|
||||
var y = ThreadIds.Y;
|
||||
if (x >= width || y >= height)
|
||||
@@ -369,11 +390,11 @@ internal readonly partial struct HoleCountShader(
|
||||
if (value == 0u)
|
||||
low += 1u;
|
||||
else if (value == 1u)
|
||||
low += 65536u;
|
||||
low += MangaScreentoneShaderMath.LaneUnit;
|
||||
else if (value == 2u)
|
||||
high += 1u;
|
||||
else if (value == 3u)
|
||||
high += 65536u;
|
||||
high += MangaScreentoneShaderMath.LaneUnit;
|
||||
}
|
||||
countLow[row + x] = low;
|
||||
countHigh[row + x] = high;
|
||||
@@ -424,7 +445,7 @@ internal readonly partial struct HoleResolveShader(
|
||||
low += countLow[sample];
|
||||
high += countHigh[sample];
|
||||
}
|
||||
var fill = MangaScreentoneToneMath.Median(low, high, (uint)((2 * radius + 1) * (2 * radius + 1)));
|
||||
var fill = MangaScreentoneShaderMath.Median(low, high, (uint)((2 * radius + 1) * (2 * radius + 1)));
|
||||
output[index] = fill != MangaScreentoneSettings.HoleMarker ? fill : current;
|
||||
}
|
||||
}
|
||||
@@ -473,28 +494,3 @@ internal readonly partial struct SpreadResolveShader(
|
||||
output[index] = Hlsl.Saturate((deviation - floor) / range);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class MangaScreentoneToneMath
|
||||
{
|
||||
public static uint Median(uint low, uint high, uint total)
|
||||
{
|
||||
var threshold = (total + 1u) / 2u;
|
||||
var level0 = low & 65535u;
|
||||
var level1 = low >> 16;
|
||||
var level2 = high & 65535u;
|
||||
var level3 = high >> 16;
|
||||
var cumulative = level0;
|
||||
if (cumulative >= threshold)
|
||||
return 0u;
|
||||
cumulative += level1;
|
||||
if (cumulative >= threshold)
|
||||
return 1u;
|
||||
cumulative += level2;
|
||||
if (cumulative >= threshold)
|
||||
return 2u;
|
||||
cumulative += level3;
|
||||
if (cumulative >= threshold)
|
||||
return 3u;
|
||||
return 255u;
|
||||
}
|
||||
}
|
||||
@@ -46,3 +46,5 @@ PaperTransparent,,透明,Transparent,透明,透明,투명,Transparente,شفاف,
|
||||
PaperTransparentDescription,,紙を描かず、インクだけを残します,Draws no paper and keeps only the ink,不绘制纸张,只保留墨迹,不繪製紙張,只保留墨跡,종이를 그리지 않고 잉크만 남깁니다,No dibuja el papel y conserva solo la tinta,لا يرسم الورق ويُبقي الحبر فقط,Tidak menggambar kertas dan hanya menyisakan tinta
|
||||
Ink,,インクの質感,Ink Texture,墨迹质感,墨跡質感,잉크 질감,Textura de tinta,ملمس الحبر,Tekstur Tinta
|
||||
InkDescription,,インクの縁のにじみと、ベタのむらです。0で純粋な白と黒になります,Softness of the ink edges and unevenness of solid blacks. At 0 the result is pure black and white,墨迹边缘的柔和程度与纯黑区域的不均匀感。为0时为纯粹的黑白,墨跡邊緣的柔和程度與純黑區域的不均勻感。為0時為純粹的黑白,잉크 가장자리의 번짐과 검은 면의 얼룩입니다. 0이면 순수한 흰색과 검은색이 됩니다,Suavidad de los bordes de la tinta y desigualdad de los negros sólidos. Con 0 el resultado es blanco y negro puros,نعومة حواف الحبر وعدم انتظام الأسود الكامل. عند 0 تكون النتيجة أبيض وأسود نقيين,Kelembutan tepi tinta dan ketidakmerataan hitam pekat. Pada 0 hasilnya hitam putih murni
|
||||
KeepTransparent,,透明部分を保つ,Keep Transparency,保留透明部分,保留透明部分,투명 부분 유지,Mantener transparencia,الإبقاء على الشفافية,Pertahankan Transparansi
|
||||
KeepTransparentDescription,,素材の透明な部分を透明のまま出力し、キャラクターの輪郭の外へは何も描きません。余白は現れず、用紙と枠線は輪郭の内側にだけ残ります,"Outputs transparent parts of the source as transparent, so nothing is drawn outside the character's outline. The margin disappears, and the paper and border remain only inside the outline",素材的透明部分保持透明,不会在角色轮廓之外绘制任何内容。边距不会出现,纸张和边框只保留在轮廓内侧,素材的透明部分保持透明,不會在角色輪廓之外繪製任何內容。邊距不會出現,紙張和邊框只保留在輪廓內側,"소재의 투명한 부분을 투명한 채로 출력하며, 캐릭터 윤곽 바깥에는 아무것도 그리지 않습니다. 여백은 나타나지 않고, 종이와 테두리는 윤곽 안쪽에만 남습니다","Mantiene transparentes las partes transparentes del material, así que no se dibuja nada fuera del contorno del personaje. El margen desaparece, y el papel y el borde solo quedan dentro del contorno",يُبقي الأجزاء الشفافة من المادة شفافة، فلا يُرسم أي شيء خارج حدود الشخصية. يختفي الهامش، ويبقى الورق والإطار داخل الحدود فقط,"Bagian transparan pada bahan tetap transparan, sehingga tidak ada yang digambar di luar kontur karakter. Margin tidak muncul, dan kertas serta bingkai hanya tersisa di dalam kontur"
|
||||
|
@@ -12,7 +12,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を白黒の漫画の原
|
||||
同じ素材と設定なら、同じGPUとドライバーで常に同じ絵になります。
|
||||
強さ、網点の細かさ、白点、黒点、薄いトーン、濃いトーン、グラデーション、黒レベル、白レベル、ガンマ、枠線、余白、インクの質感の13項目はアニメーションに対応しています。
|
||||
|
||||

|
||||

|
||||
|
||||
---
|
||||
|
||||
@@ -53,7 +53,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を白黒の漫画の原
|
||||
|
||||
使う前に知っておくことがあります。
|
||||
|
||||
- 背景が透明な素材は、強さが100%のとき、既定の用紙「白」では白い紙で埋まります。背景を透明のまま残すときは、用紙を「透明」にします。
|
||||
- 背景が透明な素材は、強さが100%のとき、既定では白い紙で埋まります。キャラクターの輪郭の外を透明のまま残すときは、「透明部分を保つ」をオンにします。
|
||||
- 動画では、フレームごとに線や面の境が切り替わり、ちらつくことがあります。動く被写体の上でも、網点は被写体に付いて動かず、素材の左上に固定されます。
|
||||
- 余白を足すと、出力は素材より大きくなります。
|
||||
- 既定では、5pxの黒い枠線が付き、インクの質感で縁が少しにじみます。用紙が白のとき、枠線を0に、インクの質感を0%にすると、純粋な白と黒になります。
|
||||
@@ -138,7 +138,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を白黒の漫画の原
|
||||
|
||||
格子に沿って隣り合う網点の中心の間隔は、素材の横幅を「網点の細かさ」で割った画素数です。印刷では、網点の細かさを、1インチあたりに網点の列が何本並ぶかで表し、線数と呼びます。「網点の細かさ」は、この線数に当たる値で、200なら、間隔は素材の横幅の200分の1です。
|
||||
|
||||
網点の形は、格子の中の位置から求めた数「1 − (cos(2πu) + cos(2πv) + 2) ÷ 4」が面積率より小さい位置を、網点の内側にして決めます。uとvは、格子に沿った座標です。この数は、網点の中心で0になり、中心から離れるほど大きくなります。網点は、面積率が小さいうちは丸い形で、50%に近づくと隣り合う網点がつながり、50%を超えると白い丸が残ります。画素を3×3の9個に分け、5個以上が網点の内側なら、その画素を黒にします。ページ全体で1種類の格子を使うため、面の境で網点の並びがずれません。
|
||||
網点の形は、格子の中の位置から求めた数$1 - \dfrac{\cos(2\pi u) + \cos(2\pi v) + 2}{4}$が面積率より小さい位置を、網点の内側にして決めます。$u$と$v$は、格子に沿った座標です。この数は、網点の中心で0になり、中心から離れるほど大きくなります。網点は、面積率が小さいうちは丸い形で、50%に近づくと隣り合う網点がつながり、50%を超えると白い丸が残ります。画素を3×3の9個に分け、5個以上が網点の内側なら、その画素を黒にします。ページ全体で1種類の格子を使うため、面の境で網点の並びがずれません。
|
||||
|
||||
網点の格子は素材の左上を基準に置くため、素材を移動すると、網点も素材に付いて動きます。素材の中で被写体が動いても、網点は被写体に付いて動かず、素材の左上に固定されます。網点の間隔は、実際の画素数で5画素以上にすることを目安にしてください。小さい素材で「網点の細かさ」を上げると、網点がつぶれます。
|
||||
|
||||
@@ -170,6 +170,8 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を白黒の漫画の原
|
||||
|
||||
「インクの質感」は、インクの縁をわずかににじませ、黒い部分の濃さにむらを付けます。インクは黒に近い色で、質感を上げるほど少し明るくなります。0%にすると、にじみもむらも付かず、用紙が白なら純粋な白と黒になります。
|
||||
|
||||
「透明部分を保つ」をオンにすると、素材の透明な部分は透明のまま出力され、キャラクターの輪郭の外へは何も描かれません。余白は出力に現れず、用紙と枠線は輪郭の内側にだけ残ります。用紙が「透明」でなければ、出力の不透明度は素材の不透明度と同じで、半透明の縁もそのまま残ります。既定はオフです。
|
||||
|
||||
---
|
||||
|
||||
## パラメータ一覧
|
||||
@@ -208,6 +210,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を白黒の漫画の原
|
||||
| 余白 | 数値 | 0px | 0〜400px | 対応 | 素材の周りへ足す用紙の余白です。出力は、余白の2倍だけ縦横に大きくなります。素材の横幅が1024画素のときの画素数で指定します。 |
|
||||
| 用紙 | 列挙 | 白 | 白 / 生成り / クリーム / 透明 | 非対応 | 用紙の色です。透明にすると、インクだけを残します。 |
|
||||
| インクの質感 | 数値 | 50% | 0〜100% | 対応 | インクの縁のにじみと、黒い部分の濃さのむらです。0%では、用紙が白なら純粋な白と黒になります。 |
|
||||
| 透明部分を保つ | ON/OFF | OFF | — | 非対応 | 素材の透明な部分を透明のまま出力し、キャラクターの輪郭の外へは何も描きません。余白は出力に現れず、用紙と枠線は輪郭の内側にだけ残ります。 |
|
||||
|
||||
---
|
||||
|
||||
@@ -236,7 +239,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を白黒の漫画の原
|
||||
やり直さない段階は、直前のフレームで計算した結果をそのまま使います。使えるのは直前の結果だけです。フレームごとに画素が変わる動画では、毎フレーム4つの段階をすべて計算し直します。静止画では、変えた項目にかかわる段階だけを計算し直すため、軽くなります。
|
||||
- 強さ0%: 強さが0%のときは入力を変更せず、漫画に仕上げる計算も行いません。余白も付きません。強さを0%から上げたフレームでは、素材と設定のうち、最後に計算したときから変わったものにかかわる計算だけをやり直します。
|
||||
- 再現性: 結果は素材と設定だけから決まり、時刻と乱数は使いません。インクのむらと用紙の繊維の濃淡は、画素の位置から決まる固定の模様です。画素の位置は、余白を含む出力の左上から数えるため、余白を変えると模様の位置が変わります。同じ素材と設定なら、同じGPUとドライバーで常に同じ絵になります。
|
||||
- 透明部分: 素材の透明な部分は、白い紙とみなして処理します。そのため、暗い素材を切り抜いた縁には、線が出ます。用紙が「透明」でなければ、強さが100%のとき、出力は素材の範囲と余白をすべて不透明に埋めます。強さが100%未満のときは、その分だけ入力映像と混ざるため、入力が透明な部分と余白は半透明になります。背景を透明のまま残すときは、用紙を「透明」にします。
|
||||
- 透明部分: 素材の透明な部分は、白い紙とみなして処理します。そのため、暗い素材を切り抜いた縁には、線が出ます。既定では、用紙が「透明」でなければ、強さが100%のとき、出力は素材の範囲と余白をすべて不透明に埋めます。強さが100%未満のときは、その分だけ入力映像と混ざるため、入力が透明な部分と余白は半透明になります。背景を透明のまま残すときは、「透明部分を保つ」をオンにします。オンにすると、用紙が「透明」でなければ、出力の不透明度は素材の不透明度と同じになります。素材の透明な部分と余白は、透明のまま出力されます。
|
||||
- 出力範囲: 余白が0のときの出力範囲は素材と同じです。余白を足すと、素材の上下左右へ余白の幅だけ広がります。余白の画素数は、指定した値に「素材の横幅 ÷ 1024」を掛けて整数に丸めた値で、出力の長辺が8192画素以下に収まる範囲です。
|
||||
- 更新通知: エフェクトを最初に生成したときに、YMM4の実行中に一度だけ新しい正式版を確認します。更新情報を取得できない場合は通知せず、そのまま動作します。プレリリースは通知の対象に含めません。
|
||||
- 不具合の自動送信: 想定していない例外が起きたときは、その内容を開発者へ自動で送信します。内容は「不具合の報告」に書いています。
|
||||
@@ -246,17 +249,20 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を白黒の漫画の原
|
||||
|
||||
## 不具合の報告
|
||||
|
||||
本プラグインは、想定していない例外が起きたときに、その内容を開発者へ自動で送信します。同意は求めず、常に送信します。
|
||||
本プラグインは、想定していない例外が起きたときに、その内容を開発者へ自動で送信します。同意は求めません。止める設定もありません。
|
||||
|
||||
送信する数には上限があります。YMM4の1回の起動で送る報告は、YMM4-Telemetryで報告する別のプラグインと合わせて20件までです。例外の型と発生位置が同じ報告は3件までです。上限を超えた報告と、送信先から待つよう求められている間に起きた報告は、送信も退避もしません。
|
||||
|
||||
送信する情報は次のとおりです。
|
||||
|
||||
| 種類 | 内容 |
|
||||
|---|---|
|
||||
| 例外 | 型の完全名、メッセージ、スタックトレース |
|
||||
| 発生位置 | モジュール名、関数名、ファイル名、行番号 |
|
||||
| 発生位置 | モジュール名、関数名、ファイル名、行番号、プラグイン自身のコードかどうか |
|
||||
| プラグイン | アセンブリ名、バージョン |
|
||||
| 実行環境 | OSの名前とバージョン、.NETのバージョン、CPUのアーキテクチャ、論理プロセッサ数 |
|
||||
| 識別子 | YMM4の起動ごとに決まるセッション識別子、報告ごとの識別子 |
|
||||
| 時刻 | 報告を作った時刻(UTC) |
|
||||
|
||||
メッセージとファイル名は、送信の前に置き換えを通します。置き換えるのは、Windowsのユーザー名、ユーザーフォルダー、AppDataのパス、マシン名、ドメイン名、メールアドレス、IPv4アドレスです。送信元のIPアドレスは受信側へ渡す手前で取り除いています。
|
||||
|
||||
|
||||
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 960 KiB |
新しいイシューから参照
ユーザーをブロックする