コミットを比較
44
コミット
main
..
pre-squash3
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
95997925c2
|
||
|
|
d5c8dc4a42
|
||
|
|
0a1a232d70
|
||
|
|
8e9d6bab92
|
||
|
|
573de65eac
|
||
|
|
a16d48430a
|
||
|
|
3a9adfc130
|
||
|
|
3acb29e37a
|
||
|
|
c48cfe1251
|
||
|
|
3da0c28fe6
|
||
|
|
c43fa215bc
|
||
|
|
32232b6435
|
||
|
|
4cc025c1ba
|
||
|
|
3866902139
|
||
|
|
52f384b482
|
||
|
|
70537dedc4
|
||
|
|
f8fb7217b5
|
||
|
|
ec20c30105
|
||
|
|
a3004b422e
|
||
|
|
2c433313f3
|
||
|
|
0944ec24b7
|
||
|
|
3b4cc42b7e
|
||
|
|
4253485354
|
||
|
|
ee74caca12
|
||
|
|
8a5ac1a07f
|
||
|
|
a791fc005a
|
||
|
|
2ee69da4eb
|
||
|
|
c14ce888f0
|
||
|
|
b65a1226bd
|
||
|
|
5231cedf84
|
||
|
|
282bb5716f
|
||
|
|
44ed81044c
|
||
|
|
f3fe50aa10
|
||
|
|
e53e6088a0
|
||
|
|
f26616806a
|
||
|
|
f78cb347b9
|
||
|
|
b83da702d6
|
||
|
|
847936e0d8
|
||
|
|
2cbcb407bb
|
||
|
|
5a8fab400b
|
||
|
|
028e099b77
|
||
|
|
48e80b920e
|
||
|
|
f1d08251a2
|
||
|
|
8d73023a78
|
検索条件に一致するファイルはありません
@@ -1,517 +0,0 @@
|
||||
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" = "VolumetricLight-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 = "VolumetricLight/VolumetricLight.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 VolumetricLight.Shader/VolumetricLight.Shader.vcxproj `
|
||||
/p:Configuration=Release `
|
||||
/p:Platform=Win32 `
|
||||
/nologo
|
||||
|
||||
- name: プロジェクトのビルド
|
||||
shell: pwsh
|
||||
run: |
|
||||
$proj = "VolumetricLight/VolumetricLight.csproj"
|
||||
dotnet build "$proj" `
|
||||
-c Release `
|
||||
-p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" `
|
||||
-p:SkipPluginDeploy=true
|
||||
|
||||
- name: パッケージの作成
|
||||
id: package
|
||||
shell: pwsh
|
||||
run: |
|
||||
$version = "${{ steps.version.outputs.TAG }}"
|
||||
$outDir = "VolumetricLight/bin/Release/net10.0-windows10.0.19041.0"
|
||||
$stageRoot = "stage/VolumetricLight"
|
||||
$pkgName = "VolumetricLight_$version.ymme"
|
||||
|
||||
New-Item -ItemType Directory -Path $stageRoot -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path "$stageRoot/LICENSE" -Force | Out-Null
|
||||
|
||||
$dll = "$outDir/VolumetricLight.dll"
|
||||
if (-not (Test-Path $dll)) {
|
||||
Write-Error "ビルド結果に VolumetricLight.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)"
|
||||
}
|
||||
}
|
||||
|
||||
+4
-12
@@ -47,9 +47,8 @@ YukkuriMovieMaker4上で動作する、素材の明るい部分を光源とみ
|
||||
- 影: 前景のアイテムに「体積光の遮光」を付け、「体積光」の
|
||||
「遮光の番号」と同じ番号を選ぶと、光の筋に影を落とせます。
|
||||
影を落とすアイテムは、「体積光」を付けたアイテムより上のレイヤーに
|
||||
置いてください。番号は1から8までで、同じシーンの同じ番号に付けられる
|
||||
のは4つまでです。別のシーンのアイテムには、番号が同じでも影を落とし
|
||||
ません。
|
||||
置いてください。番号は1から8までで、同じ番号に付けられるのは
|
||||
4つまでです。
|
||||
|
||||
- 影の範囲: 影を落とすアイテムが影を落とすのは、光源の画像と光の筋の間に
|
||||
あるときだけです。影の縁は影を落とすアイテムの画像の縁のままで、
|
||||
@@ -86,22 +85,15 @@ YukkuriMovieMaker4上で動作する、素材の明るい部分を光源とみ
|
||||
■ 不具合の報告
|
||||
--------------------------------------------------------------------------------
|
||||
本プラグインは、想定していない例外が起きたときに、その内容を開発者へ自動で
|
||||
送信します。同意は求めません。止める設定もありません。
|
||||
|
||||
送信する数には上限があります。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://git.routersys.com/manju-summoner/YukkuriMovieMaker.Generator.git
|
||||
url = https://github.com/manju-summoner/YukkuriMovieMaker.Generator.git
|
||||
[submodule "YMM4-GitHubUpdateNotifier"]
|
||||
path = YMM4-GitHubUpdateNotifier
|
||||
url = https://git.routersys.com/routersys/YMM4-GitHubUpdateNotifier.git
|
||||
url = https://github.com/routersys/YMM4-GitHubUpdateNotifier.git
|
||||
[submodule "YMM4-Telemetry"]
|
||||
path = YMM4-Telemetry
|
||||
url = https://git.routersys.com/routersys/YMM4-Telemetry.git
|
||||
url = https://github.com/routersys/YMM4-Telemetry.git
|
||||
@@ -11,7 +11,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材の明るい部分を光
|
||||
結果は設定と素材の画素とフレームの位置から決まり、乱数は使いません。同じ設定では、同じフレームは何度描いても同じ絵になります。
|
||||
向き、手前への角度、拡がり、長さ、強さ、しきい値、減衰、光源の大きさ、前方散乱、濃淡、大きさ、流れの速さ、流れの向きの13項目はアニメーションに対応しています。
|
||||
|
||||

|
||||

