13 コミット
作成者 SHA1 メッセージ 日付
routersys 52ef7ad2a3 バージョンをv3.2.0へ更新する 2026-10-07 08:44:41 +09:00
routersys 424e2b0671 標本の印の位置を定数の式で表す 2026-10-07 08:31:12 +09:00
routersys 27da67d503 光の逆変換の精度を試験で固める 2026-10-07 08:31:11 +09:00
routersys f172f41f4a 試験とハーネスのコメントを外して名前で表す 2026-10-07 08:06:10 +09:00
routersys 69b8346949 光の変換の表の段数を定数の式で表す 2026-10-07 08:06:10 +09:00
routersys 8534fa6d77 GPUのタイルの割り当てと標本の判定を名前で表す 2026-10-07 08:06:09 +09:00
routersys eb7fa93b0e CPUのバタフライの2位置まとめの段を関数へ分ける 2026-10-07 08:06:08 +09:00
routersys 4adcb2d763 素材の判定のベクトル版のコメントを外す 2026-10-07 08:06:08 +09:00
routersys d8081adec5 説明書のハイライトの項目名を新しい名前へ合わせる 2026-10-07 07:58:41 +09:00
routersys 8353194569 ハイライトの2項目の名前を短くする
・ハイライトの2項目の名前を、ハイライト閾値とハイライト強度へ短くするよう変更-M
2026-10-07 07:58:41 +09:00
routersys 3f8700d493 説明書へ効かない項目は表示されないことを書く 2026-10-07 07:41:03 +09:00
routersys a5d2cf1943 設定の項目が効くときだけ表示されることを試験で固める 2026-10-07 07:41:03 +09:00
routersys b63b8c66a1 条件によって効かない項目を設定の画面で隠す
・円形の開口では羽根枚数と開口回転を、線形光がオフではハイライトの2項目を表示しないよう変更-M
2026-10-07 07:41:02 +09:00
19個のファイルの変更、305行の追加、125行の削除

検索条件に一致するファイルはありません

