リリースワークフローを既存群と同一の構成にする
このコミットが含まれているのは:
2ファイル変更
+304
-461
検索条件に一致するファイルはありません
@@ -1,430 +0,0 @@
|
||||
# v1.0.0 - 波動光学 for YMM4
|
||||
|
||||
YukkuriMovieMaker4 向けの波動光学エフェクトプラグインの初回リリースです。
|
||||
フラウンホーファー回折理論に基づいて点像分布関数(PSF)を計算し、Direct2D カスタムシェーダーで
|
||||
映像を畳み込む映像エフェクトプラグインです。
|
||||
波長・F値・画素ピッチ・開口形状・ゼルニケ波面収差係数をパラメータとして持ち、
|
||||
円形開口・正多角形開口・中央遮蔽・6 種類の波面収差項に対応します。
|
||||
8 言語対応 UI を備えます。
|
||||
|
||||
---
|
||||
|
||||
## 新機能
|
||||
|
||||
### 1. 公開コントラクト(WaveOptics.Abstractions)
|
||||
|
||||
`WaveOptics.Abstractions` は主プラグインから独立したライブラリとして提供されます。
|
||||
|
||||
#### ApertureShape
|
||||
|
||||
開口形状を表す列挙体です。
|
||||
|
||||
| 値 | 意味 |
|
||||
|---|---|
|
||||
| `Circular` | 円形開口 |
|
||||
| `RegularPolygon` | 正多角形開口 |
|
||||
|
||||
#### OpticalApiVersion
|
||||
|
||||
`readonly record struct OpticalApiVersion(int Major, int Minor)` で宣言されます。
|
||||
`Current` 静的プロパティは `new(1, 0)` を返却します。
|
||||
|
||||
#### OpticalCapabilities
|
||||
|
||||
PSF 生成器の対応機能を表す `[Flags]` 列挙体です。
|
||||
|
||||
| 値 | 意味 |
|
||||
|---|---|
|
||||
| `None` | 0 |
|
||||
| `MonochromaticPsf` | 単色 PSF 生成 |
|
||||
| `CircularAperture` | 円形開口 |
|
||||
| `RegularPolygonAperture` | 正多角形開口 |
|
||||
| `CentralObstruction` | 中央遮蔽 |
|
||||
| `ZernikeAberration` | ゼルニケ収差 |
|
||||
| `DirectConvolution` | 直接畳み込み |
|
||||
|
||||
#### WavefrontAberration
|
||||
|
||||
8 つの収差係数を保持する `readonly struct` で、`IEquatable<WavefrontAberration>` を実装します。
|
||||
|
||||
| フィールド | 説明 |
|
||||
|---|---|
|
||||
| `DefocusWaves` | デフォーカス係数(-10〜10 waves) |
|
||||
| `AstigmatismVerticalWaves` | 縦横非点収差係数 |
|
||||
| `AstigmatismObliqueWaves` | 斜め非点収差係数 |
|
||||
| `ComaHorizontalWaves` | 水平コマ収差係数 |
|
||||
| `ComaVerticalWaves` | 垂直コマ収差係数 |
|
||||
| `TrefoilHorizontalWaves` | 水平トレフォイル係数 |
|
||||
| `TrefoilVerticalWaves` | 垂直トレフォイル係数 |
|
||||
| `SphericalWaves` | 球面収差係数 |
|
||||
|
||||
コンストラクターは各係数を `ValidateFiniteRange(-10, 10)` で検証します。
|
||||
`==`・`!=` 演算子および `GetHashCode` を実装します。
|
||||
|
||||
#### PsfDescriptor
|
||||
|
||||
PSF 計算パラメータを保持する `sealed` クラスで、`IEquatable<PsfDescriptor>` を実装します。
|
||||
|
||||
コンストラクターが受け取るパラメータと検証条件は以下のとおりです。
|
||||
|
||||
| パラメータ | 型 | 検証条件 |
|
||||
|---|---|---|
|
||||
| `pupilGridSize` | `int` | 64〜2048、かつ 2 の冪 |
|
||||
| `pupilDiameterSamples` | `int` | 16〜`pupilGridSize / 2` |
|
||||
| `kernelSize` | `int` | 3〜255、かつ奇数 |
|
||||
| `wavelengthNanometers` | `double` | 有限値、380〜780 |
|
||||
| `fNumber` | `double` | 有限値、0.5〜64 |
|
||||
| `sensorPixelPitchMicrometers` | `double` | 有限値、0.25〜100 |
|
||||
| `apertureShape` | `ApertureShape` | 定義済み列挙値 |
|
||||
| `bladeCount` | `int` | 3〜32 |
|
||||
| `bladeRotationDegrees` | `double` | 有限値、-360〜360 |
|
||||
| `centralObstructionRatio` | `double` | 有限値、0〜0.95 |
|
||||
| `aberration` | `WavefrontAberration` | — |
|
||||
|
||||
`Equals` はすべてのフィールドの完全一致で判定します。`GetHashCode` は `HashCode.Combine` を 2 段に分けて計算します。
|
||||
|
||||
#### PsfKernel
|
||||
|
||||
PSF カーネルデータを保持する `sealed` クラスです。
|
||||
|
||||
コンストラクターは `size`(奇数正整数)と `values`(`size × size` 長、全要素非負有限)を受け取り、
|
||||
合計値が正であることを検証してから値の総和で正規化します。入力配列は内部にコピーします。
|
||||
|
||||
`Sum` メソッドはカハン補償加算でエラー累積を抑えた合計値を返却します。
|
||||
|
||||
| メンバー | 説明 |
|
||||
|---|---|
|
||||
| `Size` | カーネルの一辺の画素数 |
|
||||
| `Values` | 正規化済み値の `ReadOnlyMemory<double>` |
|
||||
| `this[int x, int y]` | 範囲検証付きインデクサー |
|
||||
| `ToArray()` | 内部配列のクローン |
|
||||
|
||||
#### PsfDiagnostics
|
||||
|
||||
`readonly record struct PsfDiagnostics` で以下の診断値を保持します。
|
||||
|
||||
| フィールド | 説明 |
|
||||
|---|---|
|
||||
| `OpenPupilSampleCount` | 開口内の有効サンプル数 |
|
||||
| `FocalPlaneSamplePitchMicrometers` | 焦点面サンプル間隔(μm) |
|
||||
| `UnnormalizedKernelEnergy` | 正規化前のカーネルエネルギー |
|
||||
| `PeakIntensity` | カーネルの最大強度値 |
|
||||
|
||||
#### PsfGenerationResult
|
||||
|
||||
`sealed record PsfGenerationResult(PsfKernel Kernel, PsfDiagnostics Diagnostics)` で宣言されます。
|
||||
|
||||
#### IPsfGenerator
|
||||
|
||||
```csharp
|
||||
public interface IPsfGenerator
|
||||
{
|
||||
OpticalApiVersion ApiVersion { get; }
|
||||
OpticalCapabilities Capabilities { get; }
|
||||
PsfGenerationResult Generate(PsfDescriptor descriptor);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 2. 高速フーリエ変換(FastFourierTransform)
|
||||
|
||||
`internal static class FastFourierTransform` は 1 次元および 2 次元の FFT・逆 FFT を提供します。
|
||||
|
||||
| メソッド | 説明 |
|
||||
|---|---|
|
||||
| `Forward(Span<Complex>)` | 1 次元前進 FFT |
|
||||
| `Inverse(Span<Complex>)` | 1 次元逆 FFT(1/N スケール適用) |
|
||||
| `Forward2D(Complex[], int, int)` | 2 次元前進 FFT(行→列の順) |
|
||||
| `Inverse2D(Complex[], int, int)` | 2 次元逆 FFT |
|
||||
|
||||
1 次元実装はクーリー・テューキーアルゴリズムに基づく入力サイズ 2 の冪専用の再帰なし実装です。ビット反転置換を前処理として行い、以降を長さ倍増ループで処理します。逆変換では最後に `1/count` を乗算します。
|
||||
|
||||
2 次元実装は各行・各列に独立して 1 次元変換を適用します。列方向の処理には作業用配列 `new Complex[height]` を確保します。
|
||||
|
||||
---
|
||||
|
||||
### 3. ゼルニケ波面評価(ZernikeWavefront)
|
||||
|
||||
`internal static class ZernikeWavefront` は正規化ゼルニケ多項式による波面位相を評価します。
|
||||
|
||||
`Evaluate(double x, double y, WavefrontAberration aberration)` は以下の項の線形結合を返却します。
|
||||
|
||||
| 項 | 式 |
|
||||
|---|---|
|
||||
| デフォーカス | `√3 × (2ρ² − 1)` |
|
||||
| 縦横非点収差 | `√6 × (x² − y²)` |
|
||||
| 斜め非点収差 | `2√6 × xy` |
|
||||
| 水平コマ収差 | `√8 × (3ρ² − 2) × x` |
|
||||
| 垂直コマ収差 | `√8 × (3ρ² − 2) × y` |
|
||||
| 水平トレフォイル | `√8 × x × (x² − 3y²)` |
|
||||
| 垂直トレフォイル | `√8 × y × (3x² − y²)` |
|
||||
| 球面収差 | `√5 × (6ρ⁴ − 6ρ² + 1)` |
|
||||
|
||||
`WavefrontAberration` の `TrefoilHorizontalWaves`・`TrefoilVerticalWaves` は`WaveOpticsEffect` の UI には公開されておらず、常に 0 として扱われます。
|
||||
|
||||
---
|
||||
|
||||
### 4. フラウンホーファーPSF生成器(FraunhoferPsfGenerator)
|
||||
|
||||
`public sealed class FraunhoferPsfGenerator : IPsfGenerator` を実装します。
|
||||
|
||||
`Capabilities` は以下のフラグを返却します。
|
||||
`MonochromaticPsf | CircularAperture | RegularPolygonAperture | CentralObstruction | ZernikeAberration | DirectConvolution`
|
||||
|
||||
#### Generate メソッド
|
||||
|
||||
1. `gridSize × gridSize` の `Complex[]` 配列を確保します。
|
||||
2. グリッド中心を基準に各サンプル `(x, y)` を正規化座標 `(normalizedX, normalizedY)` に変換し、
|
||||
`IsInsideAperture` で開口内を判定します。
|
||||
3. 開口内のサンプルに対して `ZernikeWavefront.Evaluate` で波面位相 `φ` を計算し、
|
||||
`Complex.FromPolarCoordinates(1d, 2π × φ)` を瞳関数値として設定します。
|
||||
4. `FastFourierTransform.Forward2D` を適用します。
|
||||
5. 変換後の値の二乗絶対値(強度)を計算し、FFT のゼロ周波数が中心に来るよう DC シフトして
|
||||
`double[]` 配列に格納します。全強度の和で正規化します。
|
||||
6. 焦点面サンプルピッチ `λ × F × D / N`(μm)を計算し、カーネルの各画素に対応する
|
||||
焦点面座標を求めて `SampleBilinear` で強度を取得します。
|
||||
7. `new PsfKernel(kernelSize, kernel)` を生成して返却します。
|
||||
|
||||
#### IsInsideAperture メソッド
|
||||
|
||||
- 正規化半径の二乗が 1 超 → 開口外。
|
||||
- 正規化半径の二乗が `obstructionRatio²` 未満 → 遮蔽領域。
|
||||
- 円形開口の場合は上記を満たせば開口内。
|
||||
- 正多角形の場合:`Math.Atan2(y, x) - rotation` を `2π / bladeCount` で折り畳み、境界距離
|
||||
`cos(π / bladeCount) / cos(folded)` と半径を比較します。
|
||||
|
||||
#### SampleBilinear メソッド
|
||||
|
||||
双線形補間でグリッド外を 0 として返却します。
|
||||
|
||||
---
|
||||
|
||||
### 5. PSFビットマップ生成(PsfBitmapFactory)
|
||||
|
||||
`internal static class PsfBitmapFactory` の `Create(ID2D1DeviceContext, PsfKernel)` は
|
||||
PSF カーネルの各値を RGBA 4 チャンネルの `float[]` に展開(R=G=B=値, A=1)し、
|
||||
ピン留めポインタを使って `ID2D1DeviceContext1.CreateBitmap` を呼び出します。
|
||||
ピクセルフォーマットは `Format.R32G32B32A32_Float` / `AlphaMode.Ignore` / 96 DPI です。
|
||||
|
||||
---
|
||||
|
||||
### 6. カスタムシェーダーエフェクト(WaveOpticsConvolutionEffect)
|
||||
|
||||
`internal sealed class WaveOpticsConvolutionEffect : D2D1CustomShaderEffectBase` は
|
||||
`[CustomEffect(2)]` の 2 入力エフェクトとして宣言されます(入力 0: ソース画像、入力 1: PSF ビットマップ)。
|
||||
|
||||
定数は以下のとおりです。
|
||||
|
||||
| 定数 | 値 |
|
||||
|---|---|
|
||||
| `MaximumKernelSize` | `31` |
|
||||
|
||||
公開プロパティは `GetIntValue`・`GetFloatValue`・`SetValue` を介して `EffectImpl` へ転送します。
|
||||
|
||||
| プロパティ | 型 | 説明 |
|
||||
|---|---|---|
|
||||
| `KernelSize` | `int` | カーネルサイズ(奇数にクランプ、最大 31) |
|
||||
| `Amount` | `float` | 適用量(0〜1) |
|
||||
| `Gain` | `float` | 利得(0〜4) |
|
||||
|
||||
`SetSource(ID2D1Image?)` は入力 0 を設定します。`SetKernel(ID2D1Image?)` は入力 1 を設定します。
|
||||
|
||||
#### EffectImpl(内部 sealed クラス)
|
||||
|
||||
`ConstantBuffer` 構造体(`LayoutKind.Sequential`)のレイアウトは以下のとおりです。
|
||||
|
||||
| フィールド | 型 | 説明 |
|
||||
|---|---|---|
|
||||
| `KernelSize` | `int` | カーネルサイズ |
|
||||
| `Amount` | `float` | 適用量 |
|
||||
| `Gain` | `float` | 利得 |
|
||||
| `Padding` | `float` | アライメント用 |
|
||||
| `InputBounds` | `Vector4` | 入力矩形(Left, Top, Right, Bottom) |
|
||||
|
||||
コンストラクターは `constants.KernelSize = 1`・`constants.Gain = 1` を初期値として設定します。
|
||||
|
||||
`MapInputRectsToOutputRect` は `inputRect` と `inputBounds` を更新した後、
|
||||
`Inflate(inputRect, GetRadius())` を出力矩形に設定します。
|
||||
|
||||
`GetRadius` は `Amount > 0` かつ `KernelSize > 1` のとき `KernelSize / 2` を、それ以外は `0` を返却します。
|
||||
|
||||
#### HLSLシェーダー(WaveOpticsConvolution.hlsl)
|
||||
|
||||
`t0`(ソース画像)・`t1`(PSF ビットマップ)・`b0`(定数バッファー)を持つピクセルシェーダーです。
|
||||
|
||||
- `amount <= 0` または `kernelSize <= 1` の場合はソースをそのまま返却します。
|
||||
- ループ範囲は固定 `-MaximumRadius`〜`MaximumRadius`(= -15〜15)で、
|
||||
`abs(x) > radius` または `abs(y) > radius` のサンプルは `continue` でスキップします。
|
||||
- PSF の重みは `KernelTexture.Load(int3(x + radius, y + radius, 0)).r` で取得します。
|
||||
- 入力矩形外のサンプルは黒として扱います。
|
||||
- `lerp(source, convolved * gain, amount)` で出力します。
|
||||
|
||||
---
|
||||
|
||||
### 7. エフェクト定義(WaveOpticsEffect)
|
||||
|
||||
`public sealed class WaveOpticsEffect : VideoEffectBase` を継承します。
|
||||
|
||||
`[VideoEffect]` 属性は以下のパラメーターで宣言されます。
|
||||
|
||||
- 表示名:`Texts.EffectName`(ローカライズキー)
|
||||
- カテゴリー:`VideoEffectCategories.Filtering`
|
||||
- 検索タグ:`TagDiffraction`・`TagLens`・`TagPsf`・`TagOptics`(「回折」・「レンズ」・「点像分布関数」・「光学」)
|
||||
- `IsAviUtlSupported = false` により AviUtl 向け EXO 出力は非対応
|
||||
- `ResourceType = typeof(Texts)` でローカライズリソースを指定
|
||||
|
||||
`Label` プロパティは `Texts.EffectName` を返却します。
|
||||
|
||||
公開プロパティは以下のとおりです。
|
||||
|
||||
**出力グループ**
|
||||
|
||||
| プロパティ | 型 | デフォルト | 内部範囲 |
|
||||
|---|---|---|---|
|
||||
| `Amount` | `Animation` | 100 | 0〜100 |
|
||||
| `Gain` | `Animation` | 100 | 0〜400 |
|
||||
|
||||
**光学系グループ**
|
||||
|
||||
| プロパティ | 型 | デフォルト | 内部範囲 |
|
||||
|---|---|---|---|
|
||||
| `Wavelength` | `Animation` | 550 | 380〜780 |
|
||||
| `FNumber` | `Animation` | 8 | 0.5〜64 |
|
||||
| `PixelPitch` | `Animation` | 4 | 0.25〜100 |
|
||||
| `KernelRadius` | `int` | 15 | 1〜15 |
|
||||
| `Quality` | `WaveOpticsQuality` | `Standard` | — |
|
||||
|
||||
**開口グループ**
|
||||
|
||||
| プロパティ | 型 | デフォルト | 内部範囲 |
|
||||
|---|---|---|---|
|
||||
| `ApertureShape` | `WaveOpticsApertureShape` | `Circular` | — |
|
||||
| `BladeCount` | `int` | 6 | 3〜32 |
|
||||
| `BladeRotation` | `Animation` | 0 | -360〜360 |
|
||||
| `Obstruction` | `Animation` | 0 | 0〜95 |
|
||||
|
||||
**波面収差グループ**
|
||||
|
||||
| プロパティ | 型 | デフォルト | 内部範囲 |
|
||||
|---|---|---|---|
|
||||
| `Defocus` | `Animation` | 0 | -10〜10 |
|
||||
| `AstigmatismVertical` | `Animation` | 0 | -10〜10 |
|
||||
| `AstigmatismOblique` | `Animation` | 0 | -10〜10 |
|
||||
| `ComaHorizontal` | `Animation` | 0 | -10〜10 |
|
||||
| `ComaVertical` | `Animation` | 0 | -10〜10 |
|
||||
| `Spherical` | `Animation` | 0 | -10〜10 |
|
||||
|
||||
`GetAnimatables` は `Amount`・`Gain`・`Wavelength`・`FNumber`・`PixelPitch`・`BladeRotation`・
|
||||
`Obstruction`・`Defocus`・`AstigmatismVertical`・`AstigmatismOblique`・`ComaHorizontal`・
|
||||
`ComaVertical`・`Spherical` を yield します。
|
||||
|
||||
---
|
||||
|
||||
### 8. エフェクトプロセッサー(WaveOpticsEffectProcessor)
|
||||
|
||||
`internal sealed class WaveOpticsEffectProcessor : VideoEffectProcessorBase` を継承します。
|
||||
|
||||
#### Update メソッド
|
||||
|
||||
`IsPassThroughEffect || effect is null` の場合は `effectDescription.DrawDescription` をそのまま返却します。
|
||||
|
||||
各フレームで以下の値を計算します。
|
||||
|
||||
| パラメーター | クランプ範囲 | フォールバック |
|
||||
|---|---|---|
|
||||
| `amount` | 0〜1 | 0 |
|
||||
| `gain` | 0〜4 | 1 |
|
||||
| `wavelength` | 380〜780 | 550 |
|
||||
| `fNumber` | 0.5〜64 | 8 |
|
||||
| `pixelPitch` | 0.25〜100 | 4 |
|
||||
| `obstruction / 100` | 0〜0.95 | 0 |
|
||||
| 各収差係数 | -10〜10 | 0 |
|
||||
|
||||
`Parameters` レコードとして前フレームの値と比較し、変化があった場合のみ `UpdateKernel` を呼び出します。
|
||||
`Amount`・`Gain` も同様に差分検出して `effect` のプロパティを更新します。
|
||||
|
||||
#### UpdateKernel メソッド
|
||||
|
||||
`WavefrontAberration` と `PsfDescriptor` を構築して `FraunhoferPsfGenerator.Generate` を呼び出します。
|
||||
|
||||
品質から FFT 格子サイズへの変換は以下のとおりです。
|
||||
|
||||
| `WaveOpticsQuality` | FFT 格子サイズ |
|
||||
|---|---|
|
||||
| `Draft` | 128 |
|
||||
| `High` | 512 |
|
||||
| その他(`Standard`) | 256 |
|
||||
|
||||
`PsfDescriptor` の `pupilDiameterSamples` は `gridSize / 4` に固定されます。
|
||||
`kernelSize` は `KernelRadius * 2 + 1` です。
|
||||
|
||||
`PsfBitmapFactory.Create` で新しいビットマップを作成し、`disposer.RemoveAndDispose` で旧ビットマップを破棄してから新ビットマップを `effect` に設定します。
|
||||
|
||||
#### CreateEffect / setInput / ClearEffectChain
|
||||
|
||||
`CreateEffect` は `WaveOpticsConvolutionEffect` を生成し、`IsEnabled` が false の場合は破棄して
|
||||
`null` を返却します。有効な場合は `disposer` に収集し、`Output` を取得して返却します。
|
||||
|
||||
`setInput` は `effect?.SetSource(input)` を呼び出します。
|
||||
|
||||
`ClearEffectChain` は `effect?.SetSource(null)`・`effect?.SetKernel(null)` を呼び出し、
|
||||
`currentParameters = null`・`isFirst = true` にリセットします。
|
||||
|
||||
---
|
||||
|
||||
### 9. 公開API(WaveOpticsApi)
|
||||
|
||||
`public static class WaveOpticsApi` を提供します。
|
||||
|
||||
| メンバー | 説明 |
|
||||
|---|---|
|
||||
| `Version` | `OpticalApiVersion.Current` を返却します |
|
||||
| `CreatePsfGenerator()` | `new FraunhoferPsfGenerator()` を返却します |
|
||||
|
||||
---
|
||||
|
||||
### 10. ローカライズ(Texts)
|
||||
|
||||
`Texts` クラスは `[AutoGenLocalizer]` 属性を持つ `partial` クラスとして宣言されます。
|
||||
`YukkuriMovieMaker.Generator` のソースジェネレーターが `Texts.csv` を処理し、
|
||||
各ロケールのリソースファイルを自動生成します。
|
||||
|
||||
対応言語:日本語(`ja-jp`)・英語(`en-us`)・中国語簡体字(`zh-cn`)・中国語繁体字(`zh-tw`)・
|
||||
韓国語(`ko-kr`)・スペイン語(`es-es`)・アラビア語(`ar-sa`)・インドネシア語(`id-id`)
|
||||
|
||||
ローカライズキーの一覧は以下のとおりです。
|
||||
|
||||
| キー | ja-jp |
|
||||
|---|---|
|
||||
| `EffectName` | 波動光学 |
|
||||
| `OutputGroup` | 出力 |
|
||||
| `OpticsGroup` | 光学系 |
|
||||
| `ApertureGroup` | 開口 |
|
||||
| `AberrationGroup` | 波面収差 |
|
||||
| `AmountName` | 適用量 |
|
||||
| `GainName` | 利得 |
|
||||
| `WavelengthName` | 波長 |
|
||||
| `FNumberName` | F値 |
|
||||
| `PixelPitchName` | 画素ピッチ |
|
||||
| `KernelRadiusName` | カーネル半径 |
|
||||
| `QualityName` | 品質 |
|
||||
| `QualityDraft` | 高速 |
|
||||
| `QualityStandard` | 標準 |
|
||||
| `QualityHigh` | 高精度 |
|
||||
| `ApertureShapeName` | 開口形状 |
|
||||
| `CircularAperture` | 円形 |
|
||||
| `RegularPolygonAperture` | 正多角形 |
|
||||
| `BladeCountName` | 羽根枚数 |
|
||||
| `BladeRotationName` | 開口回転 |
|
||||
| `ObstructionName` | 中央遮蔽 |
|
||||
| `DefocusName` | デフォーカス |
|
||||
| `AstigmatismVerticalName` | 縦横非点収差 |
|
||||
| `AstigmatismObliqueName` | 斜め非点収差 |
|
||||
| `ComaHorizontalName` | 水平コマ収差 |
|
||||
| `ComaVerticalName` | 垂直コマ収差 |
|
||||
| `SphericalName` | 球面収差 |
|
||||
| `TagDiffraction` | 回折 |
|
||||
| `TagLens` | レンズ |
|
||||
| `TagPsf` | 点像分布関数 |
|
||||
| `TagOptics` | 光学 |
|
||||
+304
-31
@@ -14,29 +14,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: ソースコードのチェックアウト
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: .NET SDK のセットアップ
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v6
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: fxc.exe の検索
|
||||
id: fxc
|
||||
shell: pwsh
|
||||
run: |
|
||||
$fxc = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin" -Recurse -Filter "fxc.exe" |
|
||||
Where-Object { $_.FullName -like "*x64*" } |
|
||||
Sort-Object FullName -Descending |
|
||||
Select-Object -First 1
|
||||
if (-not $fxc) {
|
||||
Write-Error "fxc.exe が見つかりませんでした。"
|
||||
exit 1
|
||||
}
|
||||
Write-Host "fxc.exe の場所: $($fxc.FullName)"
|
||||
echo "FXC_PATH=$($fxc.FullName)" >> $env:GITHUB_OUTPUT
|
||||
- name: MSBuild のセットアップ
|
||||
uses: microsoft/setup-msbuild@v3
|
||||
|
||||
- name: YMM4 最新リリースの取得と解凍
|
||||
id: ymm4
|
||||
@@ -64,16 +53,45 @@ jobs:
|
||||
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
|
||||
echo "VERSION=$($tag.TrimStart('v'))" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: resx ファイルの生成(初回ビルド)
|
||||
- name: バージョン記載の照合
|
||||
shell: pwsh
|
||||
run: |
|
||||
$proj = "WaveOptics/WaveOptics.csproj"
|
||||
dotnet build "$proj" `
|
||||
-c Release `
|
||||
-p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" `
|
||||
-p:FxcPath="${{ steps.fxc.outputs.FXC_PATH }}" `
|
||||
-p:Platform=x64 `
|
||||
-p:SkipPluginDeploy=true
|
||||
$tag = "${{ steps.version.outputs.TAG }}"
|
||||
$version = "${{ steps.version.outputs.VERSION }}"
|
||||
$problems = @()
|
||||
|
||||
$csprojPath = "WaveOptics/WaveOptics.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 WaveOptics.Shader/WaveOptics.Shader.vcxproj `
|
||||
/p:Configuration=Release `
|
||||
/p:Platform=Win32 `
|
||||
/nologo
|
||||
|
||||
- name: プロジェクトのビルド
|
||||
shell: pwsh
|
||||
@@ -82,7 +100,6 @@ jobs:
|
||||
dotnet build "$proj" `
|
||||
-c Release `
|
||||
-p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" `
|
||||
-p:FxcPath="${{ steps.fxc.outputs.FXC_PATH }}" `
|
||||
-p:Platform=x64 `
|
||||
-p:SkipPluginDeploy=true
|
||||
|
||||
@@ -92,8 +109,8 @@ jobs:
|
||||
dotnet build WaveOptics.Tests/WaveOptics.Tests.csproj `
|
||||
-c Release `
|
||||
-p:YMM4DirPath="${{ steps.ymm4.outputs.YMM4_DIR }}" `
|
||||
-p:FxcPath="${{ steps.fxc.outputs.FXC_PATH }}" `
|
||||
-p:Platform=x64 `
|
||||
-p:SkipPluginDeploy=true `
|
||||
-maxcpucount:1
|
||||
|
||||
- name: テストの実行
|
||||
@@ -101,8 +118,10 @@ jobs:
|
||||
run: |
|
||||
dotnet test WaveOptics.Tests/WaveOptics.Tests.csproj `
|
||||
--no-build `
|
||||
--no-restore `
|
||||
-c Release `
|
||||
-p:Platform=x64
|
||||
-p:Platform=x64 `
|
||||
-p:SkipPluginDeploy=true
|
||||
|
||||
- name: パッケージの作成
|
||||
id: package
|
||||
@@ -114,9 +133,15 @@ jobs:
|
||||
$pkgName = "WaveOptics_$version.ymme"
|
||||
|
||||
New-Item -ItemType Directory -Path $stageRoot -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path "$stageRoot/LICENSE" -Force | Out-Null
|
||||
|
||||
Copy-Item "$outDir/WaveOptics.dll" "$stageRoot/"
|
||||
Copy-Item "$outDir/WaveOptics.Abstractions.dll" "$stageRoot/"
|
||||
foreach ($dll in @("$outDir/plugin/WaveOptics.dll", "$outDir/WaveOptics.Abstractions.dll")) {
|
||||
if (-not (Test-Path $dll)) {
|
||||
Write-Error "ビルド結果に $(Split-Path $dll -Leaf) が見つかりませんでした: $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"
|
||||
@@ -126,16 +151,264 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
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:
|
||||
GH_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)
|
||||
}
|
||||
|
||||
$accounts = @{}
|
||||
$page = 1
|
||||
while ($pending.Count -gt 0 -and $page -le 20) {
|
||||
$rows = @()
|
||||
try {
|
||||
$rows = @(gh api "repos/$repository/commits?sha=$tag&per_page=100&page=$page" --jq '.[] | [.sha, (.author.login // ""), (.author.avatar_url // "")] | @tsv')
|
||||
}
|
||||
catch {
|
||||
Write-Host "コミットの作者を取得できませんでした: $($_.Exception.Message)"
|
||||
break
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0 -or $rows.Count -eq 0) { break }
|
||||
|
||||
foreach ($row in $rows) {
|
||||
$fields = $row -split "`t"
|
||||
if ($fields.Count -lt 3) { continue }
|
||||
if ($pending.Remove($fields[0])) {
|
||||
$accounts[$fields[0]] = @{ Login = $fields[1]; Avatar = $fields[2] }
|
||||
}
|
||||
}
|
||||
|
||||
if ($rows.Count -lt 100) { 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: GitHub リリースの作成
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
name: ${{ steps.version.outputs.TAG }}
|
||||
body_path: .github/CHANGELOG.md
|
||||
body_path: release-body.md
|
||||
files: ${{ steps.package.outputs.PKG_NAME }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
新しいイシューから参照
ユーザーをブロックする