|
||||
|
||||
---
|
||||
|
||||
@@ -97,10 +97,6 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材の明るい部分を光
|
||||
|
||||
「色」は光に掛ける色です。白では素材の画素の色のままになります。
|
||||
|
||||
次の画像は、ステンドグラスの窓の写真に適用した例です。「向き」は-60°、「手前への角度」は45°、「強さ」は700%、「しきい値」は30%で、ほかの項目は既定値です。上が入力、下が出力で、しきい値を超える明るいガラスの部分だけが光源になり、窓から右下へ光の筋が伸びます。元の写真は、Wikimedia CommonsにCC0で公開されているWmpearl氏の「[Stained glass window, Hammerfest Church](https://commons.wikimedia.org/wiki/File:Stained_glass_window,_Hammerfest_Church.JPG)」です。
|
||||
|
||||

|
||||
|
||||
### 2. 光の向きと広がり
|
||||
|
||||
「向き」は、光が進む向きを、画像の面に沿った角度で決めます。0°が右、90°が上、-90°が下です。
|
||||
@@ -151,13 +147,9 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材の明るい部分を光
|
||||
|
||||
影を落とすアイテムは位置と回転と拡大率を持つ平らな画像として扱い、画像の不透明な部分が光を遮ります。光源の画像の各点から出た光の線が、影を落とすアイテムの不透明な部分を通ると、その線の先の光の筋が弱まって影になります。影を落とすアイテムが影を落とすのは、光源の画像と光の筋の間にあるときだけです。
|
||||
|
||||
次の画像は、窓の写真の手前にキャラクターを置いた例です。窓の写真には前の画像と同じ設定の「体積光」を付け、「遮光の番号」を1にしました。キャラクターには「体積光の遮光」を付け、「番号」を上は2、下は1にしました。上は番号が違うので影が落ちません。下は番号が同じなので、キャラクターが遮った分だけ、右と下の光の筋が弱まります。
|
||||
|
||||

|
||||
|
||||
「遮る強さ」は、影を落とすアイテムの不透明な部分が、光をどれだけ遮るかです。アイテムの不透明度も掛かります。100%で光を通さず、0%で遮りません。
|
||||
|
||||
同じシーンの同じ番号に付けられる「体積光の遮光」は4つまでです。5つ目以降は影を落としません。別のシーンのアイテムには、番号が同じでも影を落としません。
|
||||
同じ番号に付けられる「体積光の遮光」は4つまでです。5つ目以降は影を落としません。
|
||||
|
||||
---
|
||||
|
||||
@@ -215,7 +207,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材の明るい部分を光
|
||||
|
||||
| パラメータ名 | 型 | デフォルト | スライダー表示範囲 | アニメーション | 説明 |
|
||||
|---|---|---|---|---|---|
|
||||
| 番号 | 整数 | 1 | 1〜8 | 非対応 | 同じ番号を選んだ「体積光」の光の筋を、このアイテムが遮ります。シーンと番号ごとに遮れるアイテムは4つまでです。 |
|
||||
| 番号 | 整数 | 1 | 1〜8 | 非対応 | 同じ番号を選んだ「体積光」の光の筋を、このアイテムが遮ります。番号ごとに遮れるアイテムは4つまでです。 |
|
||||
| 遮る強さ | 数値 | 100% | 0〜100% | 対応 | アイテムの不透明な部分が光をどれだけ遮るかです。アイテムの不透明度も掛かります。100%で光を通さず、0%で遮りません。 |
|
||||
|
||||
---
|
||||
@@ -228,7 +220,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材の明るい部分を光
|
||||
- 素材の幅か高さが4096pxを超えるときは、エフェクトを適用せず入力映像を表示します。
|
||||
- 光の筋は画面に入る範囲だけを計算します。
|
||||
- 光の筋はこのエフェクトを付けたアイテムのレイヤーに1枚の映像として描きます。奥行きの違うほかのアイテムとの前後は、レイヤーの順で決まります。
|
||||
- 「体積光の遮光」は、シーンと番号ごとに4つまで付けられます。番号は1から8までです。
|
||||
- 「体積光の遮光」は番号ごとに4つまで付けられます。番号は1から8までです。
|
||||
- 影の縁は影を落とすアイテムの画像の縁のままで、ぼかしません。
|
||||
- 「体積光」と「体積光の遮光」を同じアイテムに付けても、そのアイテム自身の影は落ちません。
|
||||
- 「体積光の遮光」はそのエフェクトを付けた位置までの設定で決まる位置と画像を使います。後ろに付けたエフェクトが位置や画像を変えても、影には反映されません。アイテムのエフェクトの最後に付けてください。
|
||||
@@ -249,20 +241,17 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材の明るい部分を光
|
||||
|
||||
## 不具合の報告
|
||||
|
||||
本プラグインは、想定していない例外が起きたときに、その内容を開発者へ自動で送信します。同意は求めません。止める設定もありません。
|
||||
|
||||
送信する数には上限があります。YMM4の1回の起動で送る報告は、YMM4-Telemetryで報告する別のプラグインと合わせて20件までです。例外の型と発生位置が同じ報告は3件までです。上限を超えた報告と、送信先から待つよう求められている間に起きた報告は、送信も退避もしません。
|
||||
本プラグインは、想定していない例外が起きたときに、その内容を開発者へ自動で送信します。同意は求めず、常に送信します。
|
||||
|
||||
送信する情報は次のとおりです。
|
||||
|
||||
| 種類 | 内容 |
|
||||
|---|---|
|
||||
| 例外 | 型の完全名、メッセージ、スタックトレース |
|
||||
| 発生位置 | モジュール名、関数名、ファイル名、行番号、プラグイン自身のコードかどうか |
|
||||
| 発生位置 | モジュール名、関数名、ファイル名、行番号 |
|
||||
| プラグイン | アセンブリ名、バージョン |
|
||||
| 実行環境 | OSの名前とバージョン、.NETのバージョン、CPUのアーキテクチャ、論理プロセッサ数 |
|
||||
| 識別子 | YMM4の起動ごとに決まるセッション識別子、報告ごとの識別子 |
|
||||
| 時刻 | 報告を作った時刻(UTC) |
|
||||
|
||||
メッセージとファイル名は、送信の前に置き換えを通します。置き換えるのは、Windowsのユーザー名、ユーザーフォルダー、AppDataのパス、マシン名、ドメイン名、メールアドレス、IPv4アドレスです。送信元のIPアドレスは受信側へ渡す手前で取り除いています。
|
||||
|
||||
|
||||
@@ -95,8 +95,6 @@ internal static class HarnessCases
|
||||
yield return ("shadow-figure-half-strength", Shadowed(effect => effect.Direction.Values[0].Value = -60), [0], HarnessPose.Flat, [Figure(new Vector3(-120f, 110f, 240f), configure: effect => effect.Strength.Values[0].Value = 50)]);
|
||||
yield return ("shadow-figure-strength-animated-frames", Shadowed(effect => effect.Direction.Values[0].Value = -60), [0, 150, 299], HarnessPose.Flat, [Figure(new Vector3(-120f, 110f, 240f), configure: effect => effect.Strength.CopyFrom(Linear(100d, 10d)))]);
|
||||
yield return ("shadow-figure-rotated-light", Shadowed(), [0], RotatedY, [Figure(new Vector3(0f, 120f, 200f))]);
|
||||
yield return ("shadow-figure-other-scene", Shadowed(effect => { effect.Direction.Values[0].Value = -60; effect.Elevation.Values[0].Value = 45; }), [0], HarnessPose.Flat, [Figure(new Vector3(40f, 120f, 220f)) with { Scene = new Guid("5b0a8d3e-2c1f-4e7a-9a52-7d4f1c6b8e90") }]);
|
||||
yield return ("shadow-figure-other-frame", Shadowed(effect => { effect.Direction.Values[0].Value = -60; effect.Elevation.Values[0].Value = 45; }), [0], HarnessPose.Flat, [Figure(new Vector3(-220f, 130f, 160f)) with { FrameOffset = 7 }]);
|
||||
yield return ("shadow-figure-other-number", Shadowed(effect => { effect.Direction.Values[0].Value = -60; effect.Elevation.Values[0].Value = 45; }), [0], HarnessPose.Flat, [Figure(new Vector3(-120f, 110f, 240f), configure: effect => effect.Channel = 2)]);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using YukkuriMovieMaker.Player.Video;
|
||||
|
||||
namespace VolumetricLight.Harness;
|
||||
|
||||
internal sealed record HarnessOccluder(VolumetricLightOccluderEffect Effect, HarnessPose Pose, HarnessImage Image, Guid Scene = default, int FrameOffset = 0);
|
||||
internal sealed record HarnessOccluder(VolumetricLightOccluderEffect Effect, HarnessPose Pose, HarnessImage Image);
|
||||
|
||||
internal sealed class HarnessOccluderScene : IDisposable
|
||||
{
|
||||
@@ -57,11 +57,11 @@ internal sealed class HarnessOccluderScene : IDisposable
|
||||
|
||||
public IEnumerable<ID2D1Image> Layers => entries.Select(entry => entry.Display.Output);
|
||||
|
||||
public void Update(Func<int, HarnessPose?, Guid, EffectDescription> describe, int frame)
|
||||
public void Update(Func<int, HarnessPose?, EffectDescription> describe, int frame)
|
||||
{
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var description = describe(frame + entry.Occluder.FrameOffset, entry.Occluder.Pose, entry.Occluder.Scene);
|
||||
var description = describe(frame, entry.Occluder.Pose);
|
||||
entry.Blocker.Update(description);
|
||||
entry.Display.Update(description);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ internal sealed class HarnessRenderer : IDisposable
|
||||
sync.Unmap();
|
||||
}
|
||||
|
||||
internal EffectDescription Describe(int frame, HarnessPose? pose, Guid scene = default)
|
||||
internal EffectDescription Describe(int frame, HarnessPose? pose)
|
||||
{
|
||||
var timeline = new TimelineSourceDescription(
|
||||
new System.Drawing.Size(CanvasWidth, CanvasHeight),
|
||||
@@ -236,7 +236,7 @@ internal sealed class HarnessRenderer : IDisposable
|
||||
new YukkuriMovieMaker.Player.Video.FrameTime(Length, Fps),
|
||||
Fps,
|
||||
TimelineSourceUsage.Playing,
|
||||
scene,
|
||||
Guid.Empty,
|
||||
[]);
|
||||
var item = new TimelineItemSourceDescription(timeline, frame, Length, 0);
|
||||
var placement = pose ?? HarnessPose.Flat;
|
||||
|
||||
@@ -340,20 +340,6 @@
|
||||
],
|
||||
"hash": "6885C2736451491A0EC78156B9813B642238350992D3F33BF52435E1ADC9DE83"
|
||||
},
|
||||
{
|
||||
"name": "shadow-figure-other-scene",
|
||||
"frames": [
|
||||
0
|
||||
],
|
||||
"hash": "44996CD0E824BAE692A7BFF8063E42BFEA76A8E1997B93A86584B92956835454"
|
||||
},
|
||||
{
|
||||
"name": "shadow-figure-other-frame",
|
||||
"frames": [
|
||||
0
|
||||
],
|
||||
"hash": "91CC1D8F8948BE95E71C93CFE47816849FDF2A03D1DA5E7752059F401CB0774F"
|
||||
},
|
||||
{
|
||||
"name": "shadow-figure-other-number",
|
||||
"frames": [
|
||||
|
||||
@@ -19,7 +19,7 @@ internal static class EffectDescriptions
|
||||
|
||||
public static EffectDescription At(int frame, int length, DrawDescription draw) => At(frame, length, draw, ScreenSize);
|
||||
|
||||
public static EffectDescription At(int frame, int length, DrawDescription draw, Size screenSize, Guid scene = default)
|
||||
public static EffectDescription At(int frame, int length, DrawDescription draw, Size screenSize)
|
||||
{
|
||||
var timeline = new TimelineSourceDescription(
|
||||
screenSize,
|
||||
@@ -27,7 +27,7 @@ internal static class EffectDescriptions
|
||||
new FrameTime(length, Fps),
|
||||
Fps,
|
||||
TimelineSourceUsage.Playing,
|
||||
scene,
|
||||
Guid.Empty,
|
||||
[]);
|
||||
var item = new TimelineItemSourceDescription(timeline, frame, length, 0);
|
||||
return new EffectDescription(item, draw, 0, 1, 0, 1);
|
||||
|
||||
@@ -28,54 +28,14 @@ public sealed class OccluderRegistryTests
|
||||
using var first = devices.CreateContext();
|
||||
using var second = devices.CreateContext();
|
||||
|
||||
using var a = OccluderRegistry.Acquire(first, Guid.Empty, 1);
|
||||
using var b = OccluderRegistry.Acquire(second, Guid.Empty, 1);
|
||||
using var c = OccluderRegistry.Acquire(first, Guid.Empty, 2);
|
||||
using var a = OccluderRegistry.Acquire(first, 1);
|
||||
using var b = OccluderRegistry.Acquire(second, 1);
|
||||
using var c = OccluderRegistry.Acquire(first, 2);
|
||||
|
||||
Assert.Same(a.Group, b.Group);
|
||||
Assert.NotSame(a.Group, c.Group);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheSameNumberInAnotherSceneHasItsOwnGroup()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
var home = Guid.NewGuid();
|
||||
|
||||
using var a = OccluderRegistry.Acquire(context, home, 1);
|
||||
using var b = OccluderRegistry.Acquire(context, home, 1);
|
||||
using var c = OccluderRegistry.Acquire(context, Guid.NewGuid(), 1);
|
||||
|
||||
Assert.Same(a.Group, b.Group);
|
||||
Assert.NotSame(a.Group, c.Group);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ASnapshotKeepsOnlyTheOccludersPublishedForItsOwnFrame()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var now = lease.Group.Claim()!;
|
||||
using var later = lease.Group.Claim()!;
|
||||
now.Publish(source.Bitmap, Sample(0.25f), 4);
|
||||
later.Publish(source.Bitmap, Sample(0.75f), 9);
|
||||
var snapshot = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
|
||||
lease.Group.Snapshot(snapshot, 4);
|
||||
Assert.Equal(0.25f, snapshot[0].Strength);
|
||||
Assert.Equal(0f, snapshot[1].Strength);
|
||||
|
||||
lease.Group.Snapshot(snapshot, 9);
|
||||
Assert.Equal(0f, snapshot[0].Strength);
|
||||
Assert.Equal(0.75f, snapshot[1].Strength);
|
||||
|
||||
lease.Group.Snapshot(snapshot, 5);
|
||||
Assert.All(snapshot, occluder => Assert.Equal(0f, occluder.Strength));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DifferentDevicesNeverShareAGroup()
|
||||
{
|
||||
@@ -84,8 +44,8 @@ public sealed class OccluderRegistryTests
|
||||
using var first = firstDevices.CreateContext();
|
||||
using var second = secondDevices.CreateContext();
|
||||
|
||||
using var a = OccluderRegistry.Acquire(first, Guid.Empty, 1);
|
||||
using var b = OccluderRegistry.Acquire(second, Guid.Empty, 1);
|
||||
using var a = OccluderRegistry.Acquire(first, 1);
|
||||
using var b = OccluderRegistry.Acquire(second, 1);
|
||||
|
||||
Assert.NotSame(a.Group, b.Group);
|
||||
}
|
||||
@@ -95,8 +55,8 @@ public sealed class OccluderRegistryTests
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
var a = OccluderRegistry.Acquire(context, Guid.Empty, 3);
|
||||
var b = OccluderRegistry.Acquire(context, Guid.Empty, 3);
|
||||
var a = OccluderRegistry.Acquire(context, 3);
|
||||
var b = OccluderRegistry.Acquire(context, 3);
|
||||
var group = a.Group;
|
||||
var slot = group.Claim()!;
|
||||
|
||||
@@ -104,7 +64,7 @@ public sealed class OccluderRegistryTests
|
||||
a.Dispose();
|
||||
Assert.NotNull(group.Claim());
|
||||
b.Dispose();
|
||||
using var again = OccluderRegistry.Acquire(context, Guid.Empty, 3);
|
||||
using var again = OccluderRegistry.Acquire(context, 3);
|
||||
|
||||
Assert.NotSame(group, again.Group);
|
||||
Assert.Null(group.Claim());
|
||||
@@ -116,7 +76,7 @@ public sealed class OccluderRegistryTests
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
var slots = Enumerable.Range(0, VolumetricLightSettings.OccluderCapacity).Select(_ => lease.Group.Claim()).ToArray();
|
||||
|
||||
Assert.All(slots, Assert.NotNull);
|
||||
@@ -133,7 +93,7 @@ public sealed class OccluderRegistryTests
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
Assert.False(lease.Group.IsOccupied);
|
||||
|
||||
var first = lease.Group.Claim()!;
|
||||
@@ -151,18 +111,18 @@ public sealed class OccluderRegistryTests
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
using var first = lease.Group.Claim()!;
|
||||
var second = lease.Group.Claim()!;
|
||||
var snapshot = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
|
||||
first.Publish(source.Bitmap, Sample(0.25f), 0);
|
||||
second.Publish(source.Bitmap, Sample(0.75f), 0);
|
||||
lease.Group.Snapshot(snapshot, 0);
|
||||
first.Publish(source.Bitmap, Sample(0.25f));
|
||||
second.Publish(source.Bitmap, Sample(0.75f));
|
||||
lease.Group.Snapshot(snapshot);
|
||||
Assert.Equal([0.25f, 0.75f, 0f, 0f], snapshot.Select(occluder => occluder.Strength));
|
||||
|
||||
second.Dispose();
|
||||
lease.Group.Snapshot(snapshot, 0);
|
||||
lease.Group.Snapshot(snapshot);
|
||||
Assert.Equal([0.25f, 0f, 0f, 0f], snapshot.Select(occluder => occluder.Strength));
|
||||
}
|
||||
|
||||
@@ -172,13 +132,13 @@ public sealed class OccluderRegistryTests
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
var slot = lease.Group.Claim()!;
|
||||
slot.Dispose();
|
||||
var snapshot = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
|
||||
slot.Publish(source.Bitmap, Sample(), 0);
|
||||
lease.Group.Snapshot(snapshot, 0);
|
||||
slot.Publish(source.Bitmap, Sample());
|
||||
lease.Group.Snapshot(snapshot);
|
||||
|
||||
Assert.All(snapshot, occluder => Assert.Equal(0f, occluder.Strength));
|
||||
}
|
||||
@@ -189,12 +149,12 @@ public sealed class OccluderRegistryTests
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
var slot = lease.Group.Claim()!;
|
||||
var relay = lease.Group.GetOutput(0);
|
||||
|
||||
var empty = context.DeviceContext.GetImageLocalBounds(relay);
|
||||
slot.Publish(source.Bitmap, Sample(), 0);
|
||||
slot.Publish(source.Bitmap, Sample());
|
||||
var shown = Render(context, relay);
|
||||
slot.Dispose();
|
||||
var gone = context.DeviceContext.GetImageLocalBounds(relay);
|
||||
@@ -212,10 +172,10 @@ public sealed class OccluderRegistryTests
|
||||
using var reader = devices.CreateContext();
|
||||
using var writer = devices.CreateContext();
|
||||
using var source = new SourceImage(writer, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(reader, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(reader, 1);
|
||||
using var slot = lease.Group.Claim()!;
|
||||
|
||||
slot.Publish(source.Bitmap, Sample(), 0);
|
||||
slot.Publish(source.Bitmap, Sample());
|
||||
var shown = Render(reader, lease.Group.GetOutput(0));
|
||||
|
||||
Assert.Equal(source[3, 2], shown[3, 2]);
|
||||
@@ -228,11 +188,11 @@ public sealed class OccluderRegistryTests
|
||||
using var reader = devices.CreateContext();
|
||||
var creator = devices.CreateContext();
|
||||
using var source = new SourceImage(reader, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(creator, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(creator, 1);
|
||||
using var slot = lease.Group.Claim()!;
|
||||
creator.Dispose();
|
||||
|
||||
slot.Publish(source.Bitmap, Sample(), 0);
|
||||
slot.Publish(source.Bitmap, Sample());
|
||||
var shown = Render(reader, lease.Group.GetOutput(0));
|
||||
|
||||
Assert.Equal(source[5, 1], shown[5, 1]);
|
||||
@@ -244,7 +204,7 @@ public sealed class OccluderRegistryTests
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
var claimed = 0;
|
||||
|
||||
Parallel.For(0, 64, index =>
|
||||
@@ -254,10 +214,10 @@ public sealed class OccluderRegistryTests
|
||||
return;
|
||||
|
||||
Interlocked.Increment(ref claimed);
|
||||
slot.Publish(source.Bitmap, Sample((index + 1) / 100f), 0);
|
||||
slot.Publish(source.Bitmap, Sample((index + 1) / 100f));
|
||||
});
|
||||
var snapshot = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
lease.Group.Snapshot(snapshot, 0);
|
||||
lease.Group.Snapshot(snapshot);
|
||||
|
||||
Assert.Equal(VolumetricLightSettings.OccluderCapacity, claimed);
|
||||
Assert.All(snapshot, occluder => Assert.True(occluder.Strength > 0f));
|
||||
@@ -269,7 +229,7 @@ public sealed class OccluderRegistryTests
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
using var slot = lease.Group.Claim()!;
|
||||
using var blur = new Vortice.Direct2D1.Effects.GaussianBlur(context.DeviceContext);
|
||||
blur.SetInput(0, source.Bitmap, true);
|
||||
@@ -281,12 +241,12 @@ public sealed class OccluderRegistryTests
|
||||
var freed = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
|
||||
lease.Group.AddConsumer(blur.NativePointer);
|
||||
slot.Publish(image, Sample(), 0);
|
||||
lease.Group.Snapshot(blocked, 0);
|
||||
slot.Publish(image, Sample());
|
||||
lease.Group.Snapshot(blocked);
|
||||
var kept = context.DeviceContext.GetImageLocalBounds(lease.Group.GetOutput(0));
|
||||
lease.Group.RemoveConsumer(blur.NativePointer);
|
||||
slot.Publish(image, Sample(), 0);
|
||||
lease.Group.Snapshot(freed, 0);
|
||||
slot.Publish(image, Sample());
|
||||
lease.Group.Snapshot(freed);
|
||||
var relayed = context.DeviceContext.GetImageLocalBounds(lease.Group.GetOutput(0));
|
||||
|
||||
Assert.Equal(0f, blocked[0].Strength);
|
||||
@@ -301,18 +261,18 @@ public sealed class OccluderRegistryTests
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var source = new SourceImage(context, Width, Height, Marker);
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
using var slot = lease.Group.Claim()!;
|
||||
using var blur = new Vortice.Direct2D1.Effects.GaussianBlur(context.DeviceContext);
|
||||
blur.SetInput(0, source.Bitmap, true);
|
||||
using var image = blur.Output;
|
||||
var snapshot = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
slot.Publish(image, Sample(), 0);
|
||||
lease.Group.Snapshot(snapshot, 0);
|
||||
slot.Publish(image, Sample());
|
||||
lease.Group.Snapshot(snapshot);
|
||||
Assert.Equal(1f, snapshot[0].Strength);
|
||||
|
||||
lease.Group.AddConsumer(blur.NativePointer);
|
||||
lease.Group.Snapshot(snapshot, 0);
|
||||
lease.Group.Snapshot(snapshot);
|
||||
|
||||
Assert.Equal(0f, snapshot[0].Strength);
|
||||
Assert.Equal((0f, 0f, 0f, 0f), (context.DeviceContext.GetImageLocalBounds(lease.Group.GetOutput(0)) is var bounds ? (bounds.Left, bounds.Top, bounds.Right, bounds.Bottom) : default));
|
||||
@@ -323,8 +283,8 @@ public sealed class OccluderRegistryTests
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
using var lease = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
var link = new OccluderLink { Group = lease.Group, Frame = 0 };
|
||||
using var lease = OccluderRegistry.Acquire(context, 1);
|
||||
var link = new OccluderLink { Group = lease.Group };
|
||||
|
||||
var id = OccluderLinks.Register(link);
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ public sealed class ShaftCustomEffectTests(ITestOutputHelper output)
|
||||
readonly OccluderLease lease;
|
||||
readonly OccluderSlot[] slots;
|
||||
readonly ID2D1Bitmap1[] bitmaps;
|
||||
readonly OccluderLink link = new() { Frame = 0 };
|
||||
readonly OccluderLink link = new();
|
||||
|
||||
public OccluderRig(IGraphicsDevicesAndContext devices, IReadOnlyList<(DrawDescription Draw, GoboPyramid Image, float Strength)> occluders)
|
||||
{
|
||||
lease = OccluderRegistry.Acquire(devices, Guid.Empty, 1);
|
||||
lease = OccluderRegistry.Acquire(devices, 1);
|
||||
link.Group = lease.Group;
|
||||
LinkId = OccluderLinks.Register(link);
|
||||
slots = new OccluderSlot[occluders.Count];
|
||||
@@ -68,7 +68,7 @@ public sealed class ShaftCustomEffectTests(ITestOutputHelper output)
|
||||
Assert.True(ViewTransform.TryCreate(draw, out var view));
|
||||
slots[index] = lease.Group.Claim()!;
|
||||
bitmaps[index] = image.CreateBitmaps(devices)[0];
|
||||
slots[index].Publish(bitmaps[index], new Occluder(view, GoboMapping.Create(draw.Zoom, draw.Invert, draw.CenterPoint), strength), 0);
|
||||
slots[index].Publish(bitmaps[index], new Occluder(view, GoboMapping.Create(draw.Zoom, draw.Invert, draw.CenterPoint), strength));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,11 +49,9 @@ public sealed class VolumetricLightOccluderEffectProcessorTests
|
||||
{
|
||||
readonly IGraphicsDevicesAndContext context;
|
||||
readonly SourceImage source;
|
||||
readonly Guid scene;
|
||||
|
||||
public Item(GraphicsDevices devices, YukkuriMovieMaker.Plugin.Effects.VideoEffectBase effect, Func<int, int, Bgra> pixels, Guid scene = default)
|
||||
public Item(GraphicsDevices devices, YukkuriMovieMaker.Plugin.Effects.VideoEffectBase effect, Func<int, int, Bgra> pixels)
|
||||
{
|
||||
this.scene = scene;
|
||||
context = devices.CreateContext();
|
||||
source = new SourceImage(context, Width, Height, pixels);
|
||||
Processor = effect.CreateVideoEffect(context);
|
||||
@@ -64,12 +62,12 @@ public sealed class VolumetricLightOccluderEffectProcessorTests
|
||||
|
||||
public SourceImage Source => source;
|
||||
|
||||
public DrawDescription Update(int frame, DrawDescription draw, Guid? moveTo = null)
|
||||
=> Processor.Update(EffectDescriptions.At(frame, Length, draw, Canvas, moveTo ?? scene));
|
||||
public DrawDescription Update(int frame, DrawDescription draw)
|
||||
=> Processor.Update(EffectDescriptions.At(frame, Length, draw, Canvas));
|
||||
|
||||
public Rendering Render(int frame, DrawDescription draw, Guid? moveTo = null)
|
||||
public Rendering Render(int frame, DrawDescription draw)
|
||||
{
|
||||
Update(frame, draw, moveTo);
|
||||
Update(frame, draw);
|
||||
return Rendering.Capture(context, Processor.Output);
|
||||
}
|
||||
|
||||
@@ -94,11 +92,11 @@ public sealed class VolumetricLightOccluderEffectProcessorTests
|
||||
.Where(point => point.X < 0 || point.Y < 0 || point.X >= Width || point.Y >= Height)
|
||||
.Sum(point => (long)rendering[point.X, point.Y].Red + rendering[point.X, point.Y].Green + rendering[point.X, point.Y].Blue);
|
||||
|
||||
static Occluder[] Snapshot(IGraphicsDevicesAndContext context, int channel, int frame = 0, Guid scene = default)
|
||||
static Occluder[] Snapshot(IGraphicsDevicesAndContext context, int channel)
|
||||
{
|
||||
using var lease = OccluderRegistry.Acquire(context, scene, channel);
|
||||
using var lease = OccluderRegistry.Acquire(context, channel);
|
||||
var snapshot = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
lease.Group.Snapshot(snapshot, frame);
|
||||
lease.Group.Snapshot(snapshot);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
@@ -160,8 +158,8 @@ public sealed class VolumetricLightOccluderEffectProcessorTests
|
||||
effect.Channel = 3;
|
||||
item.Update(1, InFront);
|
||||
|
||||
Assert.All(Snapshot(context, 1, 1), occluder => Assert.Equal(0f, occluder.Strength));
|
||||
Assert.True(Snapshot(context, 3, 1)[0].Strength > 0f);
|
||||
Assert.All(Snapshot(context, 1), occluder => Assert.Equal(0f, occluder.Strength));
|
||||
Assert.True(Snapshot(context, 3)[0].Strength > 0f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -187,13 +185,13 @@ public sealed class VolumetricLightOccluderEffectProcessorTests
|
||||
var light = Light(1).CreateVideoEffect(context);
|
||||
light.SetInput(source.Bitmap);
|
||||
light.Update(EffectDescriptions.At(0, Length, EffectDescriptions.Flat, Canvas));
|
||||
var held = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
var held = OccluderRegistry.Acquire(context, 1);
|
||||
var group = held.Group;
|
||||
|
||||
light.Dispose();
|
||||
held.Dispose();
|
||||
|
||||
using var again = OccluderRegistry.Acquire(context, Guid.Empty, 1);
|
||||
using var again = OccluderRegistry.Acquire(context, 1);
|
||||
Assert.NotSame(group, again.Group);
|
||||
}
|
||||
|
||||
@@ -211,9 +209,8 @@ public sealed class VolumetricLightOccluderEffectProcessorTests
|
||||
|
||||
Assert.All(snapshot, occluder => Assert.True(occluder.Strength > 0f));
|
||||
items[0].Dispose();
|
||||
foreach (var item in items.Skip(1))
|
||||
item.Update(1, InFront);
|
||||
Assert.All(Snapshot(context, 1, 1), occluder => Assert.True(occluder.Strength > 0f));
|
||||
items[^1].Update(1, InFront);
|
||||
Assert.All(Snapshot(context, 1), occluder => Assert.True(occluder.Strength > 0f));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -278,96 +275,6 @@ public sealed class VolumetricLightOccluderEffectProcessorTests
|
||||
Assert.True(darker > Width * Height / 4, $"{darker}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnOccluderPublishedForAnotherFrameCastsNoShadowUntilThatFrame()
|
||||
{
|
||||
using var devices = new GraphicsDevices();
|
||||
using var light = new Item(devices, Light(1), Glass);
|
||||
using var occluder = new Item(devices, Blocker(), Bars);
|
||||
var clearNow = light.Render(0, EffectDescriptions.Flat);
|
||||
var clearLater = light.Render(15, EffectDescriptions.Flat);
|
||||
|
||||
occluder.Update(15, InFront);
|
||||
|
||||
Assert.True(clearNow.SamePixelsAs(light.Render(0, EffectDescriptions.Flat)));
|
||||
Assert.True(OutsideLight(light.Render(15, EffectDescriptions.Flat)) < OutsideLight(clearLater) * 0.9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnOccluderInAnotherSceneNeverReachesTheLight()
|
||||
{
|
||||
var home = Guid.NewGuid();
|
||||
var away = Guid.NewGuid();
|
||||
using var devices = new GraphicsDevices();
|
||||
using var light = new Item(devices, Light(1), Glass, home);
|
||||
using var foreign = new Item(devices, Blocker(), Bars, away);
|
||||
var clear = light.Render(0, EffectDescriptions.Flat);
|
||||
|
||||
foreign.Update(0, InFront);
|
||||
Assert.True(clear.SamePixelsAs(light.Render(0, EffectDescriptions.Flat)));
|
||||
|
||||
using var native = new Item(devices, Blocker(), Bars, home);
|
||||
native.Update(0, InFront);
|
||||
Assert.True(OutsideLight(light.Render(0, EffectDescriptions.Flat)) < OutsideLight(clear) * 0.9);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ALightThatMovesToAnotherSceneFollowsTheOccludersThereAndLeavesTheOldOnes()
|
||||
{
|
||||
var home = Guid.NewGuid();
|
||||
var away = Guid.NewGuid();
|
||||
using var devices = new GraphicsDevices();
|
||||
using var light = new Item(devices, Light(1), Glass, home);
|
||||
using var occluder = new Item(devices, Blocker(), Bars, away);
|
||||
var clear = light.Render(0, EffectDescriptions.Flat);
|
||||
occluder.Update(0, InFront);
|
||||
|
||||
Assert.True(OutsideLight(light.Render(0, EffectDescriptions.Flat, away)) < OutsideLight(clear) * 0.9);
|
||||
Assert.True(clear.SamePixelsAs(light.Render(0, EffectDescriptions.Flat, home)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnOccluderThatMovesToAnotherSceneLeavesTheLightsOfTheOldOne()
|
||||
{
|
||||
var home = Guid.NewGuid();
|
||||
var away = Guid.NewGuid();
|
||||
using var devices = new GraphicsDevices();
|
||||
using var light = new Item(devices, Light(1), Glass, home);
|
||||
using var occluder = new Item(devices, Blocker(), Bars, home);
|
||||
var clear = light.Render(0, EffectDescriptions.Flat);
|
||||
occluder.Update(0, InFront);
|
||||
Assert.True(OutsideLight(light.Render(0, EffectDescriptions.Flat)) < OutsideLight(clear) * 0.9);
|
||||
|
||||
occluder.Update(0, InFront, away);
|
||||
|
||||
Assert.True(clear.SamePixelsAs(light.Render(0, EffectDescriptions.Flat)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EachSceneKeepsItsOwnFourOccluderSlotsOnTheSameNumber()
|
||||
{
|
||||
var home = Guid.NewGuid();
|
||||
var away = Guid.NewGuid();
|
||||
using var devices = new GraphicsDevices();
|
||||
using var context = devices.CreateContext();
|
||||
var items = Enumerable.Range(0, VolumetricLightSettings.OccluderCapacity + 1)
|
||||
.Select(index => new Item(devices, Blocker(), Bars, index < VolumetricLightSettings.OccluderCapacity ? home : away))
|
||||
.ToArray();
|
||||
try
|
||||
{
|
||||
foreach (var item in items)
|
||||
item.Update(0, InFront);
|
||||
|
||||
Assert.All(Snapshot(context, 1, 0, home), occluder => Assert.True(occluder.Strength > 0f));
|
||||
Assert.True(Snapshot(context, 1, 0, away)[0].Strength > 0f);
|
||||
}
|
||||
finally
|
||||
{
|
||||
foreach (var item in items)
|
||||
item.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ALightIgnoresOccludersOfAnotherNumberAndWhenItsOwnNumberIsZero()
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@ internal sealed class OccluderGroup : IDisposable
|
||||
private readonly ID2D1Image[] _outputs = new ID2D1Image[VolumetricLightSettings.OccluderCapacity];
|
||||
private readonly ID2D1Image?[] _published = new ID2D1Image?[VolumetricLightSettings.OccluderCapacity];
|
||||
private readonly Occluder[] _requested = new Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
private readonly int[] _frames = new int[VolumetricLightSettings.OccluderCapacity];
|
||||
private readonly bool[] _blocked = new bool[VolumetricLightSettings.OccluderCapacity];
|
||||
private readonly int[] _checked = new int[VolumetricLightSettings.OccluderCapacity];
|
||||
private readonly HashSet<nint> _consumers = [];
|
||||
@@ -79,12 +78,12 @@ internal sealed class OccluderGroup : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public void Snapshot(Span<Occluder> destination, int frame)
|
||||
public void Snapshot(Span<Occluder> destination)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
for (var index = 0; index < destination.Length; index++)
|
||||
destination[index] = !_disposed && index < _occluders.Length && _frames[index] == frame ? _occluders[index] : default;
|
||||
destination[index] = !_disposed && index < _occluders.Length ? _occluders[index] : default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +124,7 @@ internal sealed class OccluderGroup : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
internal void Publish(int index, ID2D1Image image, in Occluder occluder, int frame)
|
||||
internal void Publish(int index, ID2D1Image image, in Occluder occluder)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
@@ -133,7 +132,6 @@ internal sealed class OccluderGroup : IDisposable
|
||||
return;
|
||||
|
||||
_requested[index] = occluder;
|
||||
_frames[index] = frame;
|
||||
if (!ReferenceEquals(_published[index], image) || _checked[index] != _version)
|
||||
{
|
||||
_published[index] = image;
|
||||
@@ -219,7 +217,7 @@ internal sealed class OccluderSlot(OccluderGroup group, int index) : IDisposable
|
||||
{
|
||||
private int _retired;
|
||||
|
||||
public void Publish(ID2D1Image image, in Occluder occluder, int frame) => group.Publish(index, image, occluder, frame);
|
||||
public void Publish(ID2D1Image image, in Occluder occluder) => group.Publish(index, image, occluder);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -231,13 +229,13 @@ internal sealed class OccluderSlot(OccluderGroup group, int index) : IDisposable
|
||||
internal sealed class OccluderLease : IDisposable
|
||||
{
|
||||
private readonly OccluderBoard _board;
|
||||
private readonly (Guid Scene, int Channel) _key;
|
||||
private readonly int _channel;
|
||||
private int _released;
|
||||
|
||||
internal OccluderLease(OccluderBoard board, (Guid Scene, int Channel) key, OccluderGroup group)
|
||||
internal OccluderLease(OccluderBoard board, int channel, OccluderGroup group)
|
||||
{
|
||||
_board = board;
|
||||
_key = key;
|
||||
_channel = channel;
|
||||
Group = group;
|
||||
}
|
||||
|
||||
@@ -246,7 +244,7 @@ internal sealed class OccluderLease : IDisposable
|
||||
public void Dispose()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _released, 1) == 0)
|
||||
_board.Release(_key);
|
||||
_board.Release(_channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,32 +258,31 @@ internal sealed class OccluderBoard
|
||||
}
|
||||
|
||||
private readonly object _gate = new();
|
||||
private readonly Dictionary<(Guid Scene, int Channel), Entry> _entries = [];
|
||||
private readonly Dictionary<int, Entry> _entries = [];
|
||||
|
||||
public OccluderLease Acquire(IGraphicsDevicesAndContext devices, Guid scene, int channel)
|
||||
public OccluderLease Acquire(IGraphicsDevicesAndContext devices, int channel)
|
||||
{
|
||||
var key = (scene, channel);
|
||||
lock (_gate)
|
||||
{
|
||||
if (!_entries.TryGetValue(key, out var entry))
|
||||
if (!_entries.TryGetValue(channel, out var entry))
|
||||
{
|
||||
entry = new Entry(new OccluderGroup(devices.DeviceContext));
|
||||
_entries.Add(key, entry);
|
||||
_entries.Add(channel, entry);
|
||||
}
|
||||
|
||||
entry.References++;
|
||||
return new OccluderLease(this, key, entry.Group);
|
||||
return new OccluderLease(this, channel, entry.Group);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Release((Guid Scene, int Channel) key)
|
||||
internal void Release(int channel)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (!_entries.TryGetValue(key, out var entry) || --entry.References > 0)
|
||||
if (!_entries.TryGetValue(channel, out var entry) || --entry.References > 0)
|
||||
return;
|
||||
|
||||
_entries.Remove(key);
|
||||
_entries.Remove(channel);
|
||||
entry.Group.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -295,26 +292,19 @@ internal static class OccluderRegistry
|
||||
{
|
||||
private static readonly ConditionalWeakTable<D2DDevices, OccluderBoard> Boards = [];
|
||||
|
||||
public static OccluderLease Acquire(IGraphicsDevicesAndContext devices, Guid scene, int channel)
|
||||
=> Boards.GetValue(devices.D2D, _ => new OccluderBoard()).Acquire(devices, scene, channel);
|
||||
public static OccluderLease Acquire(IGraphicsDevicesAndContext devices, int channel)
|
||||
=> Boards.GetValue(devices.D2D, _ => new OccluderBoard()).Acquire(devices, channel);
|
||||
}
|
||||
|
||||
internal sealed class OccluderLink
|
||||
{
|
||||
private OccluderGroup? _group;
|
||||
private int _frame;
|
||||
|
||||
public OccluderGroup? Group
|
||||
{
|
||||
get => Volatile.Read(ref _group);
|
||||
set => Volatile.Write(ref _group, value);
|
||||
}
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get => Volatile.Read(ref _frame);
|
||||
set => Volatile.Write(ref _frame, value);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class OccluderLinks
|
||||
|
||||
@@ -229,7 +229,7 @@ internal sealed class ShaftCustomEffect : D2D1CustomShaderEffectBase
|
||||
|
||||
Span<Occluder> occluders = stackalloc Occluder[VolumetricLightSettings.OccluderCapacity];
|
||||
Span<float> strengths = stackalloc float[VolumetricLightSettings.OccluderCapacity];
|
||||
group.Snapshot(occluders, link.Frame);
|
||||
group.Snapshot(occluders);
|
||||
for (var index = 0; index < occluders.Length; index++)
|
||||
{
|
||||
var plane = OccluderPlane.Create(_cameraFromLocal, occluders[index]);
|
||||
|
||||
@@ -54,7 +54,6 @@ internal sealed class VolumetricLightEffectProcessor(IGraphicsDevicesAndContext
|
||||
private int _linkId;
|
||||
private OccluderLease? _lease;
|
||||
private int _occlusionChannel = -1;
|
||||
private Guid _occlusionScene;
|
||||
private int _revision;
|
||||
|
||||
public override DrawDescription Update(EffectDescription effectDescription)
|
||||
@@ -101,8 +100,7 @@ internal sealed class VolumetricLightEffectProcessor(IGraphicsDevicesAndContext
|
||||
{
|
||||
SetScale(scene.Scale);
|
||||
Apply(scene.Constants);
|
||||
_link.Frame = effectDescription.TimelinePosition.Frame;
|
||||
SetOcclusion(effectDescription.SceneId, Math.Clamp(_item.OcclusionChannel, 0, VolumetricLightSettings.MaximumOcclusionChannel));
|
||||
SetOcclusion(Math.Clamp(_item.OcclusionChannel, 0, VolumetricLightSettings.MaximumOcclusionChannel));
|
||||
SetShaft(ShaftState.Shaft);
|
||||
}
|
||||
|
||||
@@ -215,19 +213,18 @@ internal sealed class VolumetricLightEffectProcessor(IGraphicsDevicesAndContext
|
||||
_constants = next;
|
||||
}
|
||||
|
||||
private void SetOcclusion(Guid scene, int channel)
|
||||
private void SetOcclusion(int channel)
|
||||
{
|
||||
if (_occlusionChannel != channel || _occlusionScene != scene)
|
||||
if (_occlusionChannel != channel)
|
||||
{
|
||||
ReleaseOcclusion();
|
||||
_lease = channel > 0 ? OccluderRegistry.Acquire(_devices, scene, channel) : null;
|
||||
_lease = channel > 0 ? OccluderRegistry.Acquire(_devices, channel) : null;
|
||||
_lease?.Group.AddConsumer(_shaft!.NativePointer);
|
||||
for (var slot = 0; slot < VolumetricLightSettings.OccluderCapacity; slot++)
|
||||
_shaft!.SetInput(VolumetricLightSettings.GoboLevelCount + slot, _lease?.Group.GetOutput(slot) ?? _emptyOutput, true);
|
||||
|
||||
_link.Group = _lease?.Group;
|
||||
_occlusionChannel = channel;
|
||||
_occlusionScene = scene;
|
||||
}
|
||||
|
||||
if (_lease?.Group.IsOccupied == true)
|
||||
|
||||
@@ -12,7 +12,6 @@ internal sealed class VolumetricLightOccluderEffectProcessor(IGraphicsDevicesAnd
|
||||
private OccluderLease? _lease;
|
||||
private OccluderSlot? _slot;
|
||||
private int _channel;
|
||||
private Guid _scene;
|
||||
|
||||
public override DrawDescription Update(EffectDescription effectDescription)
|
||||
{
|
||||
@@ -35,13 +34,11 @@ internal sealed class VolumetricLightOccluderEffectProcessor(IGraphicsDevicesAnd
|
||||
|
||||
var draw = effectDescription.DrawDescription;
|
||||
var channel = Math.Clamp(_item.Channel, 1, VolumetricLightSettings.MaximumOcclusionChannel);
|
||||
var scene = effectDescription.SceneId;
|
||||
if (_lease is null || _channel != channel || _scene != scene)
|
||||
if (_lease is null || _channel != channel)
|
||||
{
|
||||
Release();
|
||||
_lease = OccluderRegistry.Acquire(_devices, scene, channel);
|
||||
_lease = OccluderRegistry.Acquire(_devices, channel);
|
||||
_channel = channel;
|
||||
_scene = scene;
|
||||
}
|
||||
|
||||
_slot ??= _lease.Group.Claim();
|
||||
@@ -54,7 +51,7 @@ internal sealed class VolumetricLightOccluderEffectProcessor(IGraphicsDevicesAnd
|
||||
var occluder = draw.Zoom.X != 0f && draw.Zoom.Y != 0f && ViewTransform.TryCreate(draw, out var view)
|
||||
? new Occluder(view, GoboMapping.Create(draw.Zoom, draw.Invert, draw.CenterPoint), strength)
|
||||
: default;
|
||||
_slot.Publish(input, occluder, effectDescription.TimelinePosition.Frame);
|
||||
_slot.Publish(input, occluder);
|
||||
}
|
||||
|
||||
private void Release()
|
||||
|
||||
バイナリファイルは表示されません。
|
変更前 幅: | 高さ: | サイズ: 1.5 MiB |
バイナリファイルは表示されません。
|
変更前 幅: | 高さ: | サイズ: 1.6 MiB |
バイナリファイルは表示されません。
|
変更前 幅: | 高さ: | サイズ: 1.0 MiB |
新しいイシューから参照
ユーザーをブロックする