+5 -4
ファイルの表示
@@ -1,5 +1,5 @@
========================================
波動光学 for YMM4 v3.1.0
波動光学 for YMM4 v3.2.0
========================================
YukkuriMovieMaker4上で動作する、素材を回折も収差もない理想の像とみなし、
レンズの開口と波面収差から求めた点像分布関数で畳み込んで、
@@ -18,7 +18,7 @@ YukkuriMovieMaker4上で動作する、素材を回折も収差もない理想
履歴フレーム、参照画像、深度情報、学習済みモデルは使用しません。
にじみの形は光学系と収差の設定から決定論的に決まり、同じ設定では常に
同じ形になります。
適用量、利得、ハイライトのしきい値、ハイライトの強さ、波長、F値、画素ピッチ、
適用量、利得、ハイライト閾値、ハイライト強度、波長、F値、画素ピッチ、
開口回転、中央遮蔽、デフォーカス、縦横非点収差、斜め非点収差、水平コマ収差、
垂直コマ収差、球面収差の15項目はアニメーションに対応しています。
畳み込みはGPUで計算します。畳み込みを計算し直したフレームでは、その結果を
@@ -26,7 +26,7 @@ YukkuriMovieMaker4上で動作する、素材を回折も収差もない理想
CPUで計算します。
「線形光」をオンにすると、
画素の値を光の強さに比例する値へ直してから畳み込みます。
「ハイライトの強さ」を上げると、光源のような明るい部分を持ち上げて、
「ハイライト強度」を上げると、光源のような明るい部分を持ち上げて、
回折の筋のような小さな光を見えるようにできます。
エフェクトの種類一覧では「波動光学」として表示されます。
--------------------------------------------------------------------------------
@@ -81,7 +81,8 @@ CPUで計算します。
変換した値に不透明度を掛け直します。オフのときは、
画素の値をそのまま畳み込みます。
- ハイライト: ハイライトのしきい値と強さは、線形光がオンのときだけ働きます。
- ハイライト: ハイライト閾値と強度は、線形光がオンのときだけ働き、
オフのときは設定の画面に表示されません。
素材は8ビットで、光源の画素の値は1.0で頭打ちです。
回折の筋のように中心よりはるかに小さい光は、
そのままでは出力の1階調に届きません。強さを上げると、
+12 -12
ファイルの表示
@@ -10,9 +10,9 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材を回折も収差もな
点像分布関数は、瞳関数のフラウンホーファー回折を高速フーリエ変換で解いて求めます。
履歴フレーム、参照画像、学習済みモデルを使わず、入力された一枚の映像だけを処理します。
にじみの形は光学系と収差の設定から決定論的に決まり、同じ設定では常に同じ形になります。
適用量、利得、ハイライトのしきい値、ハイライトの強さ、波長、F値、画素ピッチ、開口回転、中央遮蔽、デフォーカス、縦横非点収差、斜め非点収差、水平コマ収差、垂直コマ収差、球面収差の15項目はアニメーションに対応しています。
適用量、利得、ハイライト閾値、ハイライト強度、波長、F値、画素ピッチ、開口回転、中央遮蔽、デフォーカス、縦横非点収差、斜め非点収差、水平コマ収差、垂直コマ収差、球面収差の15項目はアニメーションに対応しています。
畳み込みはGPUで計算します。畳み込みを計算し直したフレームでは、その結果を画面に出す前に検査します。GPUを使えないときと、検査で誤りを見つけたときは、CPUで計算します。
「線形光」をオンにすると、画素の値を光の強さに比例する値へ直してから畳み込みます。「ハイライトの強さ」を上げると、光源のような明るい部分を持ち上げて、回折の筋のような小さな光を見えるようにできます。
「線形光」をオンにすると、画素の値を光の強さに比例する値へ直してから畳み込みます。「ハイライト強度」を上げると、光源のような明るい部分を持ち上げて、回折の筋のような小さな光を見えるようにできます。
![Image](https://github.com/routersys/YMM4-WaveOptics/blob/main/docs/WaveOptics.png)
@@ -119,7 +119,7 @@ GPUにある値をCPUが読み取ることを、読み戻しと呼びます。GP
### 3. 開口の形と中央遮蔽
「開口形状」は、円形と正多角形から選びます。正多角形は、カメラの絞りの羽根が作る開口をまねた形で、頂点は円形の開口と同じ直径の円の上にあります。頂点までの距離を開口の半径とします。辺の数は「羽根枚数」で、向きは「開口回転」で決めます。正多角形の開口では、点像分布関数が辺と垂直な向きへ伸びます。デフォーカスでにじみが大きいときは、にじみが、開口と同じ辺の数の正多角形の形になります。にじみが切り取られないよう、カーネル半径と品質を上げてください。「羽根枚数」と「開口回転」は、開口形状が正多角形のときだけ働きます。
「開口形状」は、円形と正多角形から選びます。正多角形は、カメラの絞りの羽根が作る開口をまねた形で、頂点は円形の開口と同じ直径の円の上にあります。頂点までの距離を開口の半径とします。辺の数は「羽根枚数」で、向きは「開口回転」で決めます。正多角形の開口では、点像分布関数が辺と垂直な向きへ伸びます。デフォーカスでにじみが大きいときは、にじみが、開口と同じ辺の数の正多角形の形になります。にじみが切り取られないよう、カーネル半径と品質を上げてください。「羽根枚数」と「開口回転」は、開口形状が正多角形のときだけ働くので、円形のときは設定の画面に表示されません。
「中央遮蔽」は、反射望遠鏡の副鏡のように開口の中央をふさぐ円の大きさで、開口の半径に対する割合です。値を上げると中心の明るさが下がり、周りの輪へ光が移ります。中央遮蔽は、どちらの開口形状でも、中央を円でふさぎます。
@@ -156,7 +156,7 @@ Tが同じなら、カーネル半径を上げるほど、1枚のタイルが出
- デフォーカス: 0と0.1 waves
- 利得: 100%と150%
2つ目の表の「素材」の行は、1つ目の表の「素材」の行と同じ設定の、比べるための行です。素材の線形光の行は、線形光をオンにして、素材を「素材」の行と同じように入れ替えています。素材の線形光とハイライトの行は、さらにハイライトのしきい値を70%、強さを30倍にしています。合成した画像の画素の最も明るいチャンネルの値は、最大で0.9なので、しきい値を70%にしました。
2つ目の表の「素材」の行は、1つ目の表の「素材」の行と同じ設定の、比べるための行です。素材の線形光の行は、線形光をオンにして、素材を「素材」の行と同じように入れ替えています。素材の線形光とハイライトの行は、さらにハイライト閾値を70%、強さを30倍にしています。合成した画像の画素の最も明るいチャンネルの値は、最大で0.9なので、しきい値を70%にしました。
表の時間は、素材が変わったかどうかの判定と、畳み込みの計算を合わせた値です。デフォーカスの行は、点像分布関数とカーネルのスペクトルをCPUで求める時間と、GPUへ送る時間も含みます。利得の行は、保存した値に利得を掛け直す時間です。保存した値は、「利得と適用量」の節で説明しています。「検査あり」の行は、畳み込みを計算し直すたびの検査を含みます。検査は、GPUが書いた値を読み戻して、CPUで求めた値と比べる処理です。ほかのGPUの行は、検査を含みません。実際のフレームでは、検査が毎回行われます。GPUの経路の時間に含まないものは、YMM4との間で素材と結果を受け渡す時間です。CPUの経路の時間に含まないものは、Direct2Dのビットマップとの間で画素を読み書きする時間です。表に含まない時間は、実際のフレームでは別にかかります。
@@ -225,7 +225,7 @@ v > 0.04045 のとき x = ((v + 0.055) / 1.055)^2.4
「線形光」をオンにすると、素材の画素の値を線形の値へ直してから畳み込み、結果を画素の値へ戻します。オフのときは、画素の値をそのまま畳み込みます。半透明の画素は、素材の色を不透明度で割って元の色に戻してから変換し、変換した値に不透明度を掛け直します。畳み込んだ結果には、まず利得を掛けます。次に、色と不透明度の各成分を0〜1に打ち切り、色の成分が不透明度を超えないように抑えます。最後に、画素の値へ戻し、不透明度を掛け直して、8ビットに丸めます。
「ハイライトのしきい値」と「ハイライトの強さ」は、線形光がオンのときだけ働きます。素材は8ビットなので、光源の画素の値は1.0で頭打ちです。実際の光源はもっと明るいはずですが、その明るさは素材に残っていません。回折の筋のように中心よりはるかに小さい光は、そのままでは、出力の8ビットの1階調に届きません。ハイライトの強さを上げると、明るい画素を持ち上げてから畳み込むので、そうした光が見えるようになります。ただし、これは光源の本当の明るさを復元する処理ではなく、指定した倍率で光を足す処理です。
「ハイライト閾値」と「ハイライト強度」は、線形光がオンのときだけ働くので、オフのときは設定の画面に表示されません。素材は8ビットなので、光源の画素の値は1.0で頭打ちです。実際の光源はもっと明るいはずですが、その明るさは素材に残っていません。回折の筋のように中心よりはるかに小さい光は、そのままでは、出力の8ビットの1階調に届きません。ハイライト強度を上げると、明るい画素を持ち上げてから畳み込むので、そうした光が見えるようになります。ただし、これは光源の本当の明るさを復元する処理ではなく、指定した倍率で光を足す処理です。
持ち上げる倍率は、素材の画素ごとに決めます。画素の最も明るいチャンネルの値をmとします。半透明の画素では、素材の色を不透明度で割って元の色に戻した値を使います。しきい値をt、強さをsとすると、倍率は次の式で求めます。
@@ -236,15 +236,15 @@ e = (m - t) / (1 - t) を0〜1に打ち切った値
mがt以下の画素の倍率は1で、持ち上げません。mが1の画素の倍率は、強さsです。倍率は、色と不透明度のすべての成分に同じ値を掛けるので、色の比は変わりません。強さが1倍のときと、しきい値が100%のときは、持ち上げません。持ち上げた分の光が加わるので、出力の総和は素材の総和より大きくなります。明るさを元に戻すには、利得を下げてください。
ハイライトの効果を測りました。素材は、黒い背景の中央に、半径5画素の白い円を置いた映像です。F値16、画素ピッチ2μm、カーネル半径63画素、品質は標準、開口は6枚の羽根の正多角形で、ハイライトのしきい値は90%です。表の値は、出力の緑の成分を0〜255で表し、円の中心から25〜50画素離れた範囲で平均したものです。開口回転が0°のとき、点像分布関数は、中心から見て0°、60°、120°のように60°おきの向きへ、筋のように伸びます。筋の上は、この向きとの角度の差が3度以内の画素です。筋の間は、隣り合う筋の真ん中の向きとの角度の差が3度以内の画素です。
ハイライトの効果を測りました。素材は、黒い背景の中央に、半径5画素の白い円を置いた映像です。F値16、画素ピッチ2μm、カーネル半径63画素、品質は標準、開口は6枚の羽根の正多角形で、ハイライト閾値は90%です。表の値は、出力の緑の成分を0〜255で表し、円の中心から25〜50画素離れた範囲で平均したものです。開口回転が0°のとき、点像分布関数は、中心から見て0°、60°、120°のように60°おきの向きへ、筋のように伸びます。筋の上は、この向きとの角度の差が3度以内の画素です。筋の間は、隣り合う筋の真ん中の向きとの角度の差が3度以内の画素です。
| 設定 | 筋の上 | 筋の間 |
|---|---:|---:|
| 線形光とハイライトをオフ | 0.0 | 0.0 |
| 線形光とハイライトをオフ、利得400% | 1.0 | 0.0 |
| 線形光をオン | 2.7 | 0.0 |
| 線形光をオン、ハイライトの強さ30倍 | 41.5 | 3.7 |
| 線形光をオン、ハイライトの強さ300倍 | 130.8 | 24.2 |
| 線形光をオン、ハイライト強度30倍 | 41.5 | 3.7 |
| 線形光をオン、ハイライト強度300倍 | 130.8 | 24.2 |
出力は8ビットに丸めます。点のような小さな明るい部分では、広がった光のうちの小さな値が0に丸められて、出力の総和が素材より少なくなります。「ディザ」をオンにすると、丸める前の値に、0以上1未満の値を足してから、小数を切り捨てます。足す値は、画素の位置だけで決まります。小さな値は、その大きさに応じた確率で1として残るので、総和が保たれます。具体的には、計算領域の中の画素の位置を、整数のハッシュに通して求めます。1つの画素の赤、緑、青、不透明度には、同じ値を足します。そのため、丸めたあとも、色が不透明度を超えることはありません。同じ設定では、同じ画素に毎回同じ値を足すので、フレームが変わってもちらつきません。カーネル半径を変えると、計算領域の余白が変わるので、模様は動きます。値が0の黒と、値が255の白は、変わりません。
@@ -256,9 +256,9 @@ mがt以下の画素の倍率は1で、持ち上げません。mが1の画素の
| 4画素 | 96.0% | 100.1% |
| 8画素 | 97.9% | 100.0% |
「線形光」と「ハイライトのしきい値」と「ハイライトの強さ」を変えると、畳み込みを計算し直します。ただし、線形光がオフのときは、ハイライトの2項目を変えても、計算し直しません。線形光がオンでも、ハイライトの強さが1倍のときと、しきい値が100%のときは、持ち上げません。この場合、ハイライトの値の違いでは計算し直しません。利得とディザだけを変えたときは、「利得と適用量」で説明した保存した値から描き直します。
「線形光」と「ハイライト閾値」と「ハイライト強度」を変えると、畳み込みを計算し直します。ただし、線形光がオフのときは、ハイライトの2項目を変えても、計算し直しません。線形光がオンでも、ハイライト強度が1倍のときと、しきい値が100%のときは、持ち上げません。この場合、ハイライトの値の違いでは計算し直しません。利得とディザだけを変えたときは、「利得と適用量」で説明した保存した値から描き直します。
線形光をオンにすると、畳み込みは、変換した値に対して同じ手順で行います。そのため、誤差は、変換した値の2ノルムに比例します。ハイライトを持ち上げると2ノルムが大きくなり、誤差の上限も同じ割合で大きくなります。誤差の上限は、素材の値が0〜1のときの値です。上限は、「GPUの計算の検査とCPUの経路」と、[SpectralConvolution](SpectralConvolution/README.md)の説明にあります。実際の誤差は、上限よりはるかに小さいです。次の条件で測りました。素材は、黒い背景に半径2〜5画素の白い円を置いた映像です。カーネル半径は15画素と63画素、ハイライトの強さは1倍、10倍、100倍、1000倍です。無作為に選んだ1500か所の出力を、倍精度で直接足し合わせた値から求めた出力と比べました。GPUとCPUのどちらも、差は0階調でした。
線形光をオンにすると、畳み込みは、変換した値に対して同じ手順で行います。そのため、誤差は、変換した値の2ノルムに比例します。ハイライトを持ち上げると2ノルムが大きくなり、誤差の上限も同じ割合で大きくなります。誤差の上限は、素材の値が0〜1のときの値です。上限は、「GPUの計算の検査とCPUの経路」と、[SpectralConvolution](SpectralConvolution/README.md)の説明にあります。実際の誤差は、上限よりはるかに小さいです。次の条件で測りました。素材は、黒い背景に半径2〜5画素の白い円を置いた映像です。カーネル半径は15画素と63画素、ハイライト強度は1倍、10倍、100倍、1000倍です。無作為に選んだ1500か所の出力を、倍精度で直接足し合わせた値から求めた出力と比べました。GPUとCPUのどちらも、差は0階調でした。
線形光は、GPUの経路では、素材が変わるフレームの時間をほとんど増やしませんでした。CPUの経路では、素材を線形の値へ直す計算が増えて、時間が長くなりました。測った値は、「タイルごとの高速フーリエ変換による畳み込み」の計算時間の表にあります。
@@ -336,8 +336,8 @@ GPUの経路とCPUの経路の出力は、1ビット単位では一致しませ
| 適用量 | 数値 | 100% | 0〜100% | 対応 | 入力映像と、利得を掛けた結果を混ぜる割合です。0%では入力を変更しません。 |
| 利得 | 数値 | 100% | 0〜400% | 対応 | 畳み込んだ結果に掛ける倍率です。100%で、丸める前の値の総和を保ちます。 |
| 線形光 | 切り替え | オフ | オフ / オン | 非対応 | 画素の値を光の強さに比例する値へ直してから畳み込み、結果を画素の値へ戻します。 |
| ハイライトのしきい値 | 数値 | 95% | 0〜100% | 対応 | 線形光がオンのとき、素材の画素の最も明るいチャンネルがこの割合を超えると、持ち上げ始めます。 |
| ハイライトの強さ | 数値 | 1倍 | 1〜100倍 | 対応 | 線形光がオンのとき、最も明るい画素を持ち上げる倍率です。1倍では持ち上げません。直接入力では1000倍まで指定できます。 |
| ハイライト閾値 | 数値 | 95% | 0〜100% | 対応 | 線形光がオンのとき、素材の画素の最も明るいチャンネルがこの割合を超えると、持ち上げ始めます。 |
| ハイライト強度 | 数値 | 1倍 | 1〜100倍 | 対応 | 線形光がオンのとき、最も明るい画素を持ち上げる倍率です。1倍では持ち上げません。直接入力では1000倍まで指定できます。 |
| ディザ | 切り替え | オフ | オフ / オン | 非対応 | 8ビットに丸めるとき、画素の位置だけで決まる値を足します。 |
### 光学系グループ
+2 -2
ファイルの表示
@@ -339,8 +339,8 @@ GPU は、検査の材料を 1 つの `uint` のバッファー(`Report`)に
|---|---|
| `Linear` | 真なら、素材の値を線形の値へ直して畳み込み、結果を sRGB の値へ戻す |
| `Dither` | 真なら、出力を 8 ビットに丸めるとき、画素の位置で決まる 0 以上 1 未満の値を足してから切り捨てる |
| `Threshold` | ハイライトのしきい値 t。0 以上 1 以下 |
| `Boost` | ハイライトの強さ s。0 以上 1000 以下 |
| `Threshold` | ハイライト閾値 t。0 以上 1 以下 |
| `Boost` | ハイライト強度 s。0 以上 1000 以下 |
線形の値は、光の強さに比例する値です。`Linear` と `Dither` がどちらも偽の `default` が既定です。既定では、この節の処理は何も行わず、[CPU の経路](#3-cpu-の経路)と [GPU の経路](#4-gpu-の経路)の説明のとおりに動きます。ハイライトを持ち上げるのは、`Linear` が真で、s が 1 より大きく、t が 1 未満のときです。`LightOptions.Validate` は、t か s が範囲の外か有限でないと、`ArgumentOutOfRangeException` を投げます。
-3
ファイルの表示
@@ -85,9 +85,6 @@ internal sealed class ConvolutionScene
return new ConvolutionScene(source, margin, margin, sourceWidth, sourceHeight, spectrum, plan, light);
}
// The region starts at (regionX, regionY) of the canvas, and the source lies inside it at (sourceX, sourceY).
// The helpers that compare with the exact correlation assume a region at the origin, so a scene made
// here is only for comparing two implementations with each other.
public static ConvolutionScene CreateShifted(
byte[] source, int sourceX, int sourceY, int sourceWidth, int sourceHeight,
int regionX, int regionY, int regionWidth, int regionHeight, int radius, int size, LightOptions light = default)
+5 -6
ファイルの表示
@@ -362,10 +362,12 @@ public sealed class GpuTileConvolverTests
Assert.All(Measure(scene, run), measurement => Assert.True(measurement.Passes, $"{measurement}"));
}
const int OutputValuesPerToleratedRoundingFlip = 2000;
static void AssertOutputIsTheTransformOfTheStore(ConvolutionScene scene, GpuRun run, float gain, LightOptions light)
{
var width = scene.Plan.RegionWidth;
var differing = 0;
var roundingFlips = 0;
for (var y = 0; y < scene.Plan.RegionHeight; y++)
{
for (var x = 0; x < width; x++)
@@ -376,15 +378,12 @@ public sealed class GpuTileConvolverTests
Assert.InRange(run.Output[index + 1] - expected.Green, -1, 1);
Assert.InRange(run.Output[index + 2] - expected.Red, -1, 1);
Assert.InRange(run.Output[index + 3] - expected.Alpha, -1, 1);
differing += (run.Output[index] != expected.Blue ? 1 : 0) + (run.Output[index + 1] != expected.Green ? 1 : 0)
roundingFlips += (run.Output[index] != expected.Blue ? 1 : 0) + (run.Output[index + 1] != expected.Green ? 1 : 0)
+ (run.Output[index + 2] != expected.Red ? 1 : 0) + (run.Output[index + 3] != expected.Alpha ? 1 : 0);
}
}
// The power function of the GPU differs from the table of the CPU by a few millionths, which moves the
// rounded value by one step in a few of ten thousand places. A wrong threshold or a wrong rounding
// moves it in about a third of them.
Assert.InRange(differing, 0, run.Output.Length / 2000);
Assert.InRange(roundingFlips, 0, run.Output.Length / OutputValuesPerToleratedRoundingFlip);
}
[Theory]
+17
ファイルの表示
@@ -379,6 +379,23 @@ public sealed class LightTransformTests
Assert.InRange(worst, 0d, 1e-6);
}
[Fact]
public void DecodeStaysWithinAMillionthOfTheStandardCurve()
{
var first = BitConverter.SingleToInt32Bits(0.04045f) + 1;
var last = BitConverter.SingleToInt32Bits(1f) - 1;
var worst = 0d;
for (var bits = first; bits <= last; bits += 331)
{
var encoded = BitConverter.Int32BitsToSingle(bits);
var expected = ReferenceDecode(encoded);
worst = Math.Max(worst, Math.Abs(LightTransform.Decode(encoded) - expected) / expected);
}
Assert.InRange(worst, 0d, 1e-6);
}
[Fact]
public void EncodeIsExactAtTheJointsOfItsTable()
{
+23 -21
ファイルの表示
@@ -534,27 +534,7 @@ internal sealed class CpuTileConvolver : IDisposable
var distance = (nuint)(half * Channels);
if (allowWide && Vector256.IsHardwareAccelerated && half >= 2)
{
// Two neighboring positions of a block share one load. Every butterfly is the same
// arithmetic as the scalar form, so the results match it bit for bit.
for (var position = 0; position < half; position += 2)
{
var near = Unsafe.Add(ref table, position << shift);
var far = Unsafe.Add(ref table, (position + 1) << shift);
var nearImaginary = near.Y * direction;
var farImaginary = far.Y * direction;
var real = Vector256.Create(near.X, near.X, near.X, near.X, far.X, far.X, far.X, far.X);
var imaginary = Vector256.Create(-nearImaginary, nearImaginary, -nearImaginary, nearImaginary, -farImaginary, farImaginary, -farImaginary, farImaginary);
for (var block = 0; block < size; block += half * 2)
{
var even = (nuint)((block + position) * Channels);
var evenValue = Vector256.LoadUnsafe(ref data, even);
var oddValue = Vector256.LoadUnsafe(ref data, even + distance);
var product = oddValue * real + Vector256.Shuffle(oddValue, Vector256.Create(1, 0, 3, 2, 5, 4, 7, 6)) * imaginary;
(evenValue + product).StoreUnsafe(ref data, even);
(evenValue - product).StoreUnsafe(ref data, even + distance);
}
}
StageWithPairedTwiddles(ref data, ref table, size, half, shift, direction, distance);
continue;
}
@@ -577,6 +557,28 @@ internal sealed class CpuTileConvolver : IDisposable
}
}
static void StageWithPairedTwiddles(ref float data, ref Float2 table, int size, int half, int shift, float direction, nuint distance)
{
for (var position = 0; position < half; position += 2)
{
var near = Unsafe.Add(ref table, position << shift);
var far = Unsafe.Add(ref table, (position + 1) << shift);
var nearImaginary = near.Y * direction;
var farImaginary = far.Y * direction;
var real = Vector256.Create(near.X, near.X, near.X, near.X, far.X, far.X, far.X, far.X);
var imaginary = Vector256.Create(-nearImaginary, nearImaginary, -nearImaginary, nearImaginary, -farImaginary, farImaginary, -farImaginary, farImaginary);
for (var block = 0; block < size; block += half * 2)
{
var even = (nuint)((block + position) * Channels);
var evenValue = Vector256.LoadUnsafe(ref data, even);
var oddValue = Vector256.LoadUnsafe(ref data, even + distance);
var product = oddValue * real + Vector256.Shuffle(oddValue, Vector256.Create(1, 0, 3, 2, 5, 4, 7, 6)) * imaginary;
(evenValue + product).StoreUnsafe(ref data, even);
(evenValue - product).StoreUnsafe(ref data, even + distance);
}
}
}
internal static void ButterfliesScalar(Span<float> line, int log2, ReadOnlySpan<Float2> twiddles, float direction)
{
var pairs = 1 << (log2 - 1);
+22 -15
ファイルの表示
@@ -180,8 +180,7 @@ internal readonly partial struct ForwardRowLightShader(
var mask = size - 1;
var shift = 32 - log2Size;
// A group of 512 elements never lies in two tiles, so one division serves the whole group.
var tileIndex = batchStart + (groupBase >> (log2Size * 2));
var tileIndex = TileIndexOfGroup(groupBase);
var tileRow = tileIndex / tilesX;
var originX = regionX + (tileIndex - tileRow * tilesX) * validSize - radius;
var originY = regionY + tileRow * validSize - radius;
@@ -284,6 +283,11 @@ internal readonly partial struct ForwardRowLightShader(
return new Float4(linearRed * scale, linearGreen * scale, linearBlue * scale, scale);
}
private int TileIndexOfGroup(int groupBase)
{
return batchStart + (groupBase >> (log2Size * 2));
}
private void Butterflies(int local, float direction)
{
var halfSize = (int)(1u << (log2Size - 1));
@@ -389,16 +393,13 @@ internal readonly partial struct InverseRowLightShader(
Butterflies(local, -1f);
// A group of 512 elements never lies in two tiles, so one division serves the whole group. The
// samples buffer lists the sample positions first and then, one bit per tile, the tiles that hold a
// sample, so that only the threads of those tiles look for samples.
var tileIndex = batchStart + (groupBase >> (log2Size * 2));
var tileIndex = TileIndexOfGroup(groupBase);
var tileRow = tileIndex / tilesX;
var originX = (tileIndex - tileRow * tilesX) * validSize - radius;
var originY = tileRow * validSize - radius;
var sampled = sampleCount > 0 && IsSampled(tileIndex);
partial[local] = Emit(groupBase + element0, row[element0] * scale, size, mask, originX, originY, sampled)
+ Emit(groupBase + element1, row[element1] * scale, size, mask, originX, originY, sampled);
var tileHoldsSample = sampleCount > 0 && TileHoldsSample(tileIndex);
partial[local] = Emit(groupBase + element0, row[element0] * scale, size, mask, originX, originY, tileHoldsSample)
+ Emit(groupBase + element1, row[element1] * scale, size, mask, originX, originY, tileHoldsSample);
Hlsl.GroupMemoryBarrierWithGroupSync();
for (var stride = 128; stride > 0; stride >>= 1)
{
@@ -418,14 +419,20 @@ internal readonly partial struct InverseRowLightShader(
}
}
private bool IsSampled(int tileIndex)
private int TileIndexOfGroup(int groupBase)
{
var entry = samples[sampleTilesOffset + (tileIndex >> 6)];
var bits = (tileIndex & 32) == 0 ? (uint)entry.X : (uint)entry.Y;
return ((bits >> (tileIndex & 31)) & 1u) != 0u;
return batchStart + (groupBase >> (log2Size * 2));
}
private Float4 Emit(int flat, Float4 value, int size, int mask, int originX, int originY, bool sampled)
private bool TileHoldsSample(int tileIndex)
{
var word = tileIndex / GpuTileConvolver.SampleTilesPerWord;
var entry = samples[sampleTilesOffset + word / GpuTileConvolver.WordsPerSampleEntry];
var bits = word % GpuTileConvolver.WordsPerSampleEntry == 0 ? (uint)entry.X : (uint)entry.Y;
return ((bits >> (tileIndex % GpuTileConvolver.SampleTilesPerWord)) & 1u) != 0u;
}
private Float4 Emit(int flat, Float4 value, int size, int mask, int originX, int originY, bool tileHoldsSample)
{
if (IsNonFinite(value.X) || IsNonFinite(value.Y) || IsNonFinite(value.Z) || IsNonFinite(value.W))
Hlsl.InterlockedAdd(ref report[0], 1u);
@@ -444,7 +451,7 @@ internal readonly partial struct InverseRowLightShader(
output[new Int2(outputX, outputY)] = LightShaderOutput.Convert(value, gain, linear, dither, regionX + outputX, regionY + outputY);
if (storeValues != 0)
store[outputY * regionWidth + outputX] = value;
if (sampled)
if (tileHoldsSample)
{
for (var sample = 0; sample < sampleCount; sample++)
{
+8 -7
ファイルの表示
@@ -38,6 +38,8 @@ internal readonly record struct GpuTileJob(
internal sealed class GpuTileConvolver : IDisposable
{
public const int MaximumSamples = 16;
public const int SampleTilesPerWord = 32;
public const int WordsPerSampleEntry = 2;
readonly GraphicsDevice device;
readonly ReadWriteBuffer<Float4> spare;
@@ -158,11 +160,9 @@ internal sealed class GpuTileConvolver : IDisposable
return job;
}
// The samples buffer lists the sample positions, then one bit per tile, 64 tiles to an entry, that is set
// for the tiles holding a sample. The shaders look for samples only in those tiles.
void UploadSamples(ReadOnlySpan<Int2> sampleValues, in TilePlan plan)
{
var length = MaximumSamples + (plan.TileCount + 63) / 64;
var length = MaximumSamples + (plan.TileCount + SampleTilesPerWord * WordsPerSampleEntry - 1) / (SampleTilesPerWord * WordsPerSampleEntry);
if (samples.Length < length)
{
samples.Dispose();
@@ -177,11 +177,12 @@ internal sealed class GpuTileConvolver : IDisposable
foreach (var sample in sampleValues)
{
var tile = plan.TileAt(plan.RegionX + sample.X, plan.RegionY + sample.Y);
ref var entry = ref staging[MaximumSamples + (tile >> 6)];
if ((tile & 32) == 0)
entry.X |= 1 << (tile & 31);
var word = tile / SampleTilesPerWord;
ref var entry = ref staging[MaximumSamples + word / WordsPerSampleEntry];
if (word % WordsPerSampleEntry == 0)
entry.X |= 1 << (tile % SampleTilesPerWord);
else
entry.Y |= 1 << (tile & 31);
entry.Y |= 1 << (tile % SampleTilesPerWord);
}
samples.CopyFrom(staging);
+22 -15
ファイルの表示
@@ -157,8 +157,7 @@ internal readonly partial struct ForwardRowShader(
statistics[local] = 0u;
Hlsl.GroupMemoryBarrierWithGroupSync();
// A group of 512 elements never lies in two tiles, so one division serves the whole group.
var tileIndex = batchStart + (groupBase >> (log2Size * 2));
var tileIndex = TileIndexOfGroup(groupBase);
var tileRow = tileIndex / tilesX;
var originX = regionX + (tileIndex - tileRow * tilesX) * validSize - radius;
var originY = regionY + tileRow * validSize - radius;
@@ -220,6 +219,11 @@ internal readonly partial struct ForwardRowShader(
tiles[groupBase + local * 2 + 1] = row[local * 2 + 1];
}
private int TileIndexOfGroup(int groupBase)
{
return batchStart + (groupBase >> (log2Size * 2));
}
private void Butterflies(int local, float direction)
{
var halfSize = (int)(1u << (log2Size - 1));
@@ -411,16 +415,13 @@ internal readonly partial struct InverseRowShader(
Butterflies(local, -1f);
// A group of 512 elements never lies in two tiles, so one division serves the whole group. The
// samples buffer lists the sample positions first and then, one bit per tile, the tiles that hold a
// sample, so that only the threads of those tiles look for samples.
var tileIndex = batchStart + (groupBase >> (log2Size * 2));
var tileIndex = TileIndexOfGroup(groupBase);
var tileRow = tileIndex / tilesX;
var originX = (tileIndex - tileRow * tilesX) * validSize - radius;
var originY = tileRow * validSize - radius;
var sampled = sampleCount > 0 && IsSampled(tileIndex);
partial[local] = Emit(groupBase + element0, row[element0] * scale, size, mask, originX, originY, sampled)
+ Emit(groupBase + element1, row[element1] * scale, size, mask, originX, originY, sampled);
var tileHoldsSample = sampleCount > 0 && TileHoldsSample(tileIndex);
partial[local] = Emit(groupBase + element0, row[element0] * scale, size, mask, originX, originY, tileHoldsSample)
+ Emit(groupBase + element1, row[element1] * scale, size, mask, originX, originY, tileHoldsSample);
Hlsl.GroupMemoryBarrierWithGroupSync();
for (var stride = 128; stride > 0; stride >>= 1)
{
@@ -440,14 +441,20 @@ internal readonly partial struct InverseRowShader(
}
}
private bool IsSampled(int tileIndex)
private int TileIndexOfGroup(int groupBase)
{
var entry = samples[sampleTilesOffset + (tileIndex >> 6)];
var bits = (tileIndex & 32) == 0 ? (uint)entry.X : (uint)entry.Y;
return ((bits >> (tileIndex & 31)) & 1u) != 0u;
return batchStart + (groupBase >> (log2Size * 2));
}
private Float4 Emit(int flat, Float4 value, int size, int mask, int originX, int originY, bool sampled)
private bool TileHoldsSample(int tileIndex)
{
var word = tileIndex / GpuTileConvolver.SampleTilesPerWord;
var entry = samples[sampleTilesOffset + word / GpuTileConvolver.WordsPerSampleEntry];
var bits = word % GpuTileConvolver.WordsPerSampleEntry == 0 ? (uint)entry.X : (uint)entry.Y;
return ((bits >> (tileIndex % GpuTileConvolver.SampleTilesPerWord)) & 1u) != 0u;
}
private Float4 Emit(int flat, Float4 value, int size, int mask, int originX, int originY, bool tileHoldsSample)
{
if (IsNonFinite(value.X) || IsNonFinite(value.Y) || IsNonFinite(value.Z) || IsNonFinite(value.W))
Hlsl.InterlockedAdd(ref report[0], 1u);
@@ -466,7 +473,7 @@ internal readonly partial struct InverseRowShader(
output[new Int2(outputX, outputY)] = value * gain;
if (storeValues != 0)
store[outputY * regionWidth + outputX] = value;
if (sampled)
if (tileHoldsSample)
{
for (var sample = 0; sample < sampleCount; sample++)
{
+18 -23
ファイルの表示
@@ -15,19 +15,19 @@ internal static class LightTransform
public const float DecodeExponent = 2.4f;
public const float EncodeExponent = 0.41666666f;
// Encode and Decode read tables of value and slope pairs and interpolate between the entries, because
// the power function costs more than everything else the CPU does for one pixel. The tables are
// indexed by the bits of the float that is converted, so the steps are as fine in the darks as in the
// brights. Encode has 256 steps per power of two from 2^-9 up to 1, and its relative error stays
// below 5e-7. Decode has 1024 steps per power of two from 2^-4 up to 1, with the same error.
// That is as large as the error of the power function on the GPU, and about 30 times smaller than
// the error the checks allow.
const int EncodeFractionBits = 15;
const int EncodeFirstStep = 0x3B000000 >> EncodeFractionBits;
const int EncodeSteps = (0x3F800000 >> EncodeFractionBits) - EncodeFirstStep;
const int DecodeFractionBits = 13;
const int DecodeFirstStep = 0x3D800000 >> DecodeFractionBits;
const int DecodeSteps = (0x3F800000 >> DecodeFractionBits) - DecodeFirstStep;
const int MantissaBits = 23;
const int ExponentBias = 127;
const int OneBits = ExponentBias << MantissaBits;
const int EncodeStepsPerOctaveLog2 = 8;
const int EncodeFirstOctave = -9;
const int EncodeFractionBits = MantissaBits - EncodeStepsPerOctaveLog2;
const int EncodeFirstStep = ((ExponentBias + EncodeFirstOctave) << MantissaBits) >> EncodeFractionBits;
const int EncodeSteps = (OneBits >> EncodeFractionBits) - EncodeFirstStep;
const int DecodeStepsPerOctaveLog2 = 10;
const int DecodeFirstOctave = -4;
const int DecodeFractionBits = MantissaBits - DecodeStepsPerOctaveLog2;
const int DecodeFirstStep = ((ExponentBias + DecodeFirstOctave) << MantissaBits) >> DecodeFractionBits;
const int DecodeSteps = (OneBits >> DecodeFractionBits) - DecodeFirstStep;
const float EncodeFractionScale = 1f / (1 << EncodeFractionBits);
const float DecodeFractionScale = 1f / (1 << DecodeFractionBits);
@@ -147,19 +147,14 @@ internal static class LightTransform
outputAlpha = Saturate(alpha * gain);
}
// One threshold serves the four values of a pixel. Rounding is monotonic for a shared threshold, so a
// color that does not exceed the opacity before rounding does not exceed it after rounding either.
var threshold = options.Dither ? DitherThreshold(x, y) : 0f;
var thresholdSharedByChannels = options.Dither ? DitherThreshold(x, y) : 0f;
return (
Quantize(outputBlue, options.Dither, threshold),
Quantize(outputGreen, options.Dither, threshold),
Quantize(outputRed, options.Dither, threshold),
Quantize(outputAlpha, options.Dither, threshold));
Quantize(outputBlue, options.Dither, thresholdSharedByChannels),
Quantize(outputGreen, options.Dither, thresholdSharedByChannels),
Quantize(outputRed, options.Dither, thresholdSharedByChannels),
Quantize(outputAlpha, options.Dither, thresholdSharedByChannels));
}
// The same conversion as ToBytes for one pixel held in a vector (red, green, blue, alpha), returned as
// the four bytes (blue, green, red, alpha). Every step is the same IEEE operation in the same order,
// so the bytes are the ones ToBytes returns.
public static uint ToPacked(Vector128<float> value, float gain, in LightOptions options, int x, int y)
{
var saturated = Saturate(value * Vector128.Create(gain));
+4 -6
ファイルの表示
@@ -249,11 +249,11 @@ static int Convolution(HarnessImage image)
return subject;
}
void Measure(string title, Func<(string Name, Action<bool> Run)[]> create)
void MeasureSet(string title, Func<(string Name, Action<bool> Run)[]> createOwnedSubjects)
{
try
{
var variants = create();
var variants = createOwnedSubjects();
var samples = new List<double>[variants.Length];
for (var index = 0; index < samples.Length; index++)
samples[index] = new List<double>(Rounds);
@@ -303,9 +303,7 @@ static int Convolution(HarnessImage image)
Console.WriteLine($"convolution recompute at {image.Width}x{image.Height} over {Rounds} interleaved rounds (ms)");
// Each set owns its pipelines while it runs. Keeping the pipelines of the other set alive would
// change the memory the GPU has left and slow every row down.
Measure("default options", () =>
MeasureSet("default options", () =>
{
var cached = Gpu();
var gain = Gpu();
@@ -336,7 +334,7 @@ static int Convolution(HarnessImage image)
var linearLight = new SpectralConvolution.LightOptions(true, false, 0f, 0f);
var highlightLight = new SpectralConvolution.LightOptions(true, false, 0.7f, 30f);
Measure("light options", () =>
MeasureSet("light options", () =>
{
var source = Gpu();
var checkedSource = Gpu(true);
+4 -6
ファイルの表示
@@ -345,12 +345,10 @@ public sealed class WaveOpticsLightTests
var dithered = parameters with { Light = new LightOptions(false, true, 0f, 0f) };
var reference = Total(source);
var plain = Total(RenderCpu(source, Size, Size, in parameters)) / reference;
var kept = Total(RenderCpu(source, Size, Size, in dithered)) / reference;
var retainedWithoutDither = Total(RenderCpu(source, Size, Size, in parameters)) / reference;
var retainedWithDither = Total(RenderCpu(source, Size, Size, in dithered)) / reference;
// Each rounding error is about 0.3 of a level, and the sum of the 40000 errors is a few percent of
// the light of the spot at most. Without dithering, the faint tails are rounded down to nothing.
Assert.InRange(plain, 0.88, 0.97);
Assert.InRange(kept, 0.97, 1.03);
Assert.InRange(retainedWithoutDither, 0.88, 0.97);
Assert.InRange(retainedWithDither, 0.97, 1.03);
}
}
+121
ファイルの表示
@@ -0,0 +1,121 @@
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Reflection;
using System.Windows;
using SpectralConvolution;
using WaveOptics.Effects;
using WaveOptics.Rendering;
using YukkuriMovieMaker.ItemEditor;
namespace WaveOptics.Tests;
public sealed class WaveOpticsVisibilityTests
{
const int Width = 96;
const int Height = 96;
const int Black = unchecked((int)0xFF000000);
const int White = unchecked((int)0xFFFFFFFF);
const int Gray = unchecked((int)0xFFCCCCCC);
sealed record Setting(
float Gain, WaveOpticsQuality Quality, int KernelRadius, float Wavelength, float FNumber, float PixelPitch,
WaveOpticsApertureShape Shape, int Blades, float Rotation, float Obstruction,
float Defocus, float AstigmatismVertical, float AstigmatismOblique, float ComaHorizontal, float ComaVertical, float Spherical,
bool Linear, bool Dither, float Threshold, float Boost);
static readonly Dictionary<string, Func<Setting, Setting>> Variants = new()
{
[nameof(WaveOpticsEffect.Gain)] = s => s with { Gain = 2f },
[nameof(WaveOpticsEffect.Linear)] = s => s with { Linear = !s.Linear },
[nameof(WaveOpticsEffect.HighlightThreshold)] = s => s with { Threshold = 0.5f },
[nameof(WaveOpticsEffect.HighlightBoost)] = s => s with { Boost = 10f },
[nameof(WaveOpticsEffect.Dither)] = s => s with { Dither = true },
[nameof(WaveOpticsEffect.Wavelength)] = s => s with { Wavelength = 650f },
[nameof(WaveOpticsEffect.FNumber)] = s => s with { FNumber = 20f },
[nameof(WaveOpticsEffect.PixelPitch)] = s => s with { PixelPitch = 2.5f },
[nameof(WaveOpticsEffect.KernelRadius)] = s => s with { KernelRadius = 20 },
[nameof(WaveOpticsEffect.Quality)] = s => s with { Quality = WaveOpticsQuality.High },
[nameof(WaveOpticsEffect.ApertureShape)] = s => s with { Shape = s.Shape == WaveOpticsApertureShape.Circular ? WaveOpticsApertureShape.RegularPolygon : WaveOpticsApertureShape.Circular },
[nameof(WaveOpticsEffect.BladeCount)] = s => s with { Blades = 8 },
[nameof(WaveOpticsEffect.BladeRotation)] = s => s with { Rotation = 30f },
[nameof(WaveOpticsEffect.Obstruction)] = s => s with { Obstruction = 0.3f },
[nameof(WaveOpticsEffect.Defocus)] = s => s with { Defocus = 0.5f },
[nameof(WaveOpticsEffect.AstigmatismVertical)] = s => s with { AstigmatismVertical = 0.5f },
[nameof(WaveOpticsEffect.AstigmatismOblique)] = s => s with { AstigmatismOblique = 0.5f },
[nameof(WaveOpticsEffect.ComaHorizontal)] = s => s with { ComaHorizontal = 0.5f },
[nameof(WaveOpticsEffect.ComaVertical)] = s => s with { ComaVertical = 0.5f },
[nameof(WaveOpticsEffect.Spherical)] = s => s with { Spherical = 0.5f },
};
static IEnumerable<PropertyInfo> ParameterProperties
=> typeof(WaveOpticsEffect).GetProperties().Where(property => property.GetCustomAttribute<DisplayAttribute>() is not null);
static int[] Scene()
{
var pixels = new int[Width * Height];
Array.Fill(pixels, Black);
pixels[Height / 2 * Width + Width / 2] = White;
for (var y = 20; y < 26; y++)
{
for (var x = 20; x < 26; x++)
pixels[y * Width + x] = Gray;
}
return pixels;
}
static int[] Render(Setting setting)
{
var parameters = new WaveOpticsPipeline.Parameters(
setting.Gain,
new WaveOpticsPipeline.PsfParameters(
setting.Quality, setting.KernelRadius, setting.Wavelength, setting.FNumber, setting.PixelPitch, setting.Shape, setting.Blades,
setting.Rotation, setting.Obstruction, setting.Defocus, setting.AstigmatismVertical, setting.AstigmatismOblique,
setting.ComaHorizontal, setting.ComaVertical, setting.Spherical),
new LightOptions(setting.Linear, setting.Dither, setting.Threshold, setting.Boost));
var source = Scene();
var destination = new int[source.Length];
using var pipeline = new WaveOpticsCpuPipeline(2);
pipeline.Process(source, destination, Width, Height, in parameters);
return destination;
}
static bool IsVisible(WaveOpticsEffect effect, string name)
{
var attribute = typeof(WaveOpticsEffect).GetProperty(name)!.GetCustomAttributes().OfType<ICustomVisibilityAttribute2>().SingleOrDefault();
if (attribute is null)
return true;
var binding = attribute.GetBinding(effect, effect);
var value = typeof(WaveOpticsEffect).GetProperty(binding.Path.Path)!.GetValue(binding.Source);
return (Visibility)binding.Converter.Convert(value, typeof(Visibility), null!, CultureInfo.InvariantCulture) == Visibility.Visible;
}
[Fact]
public void EveryParameterExceptAmountHasAVariantToTest()
{
var names = ParameterProperties.Select(property => property.Name).Where(name => name != nameof(WaveOpticsEffect.Amount)).Order().ToArray();
Assert.Equal(Variants.Keys.Order().ToArray(), names);
}
[Theory]
[InlineData(WaveOpticsApertureShape.Circular, false)]
[InlineData(WaveOpticsApertureShape.Circular, true)]
[InlineData(WaveOpticsApertureShape.RegularPolygon, false)]
[InlineData(WaveOpticsApertureShape.RegularPolygon, true)]
public void AParameterIsShownExactlyWhenChangingItChangesTheOutput(WaveOpticsApertureShape shape, bool linear)
{
var effect = new WaveOpticsEffect { ApertureShape = shape, Linear = linear };
var baseline = new Setting(
1f, WaveOpticsQuality.Standard, 31, 550f, 16f, 2f, shape, 6, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, linear, false, 0.9f, 30f);
var reference = Render(baseline);
foreach (var (name, variant) in Variants)
{
var changes = !reference.AsSpan().SequenceEqual(Render(variant(baseline)));
Assert.True(changes == IsVisible(effect, name), $"{name}: changes the output = {changes}, shown = {IsVisible(effect, name)}, shape = {shape}, linear = {linear}");
}
}
}
+2 -2
ファイルの表示
@@ -50,9 +50,9 @@ TagOptics,,光学,optics,光学,光學,광학,óptica,البصريات,optik
UpdateAvailableMessage,,新しいバージョン {0} が公開されています。,A new version {0} is available.,新版本 {0} 已发布。,新版本 {0} 已發布。,새 버전 {0}이(가) 공개되었습니다.,La nueva versión {0} ya está disponible.,تم إصدار نسخة جديدة {0}.,Versi baru {0} telah dirilis.
Linear,,線形光,Linear Light,线性光,線性光,선형 광,Luz lineal,الضوء الخطي,Cahaya Linear
LinearDescription,,畳み込みの前に画素の値を光の強さに比例する値へ直し、結果を表示用の値へ戻します。,"Converts pixel values to values proportional to light intensity before the convolution, and converts the result back for display.",在卷积前将像素值转换为与光强成正比的值,并将结果转换回显示值。,在卷積前將像素值轉換為與光強成正比的值,並將結果轉換回顯示值。,"컨볼루션 전에 픽셀 값을 빛의 세기에 비례하는 값으로 변환하고, 결과를 표시용 값으로 되돌립니다.",Convierte los valores de píxel en valores proporcionales a la intensidad de la luz antes de la convolución y devuelve el resultado a valores de visualización.,يحوّل قيم البكسل إلى قيم تتناسب مع شدة الضوء قبل الالتفاف، ثم يعيد النتيجة إلى قيم العرض.,"Mengubah nilai piksel menjadi nilai yang sebanding dengan intensitas cahaya sebelum konvolusi, lalu mengembalikan hasilnya ke nilai tampilan."
HighlightThreshold,,ハイライトのしきい値,Highlight Threshold,高光阈值,高光閾值,하이라이트 임계값,Umbral de altas luces,عتبة الإضاءة العالية,Ambang Sorotan
HighlightThreshold,,ハイライト閾値,Highlight Threshold,高光阈值,高光閾值,하이라이트 임계값,Umbral de altas luces,عتبة الإضاءة العالية,Ambang Sorotan
HighlightThresholdDescription,,線形光のとき、画素の最も明るいチャンネルがこの割合を超えると、ハイライトの持ち上げを始めます。,"In linear light, highlight boosting starts when the brightest channel of a pixel exceeds this level.",在线性光下,当像素最亮的通道超过此比例时,开始提升高光。,在線性光下,當像素最亮的通道超過此比例時,開始提升高光。,선형 광에서 픽셀의 가장 밝은 채널이 이 비율을 넘으면 하이라이트를 끌어올리기 시작합니다.,"En luz lineal, el realce de las altas luces comienza cuando el canal más brillante de un píxel supera este nivel.",في الضوء الخطي، يبدأ تعزيز الإضاءة العالية عندما تتجاوز أسطع قناة في البكسل هذا المستوى.,"Pada cahaya linear, peningkatan sorotan dimulai saat kanal paling terang suatu piksel melebihi tingkat ini."
HighlightBoost,,ハイライトの強さ,Highlight Boost,高光强度,高光強度,하이라이트 강도,Intensidad de altas luces,شدة الإضاءة العالية,Intensitas Sorotan
HighlightBoost,,ハイライト強度,Highlight Boost,高光强度,高光強度,하이라이트 강도,Intensidad de altas luces,شدة الإضاءة العالية,Intensitas Sorotan
HighlightBoostDescription,,線形光のとき、しきい値を超えた画素の明るさを最大で何倍に持ち上げるかを指定します。1倍では持ち上げません。,"In linear light, sets the maximum factor by which pixels above the threshold are brightened. 1x applies no boost.",在线性光下,设置超过阈值的像素亮度最多提升的倍数。1倍时不提升。,在線性光下,設定超過閾值的像素亮度最多提升的倍數。1倍時不提升。,선형 광에서 임계값을 넘은 픽셀의 밝기를 최대 몇 배로 끌어올릴지 설정합니다. 1배에서는 끌어올리지 않습니다.,"En luz lineal, establece el factor máximo por el que se aclaran los píxeles por encima del umbral. Con 1x no se aplica realce.",في الضوء الخطي، يضبط أقصى عامل يتم به تفتيح البكسلات التي تتجاوز العتبة. عند 1x لا يُطبَّق أي تعزيز.,"Pada cahaya linear, mengatur faktor maksimum untuk mencerahkan piksel di atas ambang. Pada 1x tidak ada peningkatan."
Dither,,ディザ,Dither,抖动,抖動,디더,Tramado,التنقيط,Dither
DitherDescription,,出力を8ビットに丸めるとき、画素の位置だけで決まる揺らぎを加えます。段差が目立たなくなり、淡い光が失われにくくなります。,Adds a variation that depends only on pixel position when rounding the output to 8 bits. This hides banding and keeps faint light from being lost.,将输出舍入为8位时,加入仅由像素位置决定的扰动。这能减轻色阶断层,并避免微弱的光丢失。,將輸出捨入為8位元時,加入僅由像素位置決定的擾動。這能減輕色階斷層,並避免微弱的光流失。,출력을 8비트로 반올림할 때 픽셀 위치로만 결정되는 흔들림을 더합니다. 계조의 단차가 눈에 덜 띄고 옅은 빛이 사라지지 않습니다.,Añade una variación que depende solo de la posición del píxel al redondear la salida a 8 bits. Oculta el bandeo y evita que se pierda la luz tenue.,يضيف تغييرًا يعتمد على موضع البكسل فقط عند تقريب المخرجات إلى 8 بت. يخفي ذلك تدرج النطاقات ويمنع فقدان الضوء الخافت.,Menambahkan variasi yang hanya bergantung pada posisi piksel saat membulatkan keluaran ke 8 bit. Ini menyamarkan pita warna dan mencegah cahaya redup hilang.
1 Key Parameter ja-jp en-us zh-cn zh-tw ko-kr es-es ar-sa id-id
50 UpdateAvailableMessage 新しいバージョン {0} が公開されています。 A new version {0} is available. 新版本 {0} 已发布。 新版本 {0} 已發布。 새 버전 {0}이(가) 공개되었습니다. La nueva versión {0} ya está disponible. تم إصدار نسخة جديدة {0}. Versi baru {0} telah dirilis.
51 Linear 線形光 Linear Light 线性光 線性光 선형 광 Luz lineal الضوء الخطي Cahaya Linear
52 LinearDescription 畳み込みの前に画素の値を光の強さに比例する値へ直し、結果を表示用の値へ戻します。 Converts pixel values to values proportional to light intensity before the convolution, and converts the result back for display. 在卷积前将像素值转换为与光强成正比的值,并将结果转换回显示值。 在卷積前將像素值轉換為與光強成正比的值,並將結果轉換回顯示值。 컨볼루션 전에 픽셀 값을 빛의 세기에 비례하는 값으로 변환하고, 결과를 표시용 값으로 되돌립니다. Convierte los valores de píxel en valores proporcionales a la intensidad de la luz antes de la convolución y devuelve el resultado a valores de visualización. يحوّل قيم البكسل إلى قيم تتناسب مع شدة الضوء قبل الالتفاف، ثم يعيد النتيجة إلى قيم العرض. Mengubah nilai piksel menjadi nilai yang sebanding dengan intensitas cahaya sebelum konvolusi, lalu mengembalikan hasilnya ke nilai tampilan.
53 HighlightThreshold ハイライトのしきい値 ハイライト閾値 Highlight Threshold 高光阈值 高光閾值 하이라이트 임계값 Umbral de altas luces عتبة الإضاءة العالية Ambang Sorotan
54 HighlightThresholdDescription 線形光のとき、画素の最も明るいチャンネルがこの割合を超えると、ハイライトの持ち上げを始めます。 In linear light, highlight boosting starts when the brightest channel of a pixel exceeds this level. 在线性光下,当像素最亮的通道超过此比例时,开始提升高光。 在線性光下,當像素最亮的通道超過此比例時,開始提升高光。 선형 광에서 픽셀의 가장 밝은 채널이 이 비율을 넘으면 하이라이트를 끌어올리기 시작합니다. En luz lineal, el realce de las altas luces comienza cuando el canal más brillante de un píxel supera este nivel. في الضوء الخطي، يبدأ تعزيز الإضاءة العالية عندما تتجاوز أسطع قناة في البكسل هذا المستوى. Pada cahaya linear, peningkatan sorotan dimulai saat kanal paling terang suatu piksel melebihi tingkat ini.
55 HighlightBoost ハイライトの強さ ハイライト強度 Highlight Boost 高光强度 高光強度 하이라이트 강도 Intensidad de altas luces شدة الإضاءة العالية Intensitas Sorotan
56 HighlightBoostDescription 線形光のとき、しきい値を超えた画素の明るさを最大で何倍に持ち上げるかを指定します。1倍では持ち上げません。 In linear light, sets the maximum factor by which pixels above the threshold are brightened. 1x applies no boost. 在线性光下,设置超过阈值的像素亮度最多提升的倍数。1倍时不提升。 在線性光下,設定超過閾值的像素亮度最多提升的倍數。1倍時不提升。 선형 광에서 임계값을 넘은 픽셀의 밝기를 최대 몇 배로 끌어올릴지 설정합니다. 1배에서는 끌어올리지 않습니다. En luz lineal, establece el factor máximo por el que se aclaran los píxeles por encima del umbral. Con 1x no se aplica realce. في الضوء الخطي، يضبط أقصى عامل يتم به تفتيح البكسلات التي تتجاوز العتبة. عند 1x لا يُطبَّق أي تعزيز. Pada cahaya linear, mengatur faktor maksimum untuk mencerahkan piksel di atas ambang. Pada 1x tidak ada peningkatan.
57 Dither ディザ Dither 抖动 抖動 디더 Tramado التنقيط Dither
58 DitherDescription 出力を8ビットに丸めるとき、画素の位置だけで決まる揺らぎを加えます。段差が目立たなくなり、淡い光が失われにくくなります。 Adds a variation that depends only on pixel position when rounding the output to 8 bits. This hides banding and keeps faint light from being lost. 将输出舍入为8位时,加入仅由像素位置决定的扰动。这能减轻色阶断层,并避免微弱的光丢失。 將輸出捨入為8位元時,加入僅由像素位置決定的擾動。這能減輕色階斷層,並避免微弱的光流失。 출력을 8비트로 반올림할 때 픽셀 위치로만 결정되는 흔들림을 더합니다. 계조의 단차가 눈에 덜 띄고 옅은 빛이 사라지지 않습니다. Añade una variación que depende solo de la posición del píxel al redondear la salida a 8 bits. Oculta el bandeo y evita que se pierda la luz tenue. يضيف تغييرًا يعتمد على موضع البكسل فقط عند تقريب المخرجات إلى 8 بت. يخفي ذلك تدرج النطاقات ويمنع فقدان الضوء الخافت. Menambahkan variasi yang hanya bergantung pada posisi piksel saat membulatkan keluaran ke 8 bit. Ini menyamarkan pita warna dan mencegah cahaya redup hilang.
+4
ファイルの表示
@@ -33,10 +33,12 @@ public sealed class WaveOpticsEffect : VideoEffectBase
private bool _linear;
[Display(GroupName = nameof(Texts.OutputGroup), Name = nameof(Texts.HighlightThreshold), Description = nameof(Texts.HighlightThresholdDescription), Order = 3, ResourceType = typeof(Texts))]
[LinearLightVisible]
[AnimationSlider("F1", "%", 0, 100)]
public Animation HighlightThreshold { get; } = new(95, 0, 100);
[Display(GroupName = nameof(Texts.OutputGroup), Name = nameof(Texts.HighlightBoost), Description = nameof(Texts.HighlightBoostDescription), Order = 4, ResourceType = typeof(Texts))]
[LinearLightVisible]
[AnimationSlider("F1", "x", 1, 100)]
public Animation HighlightBoost { get; } = new(1, 1, 1000);
@@ -75,6 +77,7 @@ public sealed class WaveOpticsEffect : VideoEffectBase
private WaveOpticsApertureShape _apertureShape;
[Display(GroupName = nameof(Texts.ApertureGroup), Name = nameof(Texts.BladeCount), Description = nameof(Texts.BladeCountDescription), Order = 21, ResourceType = typeof(Texts))]
[PolygonApertureVisible]
[TextBoxSlider("F0", "", 3, 16)]
[Range(3, 32)]
[DefaultValue(6)]
@@ -82,6 +85,7 @@ public sealed class WaveOpticsEffect : VideoEffectBase
private int _bladeCount = 6;
[Display(GroupName = nameof(Texts.ApertureGroup), Name = nameof(Texts.BladeRotation), Description = nameof(Texts.BladeRotationDescription), Order = 22, ResourceType = typeof(Texts))]
[PolygonApertureVisible]
[AnimationSlider("F1", "°", -180, 180)]
public Animation BladeRotation { get; } = new(0, -360, 360);
+35
ファイルの表示
@@ -0,0 +1,35 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using YukkuriMovieMaker.ItemEditor;
namespace WaveOptics.Effects;
[AttributeUsage(AttributeTargets.Property)]
internal sealed class PolygonApertureVisibleAttribute : Attribute, ICustomVisibilityAttribute2
{
public Binding GetBinding(object item, object propertyOwner) => new(nameof(WaveOpticsEffect.ApertureShape))
{
Source = item,
Converter = new VisibilityConverter(value => value is WaveOpticsApertureShape.RegularPolygon)
};
}
[AttributeUsage(AttributeTargets.Property)]
internal sealed class LinearLightVisibleAttribute : Attribute, ICustomVisibilityAttribute2
{
public Binding GetBinding(object item, object propertyOwner) => new(nameof(WaveOpticsEffect.Linear))
{
Source = item,
Converter = new VisibilityConverter(value => value is true)
};
}
internal sealed class VisibilityConverter(Func<object?, bool> isVisible) : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> isVisible(value) ? Visibility.Visible : Visibility.Collapsed;
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
-2
ファイルの表示
@@ -64,8 +64,6 @@ internal readonly record struct WaveOpticsSourceHash(int LitCount, int MinimumX,
return new WaveOpticsSourceHash(count, minimumX, minimumY, maximumX, maximumY, sum, mix);
}
// The same sums as the scalar form: eight pixels at a time, with the unlit ones masked out. Both sums
// do not depend on the order of the pixels, so the result is the same, bit for bit.
internal static WaveOpticsSourceHash ComputeVector(ReadOnlySpan<byte> bgra, int sourceX, int sourceY, int sourceWidth, int sourceHeight)
{
var pixels = MemoryMarshal.Cast<byte, uint>(bgra[..(sourceWidth * sourceHeight * 4)]);
+1 -1
ファイルの表示
@@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<AssemblyName>WaveOptics</AssemblyName>
<RootNamespace>WaveOptics</RootNamespace>
<Version>3.1.0</Version>
<Version>3.2.0</Version>
<Platforms>AnyCPU;x64</Platforms>
<PlatformTarget>x64</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>