コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
5d55f2c083
|
||
|
|
09918c2858
|
||
|
|
a687bba0ff
|
||
|
|
bb591b6fef
|
||
|
|
27d7294290
|
||
|
|
8d1cf91499
|
||
|
|
b2a1900616
|
||
|
|
f786250866
|
||
|
|
20dfba6e7e
|
||
|
|
5e40f45910
|
||
|
|
ea4f096bc4
|
||
|
|
d7812f39dc
|
||
|
|
77fdf60ec9
|
||
|
|
bcb9925953
|
||
|
|
ec7d8a1da4
|
||
|
|
098d6e498b
|
||
|
|
ccf37dd1d3
|
||
|
|
2ce3068d54
|
||
|
|
c2a1990501
|
||
|
|
4ac25584b9
|
||
|
|
5e40f30124
|
||
|
|
9d541e06b9
|
||
|
|
bca7b5707e
|
||
|
|
a17289a2da
|
||
|
|
71e6b71056
|
||
|
|
13a0602adb
|
||
|
|
6a0c993755
|
||
|
|
484a26ec45
|
||
|
|
a121a598b6
|
||
|
|
6dd70413a9
|
||
|
|
ac482b6041
|
||
|
|
c2761c0796
|
||
|
|
3bbd411d86
|
||
|
|
324faabb96
|
||
|
|
32b706cb8b
|
||
|
|
aa97c52b38
|
||
|
|
a2f0231739
|
||
|
|
2905192d3a
|
||
|
|
ee6f6bd9c1
|
||
|
|
8853f5e403
|
||
|
|
867de7aa73
|
||
|
|
e384d7e490
|
||
|
|
87e060d71d
|
||
|
|
9c6167d224
|
||
|
|
a8a91103e1
|
||
|
|
4a2f4b2dbb
|
||
|
|
33fc45639b
|
||
|
|
7af803e46e
|
||
|
|
48e8287704
|
||
|
|
7eff4591f0
|
||
|
|
5b1bb4ad6e
|
||
|
|
7f3e6b0019
|
||
|
|
7519a11851
|
||
|
|
4193c40f41
|
||
|
|
cd68bf86b0
|
||
|
|
9948204265
|
||
|
|
25670bde90
|
||
|
|
ae230c0e10
|
||
|
|
7ee8f1ccf0
|
||
|
|
da88898a67
|
||
|
|
3c63ba0729
|
||
|
|
e7382ac289
|
||
|
|
ee7e4f43bc
|
||
|
|
7dc6e9fb40
|
||
|
|
803534d804
|
||
|
|
a25803fa30
|
||
|
|
e42401670f
|
||
|
|
a139326c39
|
||
|
|
496c237f50
|
||
|
|
dfbcbded98
|
||
|
|
2ebbe3ced0
|
||
|
|
9671cba5a1
|
||
|
|
947532f064
|
||
|
|
6e3594eb01
|
||
|
|
abc7b2cde2
|
||
|
|
68d862ded0
|
||
|
|
d3060fd202
|
||
|
|
1d92d80a86
|
||
|
|
86ad19105f
|
||
|
|
2cd5ab273a
|
||
|
|
d75aeee3c2
|
||
|
|
981fb2ceeb
|
||
|
|
01a0dcb9ae
|
||
|
|
460b5e6252
|
||
|
|
fb02580836
|
||
|
|
58a5f59b19
|
||
|
|
95598b1a88
|
||
|
|
7f436ebe17
|
||
|
|
d620f7ea3b
|
||
|
|
ad377a0923
|
||
|
|
f374038000
|
||
|
|
ddba8d63c2
|
||
|
|
ab2e195139
|
||
|
|
85c585db89
|
||
|
|
93eb681b0e
|
||
|
|
30ca75f65e
|
||
|
|
a07916de6b
|
||
|
|
467a4b0dd8
|
||
|
|
03aad4cc6e
|
||
|
|
b638c7b9c2
|
||
|
|
ede56971cd
|
||
|
|
94c11dffcb
|
||
|
|
28c1f70fa1
|
||
|
|
2ecde28980
|
||
|
|
1c2c3915e9
|
検索条件に一致するファイルはありません
+53
-26
@@ -1,44 +1,71 @@
|
||||
# v1.9.4 - Lua スクリプト for YMM4
|
||||
# v1.11.2 - Lua スクリプト for YMM4
|
||||
|
||||
v1.9.3 で追加した AviUtl/AviUtl2 互換マップによる `obj.effect` の解決を見直したリリース
|
||||
です。v1.9.3 では `obj.effect` を互換マップ駆動へ置き換えた結果、互換マップに宣言の無い
|
||||
名前が解決されなくなっていました。本リリースでは解決を二段階方式にし、互換マップを優先しつつ、
|
||||
宣言の無い名前は従来どおり YMM4 のエフェクト名・キーワードで直接解決するように戻しました。
|
||||
あわせて互換マップの読み込みを例外安全にし、退避の経路を段階的に整理しました。
|
||||
`tempbuffer` への描画合成を GPU 実行へ置き換えたリリースです。MoonSharp エンジンで
|
||||
`obj.draw` / `obj.drawpoly` が `tempbuffer` へ行う合成を、CPU のピクセルループから
|
||||
Direct2D による GPU 合成へ変更しました。GPU を利用できない環境では従来の CPU 合成へ
|
||||
自動的に切り替わります。あわせて、描画合成の変換行列の計算を一元化し、合成レーンの
|
||||
ユニットテストを追加しました。
|
||||
|
||||
---
|
||||
|
||||
## 新機能・機能改善
|
||||
|
||||
### 1. obj.effect の解決を二段階化
|
||||
### 1. tempbuffer への描画合成を GPU 実行へ変更
|
||||
|
||||
`obj.effect` のエフェクト解決を、互換マップを優先する二段階方式にしました。
|
||||
MoonSharp エンジンで `obj.setoption("drawtarget", "tempbuffer")` を指定した際の
|
||||
`obj.draw` / `obj.drawpoly` の合成を、GPU で実行するようにしました。
|
||||
|
||||
- まず互換マップを参照し、AviUtl/AviUtl2 の名前として宣言したエフェクトは、
|
||||
パラメータ名の対応と倍率・オフセットの変換を経て YMM4 のプロパティへ反映します。
|
||||
- 互換マップに宣言の無い名前は、従来どおり YMM4 のエフェクト名・キーワードで直接解決し、
|
||||
パラメータ名はプロパティ名・表示名と照合します。「ウェーブクリッピング」など YMM4・
|
||||
コミュニティのエフェクトを名前で呼ぶ使い方が再び動作します。
|
||||
- 合成の意味論は従来と同一です。乗算済みアルファのソースオーバー、不透明度の乗算、
|
||||
`antialias` によるリニア・ニアレストの切り替えをそのまま維持しています。
|
||||
- GPU での合成に失敗した場合は従来の CPU 合成へ自動的に切り替わり、ログへ一度だけ
|
||||
警告を出します。切り替え後の動作は従来と完全に同じです。
|
||||
- 大きな `tempbuffer` へ繰り返し合成するスクリプトで、毎フレームの CPU 負荷が
|
||||
下がります。
|
||||
|
||||
### 2. 描画合成の変換行列を一元化
|
||||
|
||||
`obj.draw` の ox / oy / zoom / aspect と `obj.drawpoly` の 4 頂点から合成の変換行列を
|
||||
求める処理を 1 箇所へ集約し、`framebuffer` への合成と `tempbuffer` への合成が同じ
|
||||
定義を共有するようにしました。拡大率が 0 になる描画コマンドは、どちらの描画先でも
|
||||
合成をスキップします。
|
||||
|
||||
### 3. ドキュメントの更新
|
||||
|
||||
内蔵ドキュメント(`LuaScript/docs/LuaScript.*.txt`)・README・サイトのドキュメントへ、
|
||||
`tempbuffer` への合成が MoonSharp では GPU で実行されることと、GPU を利用できない
|
||||
環境では CPU の合成へ自動的に切り替わることを各言語で追記しました。
|
||||
|
||||
---
|
||||
|
||||
## 互換性・後方互換
|
||||
|
||||
- v1.9.3 で互換マップに宣言の無い名前による `obj.effect` が解決されなくなっていた問題を
|
||||
修正し、YMM4 のエフェクト名・キーワードによる直接呼び出しを従来どおりに戻しました。
|
||||
- 解決は段階的に退避します。互換マップを読み込めない場合や、マップに宣言した対象
|
||||
エフェクトが読み込まれていない場合は、その名前を YMM4 の名前として直接解決します。
|
||||
直接解決もできない場合や適用に失敗した場合は、そのフレームでは元の映像をそのまま
|
||||
出力します(ログへ一度だけ警告を出力)。従来のエラー時挙動と同様です。
|
||||
- スクリプト言語・実行エンジン(MoonSharp / LuaJIT)・エディタの既存挙動は変わりません。
|
||||
- スクリプトの書き方と API に変更はありません。`drawtarget` の指定方法・描画結果の
|
||||
意味論は従来どおりです。
|
||||
- GPU を利用できない環境では、従来と同じ CPU 合成で動作します。
|
||||
- GPU 合成は浮動小数点で丸めるため、`tempbuffer` への合成結果が従来の CPU 合成と
|
||||
1 階調程度異なることがあります。ネイティブエンジンの `tempbuffer` 合成は従来どおり
|
||||
ワーカー内の CPU で実行されるため、丸めの違いによりエンジン間で合成結果がごく僅かに
|
||||
異なることがあります。
|
||||
- `framebuffer` への描画合成は従来どおり GPU で実行され、変更はありません。
|
||||
|
||||
---
|
||||
|
||||
## 内部実装
|
||||
|
||||
- 互換マップの読み込みを例外安全にし、リソースの欠損や XML の破損が起きても空のマップへ
|
||||
退避します。互換マップの不備が `obj.effect` 全体を停止させることはなく、直接解決は
|
||||
そのまま機能します。
|
||||
- 解決に用いる型名のレジストリと、エフェクト名・キーワードのレジストリは、
|
||||
`EffectFactories` の一度の走査でまとめて構築します。マップの対象型が見つからない場合は
|
||||
名前による直接解決へ退避し、いずれも見つからない場合のみ当該エフェクトを適用しません。
|
||||
- 合成の契約 `IBufferCompositor` を追加し、`AviUtlScriptContext` の `tempbuffer` 合成が
|
||||
注入された合成器を使うようにしました。既定は CPU の `SoftwareCompositor` で、
|
||||
ネイティブレーンとテストの動作は変わりません。
|
||||
- `HardwareCompositor` を追加しました。`PixelBufferManager` と同じ手順で、合成元と
|
||||
合成先のアップロード、ソースオーバーでの描画、CPU 読み取り可能なステージング
|
||||
ビットマップ経由の読み戻しを行います。ビットマップはサイズ単位でキャッシュします。
|
||||
- `FallbackCompositor` を追加しました。GPU の合成器を優先し、初回の例外で恒久的に
|
||||
CPU の合成器へ降格して、通知コールバックを一度だけ呼び出します。
|
||||
- `SoftwareCompositor` を静的クラスからインスタンスクラスへ変更し、既存の合成処理を
|
||||
そのまま契約の実装として保持しました。合成の数学に変更はありません。
|
||||
- 変換行列の構築を `DrawTransform.TryResolve` へ集約し、`DrawCompositor` と
|
||||
`HardwareCompositor` の双方が同じ数学を共有するようにしました。
|
||||
- `LuaScriptEffectProcessor` の `CreateEffect` とタイムアウト後のコンテキスト再生成で
|
||||
合成器を注入するようにしました。
|
||||
- テストへ `DrawTransformTests`・`FallbackCompositorTests` と、`SoftwareCompositor` の
|
||||
`Compose` ディスパッチの検証を追加しました(全 2987 件)。`HardwareCompositor` の
|
||||
描画出力はテスト環境で Direct2D を実行できないため、YMM4 上での確認が対象です。
|
||||
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
Luaスクリプト for YMM4 v1.9.4
|
||||
Luaスクリプト for YMM4 v1.11.2
|
||||
========================================
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、Luaスクリプトで映像エフェクトのパラメータや
|
||||
ピクセルを直接制御できるプラグインです。
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Collections.Immutable;
|
||||
using LuaScript.Anchor;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class AnchorSupportTests
|
||||
{
|
||||
[Fact]
|
||||
public void ClampCount_LimitsToRange()
|
||||
{
|
||||
Assert.Equal(0, AnchorSupport.ClampCount(-5));
|
||||
Assert.Equal(10, AnchorSupport.ClampCount(10));
|
||||
Assert.Equal(AnchorSupport.MaxAnchors, AnchorSupport.ClampCount(100));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyOption_SetsConnectionAndDimension()
|
||||
{
|
||||
var connection = AnchorConnection.None;
|
||||
bool is3D = false;
|
||||
|
||||
AnchorSupport.ApplyOption("loop", ref connection, ref is3D);
|
||||
AnchorSupport.ApplyOption("xyz", ref connection, ref is3D);
|
||||
|
||||
Assert.Equal(AnchorConnection.Loop, connection);
|
||||
Assert.True(is3D);
|
||||
|
||||
AnchorSupport.ApplyOption("star", ref connection, ref is3D);
|
||||
Assert.Equal(AnchorConnection.Star, connection);
|
||||
|
||||
AnchorSupport.ApplyOption("unknown", ref connection, ref is3D);
|
||||
Assert.Equal(AnchorConnection.Star, connection);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultPosition_IsDeterministicGrid()
|
||||
{
|
||||
Assert.Equal(AnchorSupport.DefaultPosition(0), AnchorSupport.DefaultPosition(0));
|
||||
Assert.NotEqual(AnchorSupport.DefaultPosition(0), AnchorSupport.DefaultPosition(1));
|
||||
|
||||
var (x8, y8) = AnchorSupport.DefaultPosition(8);
|
||||
var (x0, y0) = AnchorSupport.DefaultPosition(0);
|
||||
Assert.Equal(x0, x8);
|
||||
Assert.True(y8 > y0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePosition_PrefersStoredThenDefault()
|
||||
{
|
||||
var source = ImmutableList.Create(new LuaAnchorPoint { Group = "pos", Index = 1, X = 12, Y = 34, Z = 56 });
|
||||
|
||||
AnchorSupport.ResolvePosition(source, "pos", 1, out double x, out double y, out double z);
|
||||
Assert.Equal(12, x);
|
||||
Assert.Equal(34, y);
|
||||
Assert.Equal(56, z);
|
||||
|
||||
AnchorSupport.ResolvePosition(source, "pos", 0, out double dx, out double dy, out double dz);
|
||||
var (ex, ey) = AnchorSupport.DefaultPosition(0);
|
||||
Assert.Equal(ex, dx);
|
||||
Assert.Equal(ey, dy);
|
||||
Assert.Equal(0, dz);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePosition_IsGroupScoped()
|
||||
{
|
||||
var source = ImmutableList.Create(new LuaAnchorPoint { Group = "a", Index = 0, X = 5, Y = 5, Z = 0 });
|
||||
|
||||
AnchorSupport.ResolvePosition(source, "b", 0, out double x, out double y, out _);
|
||||
var (ex, ey) = AnchorSupport.DefaultPosition(0);
|
||||
Assert.Equal(ex, x);
|
||||
Assert.Equal(ey, y);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDrag_UpdatesExistingPoint()
|
||||
{
|
||||
var source = ImmutableList.Create(new LuaAnchorPoint { Group = "pos", Index = 2, X = 10, Y = 20, Z = 30 });
|
||||
|
||||
var result = AnchorSupport.ApplyDrag(source, "pos", 2, 3, -4, 5);
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Equal(13, result[0].X);
|
||||
Assert.Equal(16, result[0].Y);
|
||||
Assert.Equal(35, result[0].Z);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDrag_AddsNewPointFromDefault()
|
||||
{
|
||||
var source = ImmutableList<LuaAnchorPoint>.Empty;
|
||||
|
||||
var result = AnchorSupport.ApplyDrag(source, "pos", 3, 7, 8, 0);
|
||||
|
||||
Assert.Single(result);
|
||||
var (bx, by) = AnchorSupport.DefaultPosition(3);
|
||||
Assert.Equal("pos", result[0].Group);
|
||||
Assert.Equal(3, result[0].Index);
|
||||
Assert.Equal(bx + 7, result[0].X);
|
||||
Assert.Equal(by + 8, result[0].Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class DrawTransformTests
|
||||
{
|
||||
[Fact]
|
||||
public void TryResolve_Affine_MapsSourceCenterToOffset()
|
||||
{
|
||||
var command = new DrawCommand(10d, 20d, 0d, 1d, 1d, 0d);
|
||||
|
||||
Assert.True(DrawTransform.TryResolve(command, 4, 6, out var matrix));
|
||||
|
||||
var mapped = Vector2.Transform(new Vector2(2f, 3f), matrix);
|
||||
Assert.Equal(10d, mapped.X, 3);
|
||||
Assert.Equal(20d, mapped.Y, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_Affine_AppliesZoomAndAspect()
|
||||
{
|
||||
var command = new DrawCommand(0d, 0d, 0d, 2d, 1d, 0.5d);
|
||||
|
||||
Assert.True(DrawTransform.TryResolve(command, 2, 2, out var matrix));
|
||||
|
||||
var mapped = Vector2.Transform(new Vector2(2f, 2f), matrix);
|
||||
Assert.Equal(3d, mapped.X, 3);
|
||||
Assert.Equal(1d, mapped.Y, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_Affine_ClampsAspect()
|
||||
{
|
||||
var command = new DrawCommand(0d, 0d, 0d, 2d, 1d, -3d);
|
||||
|
||||
Assert.False(DrawTransform.TryResolve(command, 2, 2, out _));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_ZeroZoom_Fails()
|
||||
{
|
||||
var command = new DrawCommand(0d, 0d, 0d, 0d, 1d, 0d);
|
||||
|
||||
Assert.False(DrawTransform.TryResolve(command, 2, 2, out _));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_NegativeZoom_Mirrors()
|
||||
{
|
||||
var command = new DrawCommand(0d, 0d, 0d, -1d, 1d, 0d);
|
||||
|
||||
Assert.True(DrawTransform.TryResolve(command, 2, 2, out var matrix));
|
||||
|
||||
var mapped = Vector2.Transform(new Vector2(2f, 2f), matrix);
|
||||
Assert.Equal(-1d, mapped.X, 3);
|
||||
Assert.Equal(-1d, mapped.Y, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_IdentityPoly_YieldsIdentity()
|
||||
{
|
||||
double[] poly =
|
||||
[
|
||||
0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 2, 0,
|
||||
0, 0, 2, 0, 2, 2, 0, 2,
|
||||
1,
|
||||
];
|
||||
var command = new DrawCommand(0d, 0d, 0d, 1d, 1d, 0d, poly);
|
||||
|
||||
Assert.True(DrawTransform.TryResolve(command, 2, 2, out var matrix));
|
||||
Assert.Equal(Matrix3x2.Identity, matrix);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_DegeneratePoly_Fails()
|
||||
{
|
||||
var command = new DrawCommand(0d, 0d, 0d, 1d, 1d, 0d, new double[DrawPolyMath.Length]);
|
||||
|
||||
Assert.False(DrawTransform.TryResolve(command, 2, 2, out _));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class FallbackCompositorTests
|
||||
{
|
||||
private sealed class RecordingCompositor : IBufferCompositor
|
||||
{
|
||||
public int Calls;
|
||||
public byte[]? LastDst;
|
||||
public byte[]? LastSrc;
|
||||
public DrawCommand LastCommand;
|
||||
|
||||
public void Compose(byte[] dst, int dstW, int dstH, byte[] src, int srcW, int srcH, in DrawCommand command)
|
||||
{
|
||||
Calls++;
|
||||
LastDst = dst;
|
||||
LastSrc = src;
|
||||
LastCommand = command;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ThrowingCompositor : IBufferCompositor
|
||||
{
|
||||
public int Calls;
|
||||
|
||||
public void Compose(byte[] dst, int dstW, int dstH, byte[] src, int srcW, int srcH, in DrawCommand command)
|
||||
{
|
||||
Calls++;
|
||||
throw new InvalidOperationException("device lost");
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class DisposableCompositor : IBufferCompositor, IDisposable
|
||||
{
|
||||
public bool Disposed;
|
||||
|
||||
public void Compose(byte[] dst, int dstW, int dstH, byte[] src, int srcW, int srcH, in DrawCommand command)
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose() => Disposed = true;
|
||||
}
|
||||
|
||||
private static readonly DrawCommand Command = new(1d, 2d, 0d, 1d, 1d, 0d);
|
||||
|
||||
[Fact]
|
||||
public void Compose_PrimarySucceeds_FallbackIsNotUsed()
|
||||
{
|
||||
var primary = new RecordingCompositor();
|
||||
var fallback = new RecordingCompositor();
|
||||
var compositor = new FallbackCompositor(primary, fallback);
|
||||
|
||||
compositor.Compose(new byte[4], 1, 1, new byte[4], 1, 1, Command);
|
||||
|
||||
Assert.Equal(1, primary.Calls);
|
||||
Assert.Equal(0, fallback.Calls);
|
||||
Assert.False(compositor.IsDegraded);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compose_PrimaryThrows_FallbackReceivesSameArguments()
|
||||
{
|
||||
var primary = new ThrowingCompositor();
|
||||
var fallback = new RecordingCompositor();
|
||||
Exception? reported = null;
|
||||
var compositor = new FallbackCompositor(primary, fallback, ex => reported = ex);
|
||||
var dst = new byte[4];
|
||||
var src = new byte[4];
|
||||
|
||||
compositor.Compose(dst, 1, 1, src, 1, 1, Command);
|
||||
|
||||
Assert.Equal(1, fallback.Calls);
|
||||
Assert.Same(dst, fallback.LastDst);
|
||||
Assert.Same(src, fallback.LastSrc);
|
||||
Assert.Equal(Command, fallback.LastCommand);
|
||||
Assert.IsType<InvalidOperationException>(reported);
|
||||
Assert.True(compositor.IsDegraded);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compose_AfterFailure_PrimaryIsSkippedAndDegradationReportedOnce()
|
||||
{
|
||||
var primary = new ThrowingCompositor();
|
||||
var fallback = new RecordingCompositor();
|
||||
int reports = 0;
|
||||
var compositor = new FallbackCompositor(primary, fallback, _ => reports++);
|
||||
|
||||
compositor.Compose(new byte[4], 1, 1, new byte[4], 1, 1, Command);
|
||||
compositor.Compose(new byte[4], 1, 1, new byte[4], 1, 1, Command);
|
||||
|
||||
Assert.Equal(1, primary.Calls);
|
||||
Assert.Equal(2, fallback.Calls);
|
||||
Assert.Equal(1, reports);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Dispose_DisposesDisposableLanes()
|
||||
{
|
||||
var primary = new DisposableCompositor();
|
||||
var fallback = new DisposableCompositor();
|
||||
var compositor = new FallbackCompositor(primary, fallback);
|
||||
|
||||
compositor.Dispose();
|
||||
|
||||
Assert.True(primary.Disposed);
|
||||
Assert.True(fallback.Disposed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -33,6 +34,12 @@
|
||||
<Compile Include="..\LuaScript\Engine\LuaJitWorker.cs" Link="Linked\LuaJitWorker.cs" />
|
||||
<Compile Include="..\LuaScript\DrawCommand.cs" Link="Linked\DrawCommand.cs" />
|
||||
<Compile Include="..\LuaScript\DrawPolyMath.cs" Link="Linked\DrawPolyMath.cs" />
|
||||
<Compile Include="..\LuaScript\DrawTransform.cs" Link="Linked\DrawTransform.cs" />
|
||||
<Compile Include="..\LuaScript\IBufferCompositor.cs" Link="Linked\IBufferCompositor.cs" />
|
||||
<Compile Include="..\LuaScript\SoftwareCompositor.cs" Link="Linked\SoftwareCompositor.cs" />
|
||||
<Compile Include="..\LuaScript\FallbackCompositor.cs" Link="Linked\FallbackCompositor.cs" />
|
||||
<Compile Include="..\LuaScript\Anchor\LuaAnchorPoint.cs" Link="Linked\LuaAnchorPoint.cs" />
|
||||
<Compile Include="..\LuaScript\Anchor\AnchorSupport.cs" Link="Linked\AnchorSupport.cs" />
|
||||
<Compile Include="..\LuaScript\SceneObjectInfo.cs" Link="Linked\SceneObjectInfo.cs" />
|
||||
<Compile Include="..\LuaScript\SceneObjectQuery.cs" Link="Linked\SceneObjectQuery.cs" />
|
||||
<Compile Include="..\LuaScript\AnimTableRegistrar.cs" Link="Linked\AnimTableRegistrar.cs" />
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace LuaScript.Tests
|
||||
private static readonly Func<string, double, (byte[] buffer, int w, int h)> NoLoadMovie = (_, _) => ([], 1, 1);
|
||||
private static readonly Action<string, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object>>> NoAddEffect = (_, _) => { };
|
||||
private static readonly Action<DrawCommand> NoAddDraw = _ => { };
|
||||
private static readonly Action<string, int, bool, int, double[]> NoSetAnchor = (_, _, _, _, _) => { };
|
||||
private static readonly System.Collections.Generic.IReadOnlyDictionary<string, string> NoStringParams = new System.Collections.Generic.Dictionary<string, string>();
|
||||
|
||||
private readonly LuaJitWorker _worker = new(NativeDir);
|
||||
|
||||
@@ -40,7 +42,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.rz = obj.time * 90\nobj.alpha = 128",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
fields, NoStringParams, () => pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.False(dirty);
|
||||
@@ -48,6 +50,53 @@ namespace LuaScript.Tests
|
||||
Assert.Equal(128d, fields[NativeProtocol.Alpha]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringParameters_AreExposedOnObj()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var fields = Fields(2, 2, 0d);
|
||||
var pixels = new byte[16];
|
||||
var stringParameters = new System.Collections.Generic.Dictionary<string, string>
|
||||
{
|
||||
["text"] = "hello",
|
||||
["file_image"] = "C:/サンプル/画像.png",
|
||||
};
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.x = string.len(obj.text) obj.alpha = string.len(obj.file_image)",
|
||||
fields, stringParameters, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(5d, fields[NativeProtocol.X]);
|
||||
Assert.Equal(System.Text.Encoding.UTF8.GetByteCount("C:/サンプル/画像.png"), fields[NativeProtocol.Alpha]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringParameters_GrowAndShrinkAroundCapacity()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
string big = new string('x', 100 * 1024);
|
||||
|
||||
var large = new System.Collections.Generic.Dictionary<string, string> { ["text"] = big };
|
||||
var fieldsLarge = Fields(2, 2, 0d);
|
||||
bool ok = _worker.Execute(
|
||||
"obj.x = string.len(obj.text)",
|
||||
fieldsLarge, large, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(big.Length, fieldsLarge[NativeProtocol.X]);
|
||||
|
||||
var small = new System.Collections.Generic.Dictionary<string, string> { ["text"] = "ok" };
|
||||
var fieldsSmall = Fields(2, 2, 0d);
|
||||
ok = _worker.Execute(
|
||||
"obj.x = string.len(obj.text)",
|
||||
fieldsSmall, small, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(2d, fieldsSmall[NativeProtocol.X]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelScript_MatchesExpectedGrayscale()
|
||||
{
|
||||
@@ -75,7 +124,7 @@ namespace LuaScript.Tests
|
||||
"local gray = r*0.299 + g*0.587 + b*0.114 " +
|
||||
"obj.setpixel(x,y,gray,gray,gray,a) end end";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
@@ -110,7 +159,7 @@ namespace LuaScript.Tests
|
||||
"local gray=r*0.299+g*0.587+b*0.114 " +
|
||||
"pd:set(base+1,gray) pd:set(base+2,gray) pd:set(base+3,gray) end end";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
@@ -146,7 +195,7 @@ namespace LuaScript.Tests
|
||||
for (int k = 1; k <= 5; k++)
|
||||
{
|
||||
var fields = Fields(2, 2, k);
|
||||
bool ok = _worker.Execute("obj.x = obj.time * 10", fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute("obj.x = obj.time * 10", fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(k * 10d, fields[NativeProtocol.X]);
|
||||
}
|
||||
@@ -161,12 +210,12 @@ namespace LuaScript.Tests
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
bool timedOut = _worker.Execute(
|
||||
"local x=0 while true do x=x+1 end", fields, pixels, 2, 2, 1500, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
"local x=0 while true do x=x+1 end", fields, NoStringParams, () => pixels, 2, 2, 1500, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.False(timedOut);
|
||||
Assert.Contains("timed out", error);
|
||||
|
||||
var fields2 = Fields(2, 2, 3d);
|
||||
bool ok = _worker.Execute("obj.x = obj.time", fields2, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out error);
|
||||
bool ok = _worker.Execute("obj.x = obj.time", fields2, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(3d, fields2[NativeProtocol.X]);
|
||||
}
|
||||
@@ -188,7 +237,7 @@ namespace LuaScript.Tests
|
||||
"obj.zoom = o.zoom obj.rz = o.rz obj.alpha = o.alpha " +
|
||||
"obj.sx = o.sy obj.rzr = o.rzr";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, () => pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(12d, fields[NativeProtocol.X]);
|
||||
@@ -220,13 +269,13 @@ namespace LuaScript.Tests
|
||||
"local b = obj.getobject(\"a\") " +
|
||||
"obj.x = a.x + b.x";
|
||||
|
||||
bool ok = _worker.Execute(script, Fields(2, 2, 0d), pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, Fields(2, 2, 0d), NoStringParams, () => pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(1, calls);
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
x = 20d;
|
||||
ok = _worker.Execute(script, fields, pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out error);
|
||||
ok = _worker.Execute(script, fields, NoStringParams, () => pixels, 2, 2, 5000, resolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(2, calls);
|
||||
Assert.Equal(40d, fields[NativeProtocol.X]);
|
||||
@@ -243,7 +292,7 @@ namespace LuaScript.Tests
|
||||
const string script =
|
||||
"local o = obj.getobject(\"missing\") obj.x = o == nil and 1 or 0";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(1d, fields[NativeProtocol.X]);
|
||||
@@ -261,7 +310,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.draw() obj.draw(10, 20, 30, 2, 0.5, 0.25)",
|
||||
fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -282,7 +331,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.drawpoly(0,0,0, 10,0,0, 10,10,0, 0,10,0)",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
fields, NoStringParams, () => pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -304,7 +353,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.drawpoly(0,0,0, 8,0,0, 8,8,0, 0,8,0, 1,1, 3,1, 3,3, 1,3, 0.5)",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
fields, NoStringParams, () => pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -325,7 +374,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.setoption('antialias', 0) obj.x = obj.getoption('antialias') obj.y = obj.getoption('unset')",
|
||||
fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -344,7 +393,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.draw() obj.setoption('antialias', 0) obj.draw()",
|
||||
Fields(2, 2, 0d), pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw,
|
||||
Fields(2, 2, 0d), NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -353,6 +402,157 @@ namespace LuaScript.Tests
|
||||
Assert.Equal(0d, commands[1].Antialias);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Draw_CarriesBlendFromOption()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
var commands = new System.Collections.Generic.List<DrawCommand>();
|
||||
Action<DrawCommand> addDraw = commands.Add;
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.draw() obj.setoption('blend', 3) obj.draw()",
|
||||
Fields(2, 2, 0d), NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(2, commands.Count);
|
||||
Assert.Equal(0d, commands[0].Blend);
|
||||
Assert.Equal(3d, commands[1].Blend);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawPoly_CarriesBlendFromOption()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[4 * 4 * 4];
|
||||
var commands = new System.Collections.Generic.List<DrawCommand>();
|
||||
Action<DrawCommand> addDraw = commands.Add;
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.setoption('blend', 11) obj.drawpoly(0,0,0, 10,0,0, 10,10,0, 0,10,0)",
|
||||
Fields(4, 4, 0d), NoStringParams, () => pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, addDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Single(commands);
|
||||
Assert.Equal(11d, commands[0].Blend);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetOption_DrawState_WritesBackFlag()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
|
||||
var fTrue = Fields(2, 2, 0d);
|
||||
bool okTrue = _worker.Execute(
|
||||
"obj.setoption('draw_state', true)",
|
||||
fTrue, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? errorTrue);
|
||||
Assert.True(okTrue, errorTrue);
|
||||
Assert.Equal(1d, fTrue[NativeProtocol.DrawState]);
|
||||
|
||||
var fFalse = Fields(2, 2, 0d);
|
||||
bool okFalse = _worker.Execute(
|
||||
"obj.setoption('draw_state', false)",
|
||||
fFalse, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? errorFalse);
|
||||
Assert.True(okFalse, errorFalse);
|
||||
Assert.Equal(2d, fFalse[NativeProtocol.DrawState]);
|
||||
|
||||
var fUnset = Fields(2, 2, 0d);
|
||||
bool okUnset = _worker.Execute(
|
||||
"obj.x = 1",
|
||||
fUnset, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? errorUnset);
|
||||
Assert.True(okUnset, errorUnset);
|
||||
Assert.Equal(0d, fUnset[NativeProtocol.DrawState]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetAnchor_FillsLuaVariableFromResolver()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
string? capturedGroup = null;
|
||||
int capturedCount = -1;
|
||||
Action<string, int, bool, int, double[]> setAnchor = (group, count, is3D, connection, positions) =>
|
||||
{
|
||||
capturedGroup = group;
|
||||
capturedCount = count;
|
||||
int stride = is3D ? 3 : 2;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
positions[i * stride + 0] = i * 10;
|
||||
positions[i * stride + 1] = i * 10 + 5;
|
||||
if (is3D)
|
||||
positions[i * stride + 2] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
string script =
|
||||
"local n = obj.setanchor('pos', 2, 'loop')\n" +
|
||||
"obj.x = n\n" +
|
||||
"obj.y = pos[1]\n" +
|
||||
"obj.z = pos[3]";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, () => pixels, 2, 2, 5000,
|
||||
NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, setAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal("pos", capturedGroup);
|
||||
Assert.Equal(2, capturedCount);
|
||||
Assert.Equal(2d, fields[NativeProtocol.X]);
|
||||
Assert.Equal(0d, fields[NativeProtocol.Y]);
|
||||
Assert.Equal(10d, fields[NativeProtocol.Z]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawTarget_TempBuffer_CompositesAndCopiesBack()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[2 * 2 * 4];
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
string script =
|
||||
"obj.setpixel(0,0,255,0,0,255)\n" +
|
||||
"obj.setpixel(1,0,0,255,0,255)\n" +
|
||||
"obj.setpixel(0,1,0,0,255,255)\n" +
|
||||
"obj.setpixel(1,1,255,255,0,255)\n" +
|
||||
"obj.setoption('drawtarget','tempbuffer',2,2)\n" +
|
||||
"obj.draw(1,1,0,1,1,0)\n" +
|
||||
"obj.setoption('drawtarget','framebuffer')\n" +
|
||||
"obj.copybuffer('obj','tmp')";
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
script, fields, NoStringParams, () => pixels, 2, 2, 5000,
|
||||
NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
|
||||
Assert.Equal(0, pixels[0]);
|
||||
Assert.Equal(0, pixels[1]);
|
||||
Assert.Equal(255, pixels[2]);
|
||||
Assert.Equal(255, pixels[3]);
|
||||
|
||||
int i11 = (1 * 2 + 1) * 4;
|
||||
Assert.Equal(0, pixels[i11]);
|
||||
Assert.Equal(255, pixels[i11 + 1]);
|
||||
Assert.Equal(255, pixels[i11 + 2]);
|
||||
Assert.Equal(255, pixels[i11 + 3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadText_RoundTripsThroughCallback()
|
||||
{
|
||||
@@ -381,7 +581,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.setfont('Meiryo', 40, 3, 0x112233) obj.load('text', 'Hi')",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, loadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, () => pixels, 4, 4, 5000, NoResolver, NoLoadFigure, loadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels, out int rw, out int rh, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -421,7 +621,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.load('image', 'C:/sample.png')",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, loadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, () => pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, loadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels, out int rw, out int rh, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -458,7 +658,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.load('movie', 'C:/clip.mp4', 1.5)",
|
||||
fields, pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, loadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, () => pixels, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, loadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels, out int rw, out int rh, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -483,7 +683,7 @@ namespace LuaScript.Tests
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"obj.x = obj.getvalue('track0') obj.y = obj.getvalue('alpha') obj.z = obj.getvalue('unknown')",
|
||||
fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw,
|
||||
fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
@@ -510,7 +710,7 @@ namespace LuaScript.Tests
|
||||
"for y=0,obj.h-1 do for x=0,obj.w-1 do obj.setpixel(x,y,0,0,0,0) end end " +
|
||||
"obj.copybuffer('obj','tmp')";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
@@ -529,14 +729,127 @@ namespace LuaScript.Tests
|
||||
stored[3] = 255; stored[7] = 255; stored[11] = 255; stored[15] = 255;
|
||||
|
||||
var save = (byte[])stored.Clone();
|
||||
bool ok = _worker.Execute("obj.copybuffer('cache:foo','obj')", Fields(w, h, 0d), save, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute("obj.copybuffer('cache:foo','obj')", Fields(w, h, 0d), NoStringParams, () => save, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
|
||||
var blank = new byte[w * h * 4];
|
||||
ok = _worker.Execute("obj.copybuffer('obj','cache:foo')", Fields(w, h, 0d), blank, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out bool dirty, out _, out _, out _, out _, out error);
|
||||
ok = _worker.Execute("obj.copybuffer('obj','cache:foo')", Fields(w, h, 0d), NoStringParams, () => blank, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out _, out byte[]? restored, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
Assert.Equal(stored, blank);
|
||||
Assert.NotNull(restored);
|
||||
Assert.Equal(stored, restored!.AsSpan(0, stored.Length).ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TransformScript_NeverRequestsPixels()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
int loads = 0;
|
||||
Func<byte[]> loadPixels = () => { loads++; return pixels; };
|
||||
|
||||
var fields = Fields(2, 2, 1d);
|
||||
bool ok = _worker.Execute(
|
||||
"obj.x = obj.time * 10 obj.draw()",
|
||||
fields, NoStringParams, loadPixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.False(dirty);
|
||||
Assert.Equal(0, loads);
|
||||
Assert.Equal(10d, fields[NativeProtocol.X]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelScript_RequestsPixelsExactlyOnce()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
pixels[3] = 255; pixels[7] = 255; pixels[11] = 255; pixels[15] = 255;
|
||||
int loads = 0;
|
||||
Func<byte[]> loadPixels = () => { loads++; return pixels; };
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"for y=0,obj.h-1 do for x=0,obj.w-1 do local r,g,b,a = obj.getpixel(x,y) obj.setpixel(x,y,r,g,b,a) end end",
|
||||
Fields(2, 2, 0d), NoStringParams, loadPixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
Assert.Equal(1, loads);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Worker_SurvivesSizeChanges_PreservingCache()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var stored = new byte[2 * 2 * 4];
|
||||
for (int i = 0; i < stored.Length; i++)
|
||||
stored[i] = (byte)((i * 41 + 13) & 0xFF);
|
||||
stored[3] = 255; stored[7] = 255; stored[11] = 255; stored[15] = 255;
|
||||
|
||||
bool ok = _worker.Execute("obj.copybuffer('cache:sz','obj')", Fields(2, 2, 0d), NoStringParams, () => stored, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
|
||||
var bigger = new byte[4 * 4 * 4];
|
||||
ok = _worker.Execute("obj.copybuffer('obj','cache:sz')", Fields(4, 4, 0d), NoStringParams, () => bigger, 4, 4, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out bool dirty, out bool bufferReplaced, out byte[]? restored, out int rw, out int rh, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.True(dirty);
|
||||
Assert.True(bufferReplaced);
|
||||
Assert.Equal(2, rw);
|
||||
Assert.Equal(2, rh);
|
||||
Assert.NotNull(restored);
|
||||
Assert.Equal(stored, restored!.AsSpan(0, stored.Length).ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BareGlobals_MirrorObjFields()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
var fields = Fields(2, 2, 2d);
|
||||
fields[NativeProtocol.Frame] = 10d;
|
||||
fields[NativeProtocol.TotalFrame] = 20d;
|
||||
fields[NativeProtocol.Framerate] = 30d;
|
||||
fields[NativeProtocol.Layer] = 3d;
|
||||
fields[NativeProtocol.TimelineFrame] = 100d;
|
||||
fields[NativeProtocol.TimelineTime] = 4d;
|
||||
|
||||
const string script =
|
||||
"obj.x = time * 10 + frame " +
|
||||
"obj.y = totalframe + framerate + layer " +
|
||||
"obj.z = timelineframe + timelinetime";
|
||||
|
||||
bool ok = _worker.Execute(script, fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(30d, fields[NativeProtocol.X]);
|
||||
Assert.Equal(53d, fields[NativeProtocol.Y]);
|
||||
Assert.Equal(104d, fields[NativeProtocol.Z]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UserGlobals_AreResetBetweenRuns()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
var pixels = new byte[16];
|
||||
|
||||
bool ok = _worker.Execute(
|
||||
"leak = 42 obj.leaked = 7 scene.custom = 1 ymm4.custom = 2",
|
||||
Fields(2, 2, 0d), NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.True(ok, error);
|
||||
|
||||
var fields = Fields(2, 2, 0d);
|
||||
ok = _worker.Execute(
|
||||
"obj.x = (leak == nil and 1 or 0) + (obj.leaked == nil and 10 or 0) + (scene.custom == nil and 100 or 0) + (ymm4.custom == nil and 1000 or 0)",
|
||||
fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(1111d, fields[NativeProtocol.X]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -547,12 +860,12 @@ namespace LuaScript.Tests
|
||||
var pixels = new byte[16];
|
||||
var fields = Fields(2, 2, 0d);
|
||||
|
||||
bool ok = _worker.Execute("obj.x = missing.value", fields, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out string? error);
|
||||
bool ok = _worker.Execute("obj.x = missing.value", fields, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out string? error);
|
||||
Assert.False(ok);
|
||||
Assert.False(string.IsNullOrEmpty(error));
|
||||
|
||||
var fields2 = Fields(2, 2, 7d);
|
||||
bool ok2 = _worker.Execute("obj.x = obj.time", fields2, pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, out _, out _, out _, out _, out _, out error);
|
||||
bool ok2 = _worker.Execute("obj.x = obj.time", fields2, NoStringParams, () => pixels, 2, 2, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor, out _, out _, out _, out _, out _, out error);
|
||||
Assert.True(ok2, error);
|
||||
Assert.Equal(7d, fields2[NativeProtocol.X]);
|
||||
}
|
||||
|
||||
@@ -31,18 +31,21 @@ namespace LuaScript.Tests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("obj.rz = time * 90", "MoonSharp")]
|
||||
[InlineData(null, "MoonSharp")]
|
||||
[InlineData("", "MoonSharp")]
|
||||
[InlineData("obj.rz = time * 90", "Native")]
|
||||
[InlineData("local r,g,b,a = obj.getpixel(0,0)", "Native")]
|
||||
[InlineData("obj.setpixel(0,0,255,0,0)", "Native")]
|
||||
[InlineData("local pd = obj.getpixeldata()", "Native")]
|
||||
[InlineData("--!moonsharp\nobj.setpixel(0,0,1,1,1)", "MoonSharp")]
|
||||
[InlineData("--!native\nobj.rz = 1", "Native")]
|
||||
[InlineData("obj.load(\"figure\", \"円\", 0xff0000, 100)", "MoonSharp")]
|
||||
[InlineData("obj.load(\"figure\", \"円\", 0xff0000, 100)\nlocal r = obj.getpixel(0,0)", "Native")]
|
||||
[InlineData("obj.draw()", "MoonSharp")]
|
||||
[InlineData("obj.draw()\nlocal r = obj.getpixel(0,0)", "Native")]
|
||||
[InlineData("--!native\nobj.load(\"figure\", \"円\", 0xff0000, 100)", "Native")]
|
||||
public void ResolveAuto_RoutesPixelScriptsToNative(string script, string expected)
|
||||
[InlineData("--!gpu\nfunction pixel() end", "Gpu")]
|
||||
[InlineData("--!cpu\nfunction pixel() end", "Cpu")]
|
||||
[InlineData("obj.load(\"figure\", \"円\", 0xff0000, 100)", "Native")]
|
||||
[InlineData("obj.draw()", "Native")]
|
||||
[InlineData("obj.setoption('blend', 1)", "Native")]
|
||||
[InlineData("obj.setanchor('pos', 2)", "Native")]
|
||||
public void ResolveAuto_DefaultsToNative(string? script, string expected)
|
||||
{
|
||||
Assert.Equal(expected, ScriptDirective.ResolveAuto(script).ToString());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
using LuaScript;
|
||||
|
||||
namespace LuaScript.Tests
|
||||
{
|
||||
public class SoftwareCompositorTests
|
||||
{
|
||||
private static byte[] Solid(int w, int h, byte b, byte g, byte r, byte a)
|
||||
{
|
||||
var buffer = new byte[w * h * 4];
|
||||
for (int i = 0; i < w * h; i++)
|
||||
{
|
||||
buffer[i * 4] = b;
|
||||
buffer[i * 4 + 1] = g;
|
||||
buffer[i * 4 + 2] = r;
|
||||
buffer[i * 4 + 3] = a;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawInto_NearestOpaque_BlitsSinglePixel()
|
||||
{
|
||||
var dst = new byte[3 * 3 * 4];
|
||||
var src = Solid(1, 1, 255, 255, 255, 255);
|
||||
|
||||
SoftwareCompositor.DrawInto(dst, 3, 3, src, 1, 1, 1.5, 1.5, 1d, 0d, 1d, linear: false);
|
||||
|
||||
int center = (1 * 3 + 1) * 4;
|
||||
Assert.Equal(255, dst[center]);
|
||||
Assert.Equal(255, dst[center + 1]);
|
||||
Assert.Equal(255, dst[center + 2]);
|
||||
Assert.Equal(255, dst[center + 3]);
|
||||
|
||||
Assert.Equal(0, dst[0]);
|
||||
Assert.Equal(0, dst[(0 * 3 + 0) * 4 + 3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawInto_HalfAlphaOverOpaque_BlendsPremultiplied()
|
||||
{
|
||||
var dst = Solid(1, 1, 0, 0, 0, 255);
|
||||
var src = Solid(1, 1, 255, 255, 255, 255);
|
||||
|
||||
SoftwareCompositor.DrawInto(dst, 1, 1, src, 1, 1, 0.5, 0.5, 1d, 0d, 0.5, linear: false);
|
||||
|
||||
Assert.Equal(127, dst[0]);
|
||||
Assert.Equal(127, dst[1]);
|
||||
Assert.Equal(127, dst[2]);
|
||||
Assert.Equal(255, dst[3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawInto_OutOfBounds_LeavesDestinationUnchanged()
|
||||
{
|
||||
var dst = new byte[2 * 2 * 4];
|
||||
var src = Solid(1, 1, 255, 255, 255, 255);
|
||||
|
||||
SoftwareCompositor.DrawInto(dst, 2, 2, src, 1, 1, 100d, 100d, 1d, 0d, 1d, linear: false);
|
||||
|
||||
foreach (var value in dst)
|
||||
Assert.Equal(0, value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compose_AffineCommand_MatchesDrawInto()
|
||||
{
|
||||
var src = Solid(1, 1, 10, 20, 30, 255);
|
||||
var actual = new byte[3 * 3 * 4];
|
||||
var expected = new byte[3 * 3 * 4];
|
||||
var command = new DrawCommand(1.5, 1.5, 0d, 1d, 1d, 0d, Antialias: 0d);
|
||||
|
||||
new SoftwareCompositor().Compose(actual, 3, 3, src, 1, 1, command);
|
||||
SoftwareCompositor.DrawInto(expected, 3, 3, src, 1, 1, 1.5, 1.5, 1d, 0d, 1d, linear: false);
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compose_PolyCommand_MatchesDrawPolyInto()
|
||||
{
|
||||
var src = Solid(2, 2, 40, 50, 60, 255);
|
||||
var actual = new byte[2 * 2 * 4];
|
||||
var expected = new byte[2 * 2 * 4];
|
||||
double[] poly =
|
||||
[
|
||||
0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 2, 0,
|
||||
0, 0, 2, 0, 2, 2, 0, 2,
|
||||
1,
|
||||
];
|
||||
var command = new DrawCommand(0d, 0d, 0d, 1d, 1d, 0d, poly, Antialias: 0d);
|
||||
|
||||
new SoftwareCompositor().Compose(actual, 2, 2, src, 2, 2, command);
|
||||
SoftwareCompositor.DrawPolyInto(expected, 2, 2, src, 2, 2, poly, 1d, linear: false);
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compose_AntialiasCommand_UsesLinearSampling()
|
||||
{
|
||||
var src = new byte[2 * 1 * 4];
|
||||
src[3] = 255;
|
||||
src[4] = 255;
|
||||
src[5] = 255;
|
||||
src[6] = 255;
|
||||
src[7] = 255;
|
||||
var actual = new byte[4 * 1 * 4];
|
||||
var expected = new byte[4 * 1 * 4];
|
||||
var command = new DrawCommand(2d, 0.5, 0d, 2d, 1d, 0d, Antialias: 1d);
|
||||
|
||||
new SoftwareCompositor().Compose(actual, 4, 1, src, 2, 1, command);
|
||||
SoftwareCompositor.DrawInto(expected, 4, 1, src, 2, 1, 2d, 0.5, 2d, 0d, 1d, linear: true);
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DrawPolyInto_IdentityAffine_CopiesSource()
|
||||
{
|
||||
var src = new byte[2 * 2 * 4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
src[i * 4] = (byte)(i + 1);
|
||||
src[i * 4 + 1] = (byte)(i + 10);
|
||||
src[i * 4 + 2] = (byte)(i + 20);
|
||||
src[i * 4 + 3] = 255;
|
||||
}
|
||||
var dst = new byte[2 * 2 * 4];
|
||||
|
||||
double[] poly =
|
||||
[
|
||||
0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 2, 0,
|
||||
0, 0, 2, 0, 2, 2, 0, 2,
|
||||
1,
|
||||
];
|
||||
|
||||
SoftwareCompositor.DrawPolyInto(dst, 2, 2, src, 2, 2, poly, 1d, linear: false);
|
||||
|
||||
Assert.Equal(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace LuaScript.Anchor
|
||||
{
|
||||
internal enum AnchorConnection
|
||||
{
|
||||
None,
|
||||
Line,
|
||||
Loop,
|
||||
Star,
|
||||
Arm,
|
||||
}
|
||||
|
||||
internal readonly record struct AnchorOptions(AnchorConnection Connection, bool Is3D);
|
||||
|
||||
internal readonly record struct AnchorRequestData(string Group, int Count, AnchorConnection Connection, bool Is3D);
|
||||
|
||||
internal static class AnchorSupport
|
||||
{
|
||||
public const int MaxAnchors = 32;
|
||||
public const string TrackGroup = "track";
|
||||
|
||||
public static int ClampCount(int count) => Math.Clamp(count, 0, MaxAnchors);
|
||||
|
||||
public static void ApplyOption(string option, ref AnchorConnection connection, ref bool is3D)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case "line": connection = AnchorConnection.Line; break;
|
||||
case "loop": connection = AnchorConnection.Loop; break;
|
||||
case "star": connection = AnchorConnection.Star; break;
|
||||
case "arm": connection = AnchorConnection.Arm; break;
|
||||
case "xyz": is3D = true; break;
|
||||
}
|
||||
}
|
||||
|
||||
public static (double X, double Y) DefaultPosition(int index)
|
||||
{
|
||||
int col = index % 8;
|
||||
int row = index / 8;
|
||||
return ((col - 3.5) * 60d, (row - 1.5) * 60d);
|
||||
}
|
||||
|
||||
public static void ResolvePosition(IReadOnlyList<LuaAnchorPoint>? source, string group, int index,
|
||||
out double x, out double y, out double z)
|
||||
{
|
||||
if (source is not null)
|
||||
{
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
var a = source[i];
|
||||
if (a.Index == index && string.Equals(a.Group, group, StringComparison.Ordinal))
|
||||
{
|
||||
x = a.X;
|
||||
y = a.Y;
|
||||
z = a.Z;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var (dx, dy) = DefaultPosition(index);
|
||||
x = dx;
|
||||
y = dy;
|
||||
z = 0d;
|
||||
}
|
||||
|
||||
public static ImmutableList<LuaAnchorPoint> ApplyDrag(
|
||||
ImmutableList<LuaAnchorPoint> source, string group, int index, double dx, double dy, double dz)
|
||||
{
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
var a = source[i];
|
||||
if (a.Index == index && string.Equals(a.Group, group, StringComparison.Ordinal))
|
||||
{
|
||||
return source.SetItem(i, new LuaAnchorPoint
|
||||
{
|
||||
Group = group,
|
||||
Index = index,
|
||||
X = a.X + dx,
|
||||
Y = a.Y + dy,
|
||||
Z = a.Z + dz,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var (bx, by) = DefaultPosition(index);
|
||||
return source.Add(new LuaAnchorPoint
|
||||
{
|
||||
Group = group,
|
||||
Index = index,
|
||||
X = bx + dx,
|
||||
Y = by + dy,
|
||||
Z = dz,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace LuaScript.Anchor
|
||||
{
|
||||
public sealed class LuaAnchorPoint
|
||||
{
|
||||
public string Group { get; set; } = string.Empty;
|
||||
public int Index { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public double Z { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,19 @@
|
||||
using LuaScript.Anchor;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
internal sealed class AviUtlScriptContext
|
||||
{
|
||||
public IReadOnlyList<LuaAnchorPoint>? AnchorSource { get; set; }
|
||||
|
||||
private readonly List<AnchorRequestData> _anchorRequests = [];
|
||||
|
||||
public IReadOnlyList<AnchorRequestData> AnchorRequests => _anchorRequests;
|
||||
|
||||
internal void AddAnchorRequest(in AnchorRequestData request) => _anchorRequests.Add(request);
|
||||
|
||||
internal void ClearAnchorRequests() => _anchorRequests.Clear();
|
||||
|
||||
public bool IsPlaying { get; set; }
|
||||
public bool IsPaused { get; set; }
|
||||
public string SceneId { get; set; } = string.Empty;
|
||||
@@ -29,6 +41,11 @@ namespace LuaScript
|
||||
public double Track2 { get; set; }
|
||||
public double Track3 { get; set; }
|
||||
|
||||
public double Slider0 { get; set; }
|
||||
public double Slider1 { get; set; }
|
||||
public double Slider2 { get; set; }
|
||||
public double Slider3 { get; set; }
|
||||
|
||||
public bool Check0 { get; set; }
|
||||
public bool Check1 { get; set; }
|
||||
public bool Check2 { get; set; }
|
||||
@@ -37,6 +54,8 @@ namespace LuaScript
|
||||
public bool HasColor { get; set; }
|
||||
public double ColorValue { get; set; }
|
||||
|
||||
public bool? DrawStateOverride { get; set; }
|
||||
|
||||
public double Time { get; set; }
|
||||
public int Frame { get; set; }
|
||||
public int TotalFrame { get; set; }
|
||||
@@ -52,6 +71,12 @@ namespace LuaScript
|
||||
|
||||
public Func<SceneObjectResolver>? ResolverProvider { get; set; }
|
||||
|
||||
private readonly Dictionary<string, string> _stringParameters = new(StringComparer.Ordinal);
|
||||
|
||||
public IReadOnlyDictionary<string, string> StringParameters => _stringParameters;
|
||||
|
||||
internal void SetStringParameter(string name, string? value) => _stringParameters[name] = value ?? string.Empty;
|
||||
|
||||
private const double Epsilon = 1e-10;
|
||||
|
||||
private readonly List<SceneObjectQuery> _objectQueries = [];
|
||||
@@ -66,6 +91,8 @@ namespace LuaScript
|
||||
|
||||
internal void ClearEffects() => _effectRequests.Clear();
|
||||
|
||||
internal IBufferCompositor Compositor { get; set; } = new SoftwareCompositor();
|
||||
|
||||
private readonly List<DrawCommand> _drawCommands = [];
|
||||
|
||||
public IReadOnlyList<DrawCommand> DrawCommands => _drawCommands;
|
||||
@@ -74,6 +101,49 @@ namespace LuaScript
|
||||
|
||||
internal void ClearDraws() => _drawCommands.Clear();
|
||||
|
||||
private bool _drawTargetTemp;
|
||||
|
||||
internal void ResetDrawTarget() => _drawTargetTemp = false;
|
||||
|
||||
internal void SetDrawTarget(bool temp, int width, int height, bool hasSize)
|
||||
{
|
||||
_drawTargetTemp = temp;
|
||||
if (temp && hasSize)
|
||||
{
|
||||
int w = Math.Max(1, width);
|
||||
int h = Math.Max(1, height);
|
||||
_buffers["t"] = (new byte[w * h * 4], w, h);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SubmitDraw(DrawCommand command)
|
||||
{
|
||||
if (!_drawTargetTemp)
|
||||
{
|
||||
_drawCommands.Add(command);
|
||||
return;
|
||||
}
|
||||
CompositeToTemp(command);
|
||||
}
|
||||
|
||||
private void CompositeToTemp(DrawCommand command)
|
||||
{
|
||||
EnsurePixelBuffer();
|
||||
var src = _pixelBuffer;
|
||||
if (src is null)
|
||||
return;
|
||||
|
||||
if (!_buffers.TryGetValue("t", out var temp))
|
||||
{
|
||||
int w = Math.Max(1, ImageWidth);
|
||||
int h = Math.Max(1, ImageHeight);
|
||||
temp = (new byte[w * h * 4], w, h);
|
||||
_buffers["t"] = temp;
|
||||
}
|
||||
|
||||
Compositor.Compose(temp.Data, temp.Width, temp.Height, src, ImageWidth, ImageHeight, command);
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, (byte[] Data, int Width, int Height)> _buffers = new(StringComparer.Ordinal);
|
||||
|
||||
internal bool CopyBuffer(string dst, string src)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using YukkuriMovieMaker.Project;
|
||||
|
||||
namespace LuaScript.Compat
|
||||
{
|
||||
internal static class BlendModeMap
|
||||
{
|
||||
private static readonly Blend[] Order =
|
||||
[
|
||||
Blend.Normal,
|
||||
Blend.Dissolve,
|
||||
Blend.Darker,
|
||||
Blend.Multiply,
|
||||
Blend.ColorBurn,
|
||||
Blend.LinearBurn,
|
||||
Blend.Lighter,
|
||||
Blend.Screen,
|
||||
Blend.ColorDodge,
|
||||
Blend.LinearDodge,
|
||||
Blend.Add,
|
||||
Blend.Overlay,
|
||||
Blend.SoftLight,
|
||||
Blend.HardLight,
|
||||
Blend.VividLight,
|
||||
Blend.LinearLight,
|
||||
Blend.PinLight,
|
||||
Blend.HardMix,
|
||||
Blend.Difference,
|
||||
Blend.Exclusion,
|
||||
Blend.Subtract,
|
||||
Blend.Division,
|
||||
Blend.Hue,
|
||||
Blend.Saturation,
|
||||
Blend.Color,
|
||||
Blend.Luminosity,
|
||||
Blend.LighterColor,
|
||||
Blend.DestinationOver,
|
||||
Blend.DarkerColor,
|
||||
Blend.DestinationOut,
|
||||
Blend.SourceAtop,
|
||||
Blend.XOR,
|
||||
Blend.MaskInvert,
|
||||
];
|
||||
|
||||
public static Blend Resolve(double value)
|
||||
{
|
||||
if (double.IsNaN(value))
|
||||
return Blend.Normal;
|
||||
|
||||
int index = (int)value;
|
||||
return (uint)index < (uint)Order.Length ? Order[index] : Blend.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,31 +6,29 @@ namespace LuaScript.Compat
|
||||
{
|
||||
internal readonly struct ScriptParameterUsage
|
||||
{
|
||||
public bool Check0 { get; }
|
||||
public bool Check1 { get; }
|
||||
public bool Check2 { get; }
|
||||
public bool Check3 { get; }
|
||||
public bool Color { get; }
|
||||
private readonly HashSet<string>? _members;
|
||||
private readonly bool _color;
|
||||
|
||||
private ScriptParameterUsage(bool check0, bool check1, bool check2, bool check3, bool color)
|
||||
private ScriptParameterUsage(HashSet<string>? members, bool color)
|
||||
{
|
||||
Check0 = check0;
|
||||
Check1 = check1;
|
||||
Check2 = check2;
|
||||
Check3 = check3;
|
||||
Color = color;
|
||||
_members = members;
|
||||
_color = color;
|
||||
}
|
||||
|
||||
public static readonly ScriptParameterUsage None = default;
|
||||
|
||||
public bool Check(int index) => index switch
|
||||
{
|
||||
0 => Check0,
|
||||
1 => Check1,
|
||||
2 => Check2,
|
||||
3 => Check3,
|
||||
_ => false,
|
||||
};
|
||||
public bool Color => _color;
|
||||
|
||||
public bool Uses(string member) => _members is not null && _members.Contains(member);
|
||||
|
||||
public bool Check0 => Uses("check0");
|
||||
public bool Check1 => Uses("check1");
|
||||
public bool Check2 => Uses("check2");
|
||||
public bool Check3 => Uses("check3");
|
||||
|
||||
public bool Check(int index) => (uint)index < 4 && Uses("check" + (char)('0' + index));
|
||||
|
||||
public bool Slider(int index) => (uint)index < 4 && Uses("slider" + (char)('0' + index));
|
||||
|
||||
public static ScriptParameterUsage Detect(string? script)
|
||||
{
|
||||
@@ -47,7 +45,7 @@ namespace LuaScript.Compat
|
||||
return None;
|
||||
}
|
||||
|
||||
var checks = new bool[4];
|
||||
HashSet<string>? members = null;
|
||||
bool color = false;
|
||||
|
||||
for (int i = 0; i < tokens.Count; i++)
|
||||
@@ -68,17 +66,11 @@ namespace LuaScript.Compat
|
||||
tokens[i + 1].IsSymbol(".") &&
|
||||
tokens[i + 2].Kind == LuaTokenKind.Name)
|
||||
{
|
||||
string member = tokens[i + 2].Text;
|
||||
if (member.Length == 6 && member.StartsWith("check", StringComparison.Ordinal))
|
||||
{
|
||||
char digit = member[5];
|
||||
if (digit is >= '0' and <= '3')
|
||||
checks[digit - '0'] = true;
|
||||
}
|
||||
(members ??= new HashSet<string>(StringComparer.Ordinal)).Add(tokens[i + 2].Text);
|
||||
}
|
||||
}
|
||||
|
||||
return new ScriptParameterUsage(checks[0], checks[1], checks[2], checks[3], color);
|
||||
return new ScriptParameterUsage(members, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,6 @@ namespace LuaScript
|
||||
double Alpha,
|
||||
double Aspect,
|
||||
double[]? Poly = null,
|
||||
double Antialias = 1d);
|
||||
double Antialias = 1d,
|
||||
double Blend = 0d);
|
||||
}
|
||||
+41
-21
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using LuaScript.Compat;
|
||||
using Vortice.Direct2D1;
|
||||
using Vortice.Direct2D1.Effects;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
using YukkuriMovieMaker.Player;
|
||||
using Blend = YukkuriMovieMaker.Project.Blend;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
@@ -15,6 +18,8 @@ namespace LuaScript
|
||||
private ID2D1Bitmap1? _source;
|
||||
private ID2D1Bitmap1? _target;
|
||||
private AffineTransform2D? _placement;
|
||||
private Opacity? _opacityEffect;
|
||||
private ID2D1Image? _opacityOutput;
|
||||
private int _sourceWidth;
|
||||
private int _sourceHeight;
|
||||
private int _targetWidth;
|
||||
@@ -74,31 +79,16 @@ namespace LuaScript
|
||||
for (int i = 0; i < commands.Count; i++)
|
||||
{
|
||||
var cmd = commands[i];
|
||||
if (!DrawTransform.TryResolve(cmd, width, height, out var transform))
|
||||
continue;
|
||||
|
||||
var interpolation = cmd.Antialias != 0d
|
||||
? BitmapInterpolationMode.Linear
|
||||
: BitmapInterpolationMode.NearestNeighbor;
|
||||
var blend = BlendModeMap.Resolve(cmd.Blend);
|
||||
|
||||
if (cmd.Poly is { } poly)
|
||||
{
|
||||
if (!DrawPolyMath.TrySolveAffine(poly, out var affine))
|
||||
continue;
|
||||
rt.Transform = affine * toTarget;
|
||||
rt.DrawBitmap(_source, (float)Math.Clamp(poly[20], 0d, 1d), interpolation);
|
||||
continue;
|
||||
}
|
||||
|
||||
double aspect = Math.Clamp(cmd.Aspect, -1d, 1d);
|
||||
float zx = (float)(cmd.Zoom * (1d + aspect));
|
||||
float zy = (float)(cmd.Zoom * (1d - aspect));
|
||||
float opacity = (float)Math.Clamp(cmd.Alpha, 0d, 1d);
|
||||
|
||||
var matrix =
|
||||
Matrix3x2.CreateTranslation(-width * 0.5f, -height * 0.5f) *
|
||||
Matrix3x2.CreateScale(zx, zy) *
|
||||
Matrix3x2.CreateTranslation((float)(cmd.Ox - originX), (float)(cmd.Oy - originY));
|
||||
|
||||
rt.Transform = matrix;
|
||||
rt.DrawBitmap(_source, opacity, interpolation);
|
||||
rt.Transform = transform * toTarget;
|
||||
DrawSource(rt, (float)Math.Clamp(cmd.Alpha, 0d, 1d), interpolation, blend);
|
||||
}
|
||||
rt.Transform = Matrix3x2.Identity;
|
||||
dc.EndDraw();
|
||||
@@ -108,6 +98,25 @@ namespace LuaScript
|
||||
return _placement.Output;
|
||||
}
|
||||
|
||||
private void DrawSource(ID2D1RenderTarget rt, float opacity, BitmapInterpolationMode interpolation, Blend blend)
|
||||
{
|
||||
if (blend == Blend.Normal)
|
||||
{
|
||||
rt.DrawBitmap(_source!, opacity, interpolation);
|
||||
return;
|
||||
}
|
||||
|
||||
var interp = ToImageInterpolation(interpolation);
|
||||
_opacityEffect!.Value = opacity;
|
||||
if (blend.IsCompositionEffect())
|
||||
_ctx.DeviceContext.DrawImage(_opacityOutput!, interpolationMode: interp, compositeMode: blend.ToD2DCompositionMode());
|
||||
else
|
||||
_ctx.DeviceContext.BlendImage(_opacityOutput!, blend.ToD2DBlendMode(), null, null, interp);
|
||||
}
|
||||
|
||||
private static InterpolationMode ToImageInterpolation(BitmapInterpolationMode mode) =>
|
||||
mode == BitmapInterpolationMode.Linear ? InterpolationMode.Linear : InterpolationMode.NearestNeighbor;
|
||||
|
||||
private void EnsureSource(int width, int height)
|
||||
{
|
||||
if (_source is not null && _sourceWidth == width && _sourceHeight == height)
|
||||
@@ -117,6 +126,13 @@ namespace LuaScript
|
||||
_source = _ctx.DeviceContext.CreateEmptyBitmap(width, height, BitmapOptions.Target);
|
||||
_sourceWidth = width;
|
||||
_sourceHeight = height;
|
||||
|
||||
if (_opacityEffect is null)
|
||||
{
|
||||
_opacityEffect = new Opacity(_ctx.DeviceContext);
|
||||
_opacityOutput = _opacityEffect.Output;
|
||||
}
|
||||
_opacityEffect.SetInput(0, _source, true);
|
||||
}
|
||||
|
||||
private void EnsureTarget(int width, int height)
|
||||
@@ -139,9 +155,13 @@ namespace LuaScript
|
||||
public void Dispose()
|
||||
{
|
||||
_placement?.Dispose();
|
||||
_opacityOutput?.Dispose();
|
||||
_opacityEffect?.Dispose();
|
||||
_source?.Dispose();
|
||||
_target?.Dispose();
|
||||
_placement = null;
|
||||
_opacityOutput = null;
|
||||
_opacityEffect = null;
|
||||
_source = null;
|
||||
_target = null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
internal static class DrawTransform
|
||||
{
|
||||
public static bool TryResolve(in DrawCommand command, int srcW, int srcH, out Matrix3x2 matrix)
|
||||
{
|
||||
if (command.Poly is { } poly)
|
||||
return DrawPolyMath.TrySolveAffine(poly, out matrix);
|
||||
|
||||
double aspect = Math.Clamp(command.Aspect, -1d, 1d);
|
||||
double zx = command.Zoom * (1d + aspect);
|
||||
double zy = command.Zoom * (1d - aspect);
|
||||
if (zx == 0d || zy == 0d)
|
||||
{
|
||||
matrix = Matrix3x2.Identity;
|
||||
return false;
|
||||
}
|
||||
|
||||
matrix =
|
||||
Matrix3x2.CreateTranslation(-srcW * 0.5f, -srcH * 0.5f) *
|
||||
Matrix3x2.CreateScale((float)zx, (float)zy) *
|
||||
Matrix3x2.CreateTranslation((float)command.Ox, (float)command.Oy);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,10 @@ namespace LuaScript.Engine.Kernel
|
||||
Track1,
|
||||
Track2,
|
||||
Track3,
|
||||
Slider0,
|
||||
Slider1,
|
||||
Slider2,
|
||||
Slider3,
|
||||
Check0,
|
||||
Check1,
|
||||
Check2,
|
||||
@@ -105,6 +109,10 @@ namespace LuaScript.Engine.Kernel
|
||||
["track1"] = KernelUniform.Track1,
|
||||
["track2"] = KernelUniform.Track2,
|
||||
["track3"] = KernelUniform.Track3,
|
||||
["slider0"] = KernelUniform.Slider0,
|
||||
["slider1"] = KernelUniform.Slider1,
|
||||
["slider2"] = KernelUniform.Slider2,
|
||||
["slider3"] = KernelUniform.Slider3,
|
||||
["check0"] = KernelUniform.Check0,
|
||||
["check1"] = KernelUniform.Check1,
|
||||
["check2"] = KernelUniform.Check2,
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace LuaScript.Engine.Kernel
|
||||
values[(int)KernelUniform.Track1] = ctx.Track1;
|
||||
values[(int)KernelUniform.Track2] = ctx.Track2;
|
||||
values[(int)KernelUniform.Track3] = ctx.Track3;
|
||||
values[(int)KernelUniform.Slider0] = ctx.Slider0;
|
||||
values[(int)KernelUniform.Slider1] = ctx.Slider1;
|
||||
values[(int)KernelUniform.Slider2] = ctx.Slider2;
|
||||
values[(int)KernelUniform.Slider3] = ctx.Slider3;
|
||||
values[(int)KernelUniform.Check0] = ctx.Check0 ? 1d : 0d;
|
||||
values[(int)KernelUniform.Check1] = ctx.Check1 ? 1d : 0d;
|
||||
values[(int)KernelUniform.Check2] = ctx.Check2 ? 1d : 0d;
|
||||
|
||||
+167
-33
@@ -19,15 +19,19 @@ namespace LuaScript.Engine
|
||||
private EventWaitHandle? _workEvent;
|
||||
private EventWaitHandle? _doneEvent;
|
||||
private Process? _process;
|
||||
private int _width;
|
||||
private int _height;
|
||||
private int _stringParamsCapacity = NativeProtocol.MinStringParamsCapacity;
|
||||
private long _pixelOffset = NativeProtocol.PixelOffset(NativeProtocol.MinStringParamsCapacity);
|
||||
private long _allocatedSize;
|
||||
private bool _alive;
|
||||
|
||||
private readonly byte[] _callbackTag = new byte[NativeProtocol.CallbackTagMax];
|
||||
private readonly byte[] _lastCallbackTag = new byte[NativeProtocol.CallbackTagMax];
|
||||
private readonly double[] _anchorBuffer = new double[Anchor.AnchorSupport.MaxAnchors * 3];
|
||||
private int _lastCallbackTagLength = -1;
|
||||
private string _lastCallbackTagText = string.Empty;
|
||||
private byte[]? _resultBuffer;
|
||||
private readonly Dictionary<string, byte[]> _stringNameBytes = new(StringComparer.Ordinal);
|
||||
private byte[] _stringValueBytes = new byte[256];
|
||||
|
||||
public LuaJitWorker(string nativeDir)
|
||||
{
|
||||
@@ -43,7 +47,8 @@ namespace LuaScript.Engine
|
||||
public bool Execute(
|
||||
string script,
|
||||
double[] fields,
|
||||
byte[] pixels,
|
||||
IReadOnlyDictionary<string, string> stringParameters,
|
||||
Func<byte[]> loadPixels,
|
||||
int width,
|
||||
int height,
|
||||
int timeoutMs,
|
||||
@@ -54,16 +59,17 @@ namespace LuaScript.Engine
|
||||
Func<string, double, (byte[] buffer, int w, int h)> loadMovie,
|
||||
Action<string, IReadOnlyList<KeyValuePair<string, object>>> addEffect,
|
||||
Action<DrawCommand> addDraw,
|
||||
Action<string, int, bool, int, double[]> setAnchor,
|
||||
out bool pixelsDirty,
|
||||
out bool bufferReplaced,
|
||||
out byte[]? newPixels,
|
||||
out byte[]? resultPixels,
|
||||
out int resultWidth,
|
||||
out int resultHeight,
|
||||
out string? error)
|
||||
{
|
||||
pixelsDirty = false;
|
||||
bufferReplaced = false;
|
||||
newPixels = null;
|
||||
resultPixels = null;
|
||||
resultWidth = width;
|
||||
resultHeight = height;
|
||||
error = null;
|
||||
@@ -75,15 +81,16 @@ namespace LuaScript.Engine
|
||||
return false;
|
||||
}
|
||||
|
||||
EnsureWorker(width, height);
|
||||
int stringCapacity = ResolveStringCapacity(_stringParamsCapacity, MeasureStringParameters(stringParameters));
|
||||
EnsureWorker(width, height, stringCapacity);
|
||||
var view = _view!;
|
||||
|
||||
view.WriteArray(NativeProtocol.FieldsOffset, fields, 0, NativeProtocol.FieldCount);
|
||||
WriteStringParameters(view, stringParameters);
|
||||
view.Write(NativeProtocol.OffWidth, width);
|
||||
view.Write(NativeProtocol.OffHeight, height);
|
||||
view.Write(NativeProtocol.OffScriptLen, scriptBytes.Length);
|
||||
view.WriteArray(NativeProtocol.ScriptOffset, scriptBytes, 0, scriptBytes.Length);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, pixels, 0, pixels.Length);
|
||||
view.Write(NativeProtocol.OffPixelsDirty, 0);
|
||||
view.Write(NativeProtocol.OffErrorLen, 0);
|
||||
view.Write(NativeProtocol.OffStatus, NativeProtocol.StatusIdle);
|
||||
@@ -91,6 +98,7 @@ namespace LuaScript.Engine
|
||||
|
||||
_workEvent!.Set();
|
||||
|
||||
byte[]? uploadedPixels = null;
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
int status;
|
||||
while (true)
|
||||
@@ -107,7 +115,15 @@ namespace LuaScript.Engine
|
||||
if (status != NativeProtocol.StatusCallback)
|
||||
break;
|
||||
|
||||
DispatchCallback(view, resolveObject, loadFigure, loadText, loadImage, loadMovie, addEffect, addDraw);
|
||||
if (view.ReadInt32(NativeProtocol.OffCallbackKind) == NativeProtocol.CbKindRequestPixels)
|
||||
{
|
||||
uploadedPixels ??= loadPixels();
|
||||
WritePixelRegion(uploadedPixels, uploadedPixels.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
DispatchCallback(view, resolveObject, loadFigure, loadText, loadImage, loadMovie, addEffect, addDraw, setAnchor);
|
||||
}
|
||||
_workEvent.Set();
|
||||
}
|
||||
|
||||
@@ -123,6 +139,8 @@ namespace LuaScript.Engine
|
||||
for (int i = NativeProtocol.FirstWritableField; i <= NativeProtocol.LastWritableField; i++)
|
||||
fields[i] = view.ReadDouble(NativeProtocol.FieldsOffset + i * 8);
|
||||
|
||||
fields[NativeProtocol.DrawState] = view.ReadDouble(NativeProtocol.FieldsOffset + NativeProtocol.DrawState * 8);
|
||||
|
||||
resultWidth = view.ReadInt32(NativeProtocol.OffWidth);
|
||||
resultHeight = view.ReadInt32(NativeProtocol.OffHeight);
|
||||
bufferReplaced = resultWidth != width || resultHeight != height;
|
||||
@@ -130,23 +148,109 @@ namespace LuaScript.Engine
|
||||
pixelsDirty = view.ReadInt32(NativeProtocol.OffPixelsDirty) != 0;
|
||||
if (pixelsDirty)
|
||||
{
|
||||
if (bufferReplaced)
|
||||
int pixelSize = resultWidth * resultHeight * 4;
|
||||
if (!bufferReplaced && uploadedPixels is not null)
|
||||
{
|
||||
int pixelSize = resultWidth * resultHeight * 4;
|
||||
if (_resultBuffer == null || _resultBuffer.Length < pixelSize)
|
||||
_resultBuffer = new byte[pixelSize];
|
||||
view.ReadArray(NativeProtocol.PixelOffset, _resultBuffer, 0, pixelSize);
|
||||
newPixels = _resultBuffer;
|
||||
ReadPixelRegion(uploadedPixels, pixelSize);
|
||||
resultPixels = uploadedPixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
view.ReadArray(NativeProtocol.PixelOffset, pixels, 0, pixels.Length);
|
||||
if (_resultBuffer == null || _resultBuffer.Length < pixelSize)
|
||||
_resultBuffer = new byte[pixelSize];
|
||||
ReadPixelRegion(_resultBuffer, pixelSize);
|
||||
resultPixels = _resultBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private unsafe void WritePixelRegion(byte[] source, int length)
|
||||
{
|
||||
var handle = _view!.SafeMemoryMappedViewHandle;
|
||||
byte* ptr = null;
|
||||
handle.AcquirePointer(ref ptr);
|
||||
try
|
||||
{
|
||||
fixed (byte* src = source)
|
||||
Buffer.MemoryCopy(src, ptr + _view.PointerOffset + _pixelOffset, handle.ByteLength - (ulong)(_view.PointerOffset + _pixelOffset), (ulong)length);
|
||||
}
|
||||
finally
|
||||
{
|
||||
handle.ReleasePointer();
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void ReadPixelRegion(byte[] destination, int length)
|
||||
{
|
||||
var handle = _view!.SafeMemoryMappedViewHandle;
|
||||
byte* ptr = null;
|
||||
handle.AcquirePointer(ref ptr);
|
||||
try
|
||||
{
|
||||
fixed (byte* dst = destination)
|
||||
Buffer.MemoryCopy(ptr + _view.PointerOffset + _pixelOffset, dst, destination.Length, length);
|
||||
}
|
||||
finally
|
||||
{
|
||||
handle.ReleasePointer();
|
||||
}
|
||||
}
|
||||
|
||||
private static int MeasureStringParameters(IReadOnlyDictionary<string, string> stringParameters)
|
||||
{
|
||||
int total = 4;
|
||||
foreach (var pair in stringParameters)
|
||||
total += 8 + Encoding.UTF8.GetByteCount(pair.Key) + Encoding.UTF8.GetByteCount(pair.Value ?? string.Empty);
|
||||
return total;
|
||||
}
|
||||
|
||||
private static int ResolveStringCapacity(int current, int required)
|
||||
{
|
||||
int capacity = current;
|
||||
while (capacity < required)
|
||||
{
|
||||
if (capacity > int.MaxValue / 2)
|
||||
{
|
||||
capacity = required;
|
||||
break;
|
||||
}
|
||||
capacity *= 2;
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
|
||||
private void WriteStringParameters(MemoryMappedViewAccessor view, IReadOnlyDictionary<string, string> stringParameters)
|
||||
{
|
||||
long basePos = NativeProtocol.StringParamsOffset;
|
||||
long limit = basePos + _stringParamsCapacity;
|
||||
long pos = basePos + 4;
|
||||
int count = 0;
|
||||
foreach (var pair in stringParameters)
|
||||
{
|
||||
if (!_stringNameBytes.TryGetValue(pair.Key, out var name))
|
||||
{
|
||||
name = Encoding.UTF8.GetBytes(pair.Key);
|
||||
_stringNameBytes[pair.Key] = name;
|
||||
}
|
||||
string value = pair.Value ?? string.Empty;
|
||||
int maxValueBytes = Encoding.UTF8.GetMaxByteCount(value.Length);
|
||||
if (_stringValueBytes.Length < maxValueBytes)
|
||||
_stringValueBytes = new byte[Math.Max(maxValueBytes, _stringValueBytes.Length * 2)];
|
||||
int valueLen = Encoding.UTF8.GetBytes(value, 0, value.Length, _stringValueBytes, 0);
|
||||
if (pos + 8 + name.Length + valueLen > limit)
|
||||
break;
|
||||
view.Write(pos, name.Length); pos += 4;
|
||||
view.WriteArray(pos, name, 0, name.Length); pos += name.Length;
|
||||
view.Write(pos, valueLen); pos += 4;
|
||||
view.WriteArray(pos, _stringValueBytes, 0, valueLen); pos += valueLen;
|
||||
count++;
|
||||
}
|
||||
view.Write(basePos, count);
|
||||
view.Write(NativeProtocol.OffStringParamsLen, (int)(pos - basePos));
|
||||
}
|
||||
|
||||
private void DispatchCallback(
|
||||
MemoryMappedViewAccessor view,
|
||||
Func<string, int, SceneObjectInfo?> resolveObject,
|
||||
@@ -155,7 +259,8 @@ namespace LuaScript.Engine
|
||||
Func<string, (byte[] buffer, int w, int h)> loadImage,
|
||||
Func<string, double, (byte[] buffer, int w, int h)> loadMovie,
|
||||
Action<string, IReadOnlyList<KeyValuePair<string, object>>> addEffect,
|
||||
Action<DrawCommand> addDraw)
|
||||
Action<DrawCommand> addDraw,
|
||||
Action<string, int, bool, int, double[]> setAnchor)
|
||||
{
|
||||
int kind = view.ReadInt32(NativeProtocol.OffCallbackKind);
|
||||
switch (kind)
|
||||
@@ -184,9 +289,33 @@ namespace LuaScript.Engine
|
||||
case NativeProtocol.CbKindDrawPoly:
|
||||
ResolveDrawPolyCallback(view, addDraw);
|
||||
break;
|
||||
case NativeProtocol.CbKindSetAnchor:
|
||||
ResolveSetAnchorCallback(view, setAnchor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResolveSetAnchorCallback(MemoryMappedViewAccessor view, Action<string, int, bool, int, double[]> setAnchor)
|
||||
{
|
||||
int tagLen = Math.Clamp(view.ReadInt32(NativeProtocol.OffCallbackTagLen), 0, NativeProtocol.CallbackTagMax);
|
||||
view.ReadArray(NativeProtocol.CallbackTagOffset, _callbackTag, 0, tagLen);
|
||||
string group = Encoding.UTF8.GetString(_callbackTag, 0, tagLen);
|
||||
|
||||
long rOff = NativeProtocol.CallbackResultOffset;
|
||||
int count = Math.Clamp((int)view.ReadDouble(rOff + 0 * 8), 0, Anchor.AnchorSupport.MaxAnchors);
|
||||
bool is3D = view.ReadDouble(rOff + 1 * 8) != 0d;
|
||||
int connection = (int)view.ReadDouble(rOff + 2 * 8);
|
||||
|
||||
Array.Clear(_anchorBuffer, 0, _anchorBuffer.Length);
|
||||
try { setAnchor(group, count, is3D, connection, _anchorBuffer); }
|
||||
catch { }
|
||||
|
||||
int stride = is3D ? 3 : 2;
|
||||
for (int i = 0; i < count * stride; i++)
|
||||
view.Write(NativeProtocol.CallbackTagOffset + i * 8, _anchorBuffer[i]);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
private static void ResolveDrawCallback(MemoryMappedViewAccessor view, Action<DrawCommand> addDraw)
|
||||
{
|
||||
long rOff = NativeProtocol.CallbackResultOffset;
|
||||
@@ -197,8 +326,9 @@ namespace LuaScript.Engine
|
||||
double alpha = view.ReadDouble(rOff + 4 * 8);
|
||||
double aspect = view.ReadDouble(rOff + 5 * 8);
|
||||
double antialias = view.ReadDouble(rOff + 6 * 8);
|
||||
double blend = view.ReadDouble(rOff + 7 * 8);
|
||||
|
||||
try { addDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, antialias)); }
|
||||
try { addDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, antialias, blend)); }
|
||||
catch { }
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
@@ -209,8 +339,9 @@ namespace LuaScript.Engine
|
||||
for (int i = 0; i < DrawPolyMath.Length; i++)
|
||||
poly[i] = view.ReadDouble(NativeProtocol.CallbackTagOffset + i * 8);
|
||||
double antialias = view.ReadDouble(NativeProtocol.CallbackTagOffset + DrawPolyMath.Length * 8);
|
||||
double blend = view.ReadDouble(NativeProtocol.CallbackTagOffset + (DrawPolyMath.Length + 1) * 8);
|
||||
|
||||
try { addDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, antialias)); }
|
||||
try { addDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, antialias, blend)); }
|
||||
catch { }
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
@@ -264,7 +395,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -273,7 +404,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
WritePixelRegion(result.buffer, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -299,7 +430,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -308,7 +439,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
WritePixelRegion(result.buffer, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -325,7 +456,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -334,7 +465,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
WritePixelRegion(result.buffer, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -352,7 +483,7 @@ namespace LuaScript.Engine
|
||||
catch { result = (new byte[4], 1, 1); }
|
||||
|
||||
int pixelSize = result.w * result.h * 4;
|
||||
long capacity = view.Capacity - NativeProtocol.PixelOffset;
|
||||
long capacity = view.Capacity - _pixelOffset;
|
||||
if (pixelSize > capacity)
|
||||
{
|
||||
result = (new byte[4], 1, 1);
|
||||
@@ -361,7 +492,7 @@ namespace LuaScript.Engine
|
||||
|
||||
view.Write(NativeProtocol.OffLoadResultWidth, result.w);
|
||||
view.Write(NativeProtocol.OffLoadResultHeight, result.h);
|
||||
view.WriteArray(NativeProtocol.PixelOffset, result.buffer, 0, pixelSize);
|
||||
WritePixelRegion(result.buffer, pixelSize);
|
||||
view.Write(NativeProtocol.OffCallbackFound, 1);
|
||||
}
|
||||
|
||||
@@ -409,20 +540,22 @@ namespace LuaScript.Engine
|
||||
return _lastCallbackTagText;
|
||||
}
|
||||
|
||||
private void EnsureWorker(int width, int height)
|
||||
private void EnsureWorker(int width, int height, int stringCapacity)
|
||||
{
|
||||
if (_alive && _process is { HasExited: false } && _width == width && _height == height)
|
||||
long required = NativeProtocol.PixelOffset(stringCapacity) + (long)width * height * 4;
|
||||
if (_alive && _process is { HasExited: false } && _stringParamsCapacity == stringCapacity && required <= _allocatedSize)
|
||||
return;
|
||||
|
||||
KillWorker();
|
||||
StartWorker(width, height);
|
||||
StartWorker(width, height, stringCapacity);
|
||||
}
|
||||
|
||||
private void StartWorker(int width, int height)
|
||||
private void StartWorker(int width, int height, int stringCapacity)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
long size = NativeProtocol.BufferSize(width, height);
|
||||
_stringParamsCapacity = stringCapacity;
|
||||
_pixelOffset = NativeProtocol.PixelOffset(stringCapacity);
|
||||
long size = Math.Max(NativeProtocol.BufferSize(width, height, stringCapacity), _allocatedSize);
|
||||
_allocatedSize = size;
|
||||
|
||||
string suffix = Guid.NewGuid().ToString("N");
|
||||
string mapName = "LuaScriptMap_" + suffix;
|
||||
@@ -449,6 +582,7 @@ namespace LuaScript.Engine
|
||||
psi.ArgumentList.Add(workName);
|
||||
psi.ArgumentList.Add(doneName);
|
||||
psi.ArgumentList.Add(_shimScript);
|
||||
psi.ArgumentList.Add(stringCapacity.ToString());
|
||||
|
||||
_process = Process.Start(psi);
|
||||
if (_process is not null)
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace LuaScript.Engine
|
||||
{
|
||||
internal static class NativeFieldMap
|
||||
{
|
||||
private const double Epsilon = 1e-10;
|
||||
|
||||
public static void ToFields(AviUtlScriptContext ctx, double[] f)
|
||||
{
|
||||
f[NativeProtocol.W] = ctx.ImageWidth;
|
||||
@@ -38,6 +36,10 @@ namespace LuaScript.Engine
|
||||
f[NativeProtocol.Track1] = ctx.Track1;
|
||||
f[NativeProtocol.Track2] = ctx.Track2;
|
||||
f[NativeProtocol.Track3] = ctx.Track3;
|
||||
f[NativeProtocol.Slider0] = ctx.Slider0;
|
||||
f[NativeProtocol.Slider1] = ctx.Slider1;
|
||||
f[NativeProtocol.Slider2] = ctx.Slider2;
|
||||
f[NativeProtocol.Slider3] = ctx.Slider3;
|
||||
f[NativeProtocol.Check0] = ctx.Check0 ? 1d : 0d;
|
||||
f[NativeProtocol.Check1] = ctx.Check1 ? 1d : 0d;
|
||||
f[NativeProtocol.Check2] = ctx.Check2 ? 1d : 0d;
|
||||
@@ -89,6 +91,13 @@ namespace LuaScript.Engine
|
||||
f[NativeProtocol.Rxr],
|
||||
f[NativeProtocol.Ryr],
|
||||
f[NativeProtocol.Rzr]);
|
||||
|
||||
ctx.DrawStateOverride = f[NativeProtocol.DrawState] switch
|
||||
{
|
||||
1d => true,
|
||||
2d => false,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace LuaScript.Engine
|
||||
public const int OffCallbackKind = 44;
|
||||
public const int OffLoadResultWidth = 48;
|
||||
public const int OffLoadResultHeight = 52;
|
||||
public const int OffStringParamsLen = 56;
|
||||
|
||||
public const int HeaderSize = 64;
|
||||
|
||||
@@ -43,6 +44,9 @@ namespace LuaScript.Engine
|
||||
public const int CallbackResultOffset = CallbackTagOffset + CallbackTagMax;
|
||||
public const int CallbackResultCount = 8;
|
||||
|
||||
public const int StringParamsOffset = CallbackResultOffset + CallbackResultCount * 8;
|
||||
public const int MinStringParamsCapacity = 64 * 1024;
|
||||
|
||||
public const int CbKindGetObject = 0;
|
||||
public const int CbKindLoadFigure = 1;
|
||||
public const int CbKindEffect = 2;
|
||||
@@ -51,6 +55,8 @@ namespace LuaScript.Engine
|
||||
public const int CbKindLoadText = 5;
|
||||
public const int CbKindLoadImage = 6;
|
||||
public const int CbKindLoadMovie = 7;
|
||||
public const int CbKindSetAnchor = 8;
|
||||
public const int CbKindRequestPixels = 9;
|
||||
|
||||
public const int CbExist = 0;
|
||||
public const int CbX = 1;
|
||||
@@ -61,7 +67,7 @@ namespace LuaScript.Engine
|
||||
public const int CbAlpha = 6;
|
||||
public const int CbLayer = 7;
|
||||
|
||||
public const int PixelOffset = CallbackResultOffset + CallbackResultCount * 8;
|
||||
public static int PixelOffset(int stringCapacity) => StringParamsOffset + stringCapacity;
|
||||
|
||||
public const int W = 0;
|
||||
public const int H = 1;
|
||||
@@ -121,13 +127,18 @@ namespace LuaScript.Engine
|
||||
public const int Check2 = 55;
|
||||
public const int Check3 = 56;
|
||||
public const int Color = 57;
|
||||
public const int Slider0 = 58;
|
||||
public const int Slider1 = 59;
|
||||
public const int Slider2 = 60;
|
||||
public const int Slider3 = 61;
|
||||
public const int DrawState = 62;
|
||||
|
||||
public const int FirstWritableField = X;
|
||||
public const int LastWritableField = Rzr;
|
||||
|
||||
public const int MaxPixelBufferSize = 3840 * 2160 * 4;
|
||||
|
||||
public static long BufferSize(int width, int height) =>
|
||||
PixelOffset + Math.Max((long)width * height * 4, MaxPixelBufferSize);
|
||||
public static long BufferSize(int width, int height, int stringCapacity) =>
|
||||
PixelOffset(stringCapacity) + Math.Max((long)width * height * 4, MaxPixelBufferSize);
|
||||
}
|
||||
}
|
||||
@@ -9,23 +9,14 @@ namespace LuaScript.Engine
|
||||
|
||||
public static ScriptEngineKind ResolveAuto(string? script)
|
||||
{
|
||||
if (TryGetDirective(script, out var kind))
|
||||
return kind;
|
||||
if (UsesDrawingApi(script))
|
||||
if (string.IsNullOrEmpty(script))
|
||||
return ScriptEngineKind.MoonSharp;
|
||||
return UsesPixelApi(script) ? ScriptEngineKind.Native : ScriptEngineKind.MoonSharp;
|
||||
return TryGetDirective(script, out var kind) ? kind : ScriptEngineKind.Native;
|
||||
}
|
||||
|
||||
public static bool TryResolveExplicit(string? script, out ScriptEngineKind kind) =>
|
||||
TryGetDirective(script, out kind);
|
||||
|
||||
public static bool UsesPixelApi(string? script) =>
|
||||
script is not null && (script.Contains("getpixel", StringComparison.Ordinal) || script.Contains("setpixel", StringComparison.Ordinal));
|
||||
|
||||
public static bool UsesDrawingApi(string? script) =>
|
||||
script is not null &&
|
||||
script.Contains("obj.setoption", StringComparison.Ordinal);
|
||||
|
||||
private static bool TryGetDirective(string? script, out ScriptEngineKind kind)
|
||||
{
|
||||
kind = ScriptEngineKind.MoonSharp;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
internal sealed class FallbackCompositor(
|
||||
IBufferCompositor primary,
|
||||
IBufferCompositor fallback,
|
||||
Action<Exception>? onDegraded = null) : IBufferCompositor, IDisposable
|
||||
{
|
||||
private bool _degraded;
|
||||
|
||||
public bool IsDegraded => _degraded;
|
||||
|
||||
public void Compose(byte[] dst, int dstW, int dstH, byte[] src, int srcW, int srcH, in DrawCommand command)
|
||||
{
|
||||
if (!_degraded)
|
||||
{
|
||||
try
|
||||
{
|
||||
primary.Compose(dst, dstW, dstH, src, srcW, srcH, command);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_degraded = true;
|
||||
onDegraded?.Invoke(ex);
|
||||
}
|
||||
}
|
||||
fallback.Compose(dst, dstW, dstH, src, srcW, srcH, command);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
(primary as IDisposable)?.Dispose();
|
||||
(fallback as IDisposable)?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Vortice.DCommon;
|
||||
using Vortice.Direct2D1;
|
||||
using Vortice.DXGI;
|
||||
using Vortice.Mathematics;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
internal sealed class HardwareCompositor : IBufferCompositor, IDisposable
|
||||
{
|
||||
private readonly GraphicsDevicesAndContext _ctx;
|
||||
private ID2D1Bitmap1? _source;
|
||||
private ID2D1Bitmap1? _target;
|
||||
private ID2D1Bitmap1? _staging;
|
||||
private int _sourceWidth;
|
||||
private int _sourceHeight;
|
||||
private int _targetWidth;
|
||||
private int _targetHeight;
|
||||
|
||||
public HardwareCompositor(GraphicsDevicesAndContext ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
public unsafe void Compose(byte[] dst, int dstW, int dstH, byte[] src, int srcW, int srcH, in DrawCommand command)
|
||||
{
|
||||
if (srcW <= 0 || srcH <= 0 || dstW <= 0 || dstH <= 0)
|
||||
return;
|
||||
if (src.Length < srcW * srcH * 4 || dst.Length < dstW * dstH * 4)
|
||||
return;
|
||||
if (!DrawTransform.TryResolve(command, srcW, srcH, out var transform))
|
||||
return;
|
||||
|
||||
float opacity = (float)Math.Clamp(command.Alpha, 0d, 1d);
|
||||
if (opacity <= 0f)
|
||||
return;
|
||||
|
||||
EnsureSource(srcW, srcH);
|
||||
EnsureTarget(dstW, dstH);
|
||||
|
||||
fixed (byte* ptr = src)
|
||||
_source!.CopyFromMemory(new nint(ptr), srcW * 4);
|
||||
fixed (byte* ptr = dst)
|
||||
_target!.CopyFromMemory(new nint(ptr), dstW * 4);
|
||||
|
||||
var interpolation = command.Antialias != 0d
|
||||
? BitmapInterpolationMode.Linear
|
||||
: BitmapInterpolationMode.NearestNeighbor;
|
||||
|
||||
var dc = _ctx.DeviceContext;
|
||||
var rt = (ID2D1RenderTarget)dc;
|
||||
var savedTarget = dc.Target;
|
||||
dc.Target = _target;
|
||||
try
|
||||
{
|
||||
dc.BeginDraw();
|
||||
rt.Transform = transform;
|
||||
rt.DrawBitmap(_source!, opacity, interpolation);
|
||||
rt.Transform = Matrix3x2.Identity;
|
||||
dc.EndDraw();
|
||||
}
|
||||
finally
|
||||
{
|
||||
dc.Target = savedTarget;
|
||||
}
|
||||
|
||||
_staging!.CopyFromBitmap(_target!);
|
||||
var mapped = _staging.Map(MapOptions.Read);
|
||||
try
|
||||
{
|
||||
if (mapped.Pitch == dstW * 4)
|
||||
{
|
||||
Marshal.Copy(mapped.Bits, dst, 0, dstW * dstH * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int row = 0; row < dstH; row++)
|
||||
Marshal.Copy(mapped.Bits + mapped.Pitch * row, dst, row * dstW * 4, dstW * 4);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_staging.Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureSource(int width, int height)
|
||||
{
|
||||
if (_source is not null && _sourceWidth == width && _sourceHeight == height)
|
||||
return;
|
||||
|
||||
_source?.Dispose();
|
||||
_source = _ctx.DeviceContext.CreateEmptyBitmap(width, height, BitmapOptions.Target);
|
||||
_sourceWidth = width;
|
||||
_sourceHeight = height;
|
||||
}
|
||||
|
||||
private void EnsureTarget(int width, int height)
|
||||
{
|
||||
if (_target is not null && _targetWidth == width && _targetHeight == height)
|
||||
return;
|
||||
|
||||
_target?.Dispose();
|
||||
_staging?.Dispose();
|
||||
_target = null;
|
||||
_staging = null;
|
||||
|
||||
var dc = _ctx.DeviceContext;
|
||||
_target = dc.CreateEmptyBitmap(width, height, BitmapOptions.Target);
|
||||
|
||||
var stagingProps = new BitmapProperties1(
|
||||
new PixelFormat(Format.B8G8R8A8_UNorm, Vortice.DCommon.AlphaMode.Premultiplied),
|
||||
96f, 96f,
|
||||
BitmapOptions.CpuRead | BitmapOptions.CannotDraw);
|
||||
_staging = dc.CreateBitmap(new SizeI(width, height), nint.Zero, width * 4, stagingProps);
|
||||
|
||||
_targetWidth = width;
|
||||
_targetHeight = height;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_source?.Dispose();
|
||||
_target?.Dispose();
|
||||
_staging?.Dispose();
|
||||
_source = null;
|
||||
_target = null;
|
||||
_staging = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace LuaScript
|
||||
{
|
||||
internal interface IBufferCompositor
|
||||
{
|
||||
void Compose(byte[] dst, int dstW, int dstH, byte[] src, int srcW, int srcH, in DrawCommand command);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,11 @@ namespace LuaScript
|
||||
"obj.rx", "obj.ry", "obj.rz",
|
||||
"obj.rxr", "obj.ryr", "obj.rzr",
|
||||
"obj.track0", "obj.track1", "obj.track2", "obj.track3",
|
||||
"obj.slider0", "obj.slider1", "obj.slider2", "obj.slider3",
|
||||
"obj.check0", "obj.check1", "obj.check2", "obj.check3",
|
||||
"obj.text", "obj.font", "obj.dir",
|
||||
"obj.file_video", "obj.file_audio", "obj.file_image", "obj.file_project",
|
||||
"obj.file_mp4", "obj.file_exo", "obj.file_subtitle", "obj.file_shader",
|
||||
"obj.time", "obj.totaltime", "obj.t", "obj.frame", "obj.totalframe",
|
||||
"obj.framerate", "obj.layer", "obj.index", "obj.num",
|
||||
"obj.getpixel", "obj.setpixel",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net10.0-windows10.0.19041.0</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>1.9.4</Version>
|
||||
<Version>1.11.2</Version>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Windows.Media;
|
||||
using LuaScript.Anchor;
|
||||
using LuaScript.Compat;
|
||||
using Newtonsoft.Json;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
@@ -10,6 +13,7 @@ using YukkuriMovieMaker.ItemEditor.CustomVisibilityAttributes;
|
||||
using YukkuriMovieMaker.Player.Video;
|
||||
using YukkuriMovieMaker.Plugin;
|
||||
using YukkuriMovieMaker.Plugin.Effects;
|
||||
using YukkuriMovieMaker.Settings;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
@@ -62,6 +66,34 @@ namespace LuaScript
|
||||
[ShowPropertyEditorWhen(nameof(IsTrack3Visible), true)]
|
||||
public Animation Track3 { get; } = new Animation(0, YMM4Constants.VerySmallValue, YMM4Constants.VeryLargeValue);
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider0), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", 1, 10)]
|
||||
[DefaultValue(1)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider0Visible), true)]
|
||||
public int Slider0 { get => _slider0; set => Set(ref _slider0, value); }
|
||||
int _slider0 = 1;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider1), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", 0, 100)]
|
||||
[DefaultValue(0)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider1Visible), true)]
|
||||
public int Slider1 { get => _slider1; set => Set(ref _slider1, value); }
|
||||
int _slider1;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider2), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", 0, 1000)]
|
||||
[DefaultValue(0)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider2Visible), true)]
|
||||
public int Slider2 { get => _slider2; set => Set(ref _slider2, value); }
|
||||
int _slider2;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Slider3), Description = nameof(Texts.SliderDesc), ResourceType = typeof(Texts))]
|
||||
[TextBoxSlider("F0", "", -1000, 1000)]
|
||||
[DefaultValue(0)]
|
||||
[ShowPropertyEditorWhen(nameof(IsSlider3Visible), true)]
|
||||
public int Slider3 { get => _slider3; set => Set(ref _slider3, value); }
|
||||
int _slider3;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Check0), Description = nameof(Texts.CheckDesc), ResourceType = typeof(Texts))]
|
||||
[ToggleSlider]
|
||||
[ShowPropertyEditorWhen(nameof(IsCheck0Visible), true)]
|
||||
@@ -92,6 +124,76 @@ namespace LuaScript
|
||||
public Color Color { get => _color; set => Set(ref _color, value); }
|
||||
Color _color = Colors.White;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Text), Description = nameof(Texts.TextDesc), ResourceType = typeof(Texts))]
|
||||
[TextEditor(AcceptsReturn = true, PropertyEditorSize = PropertyEditorSize.FullWidth)]
|
||||
[ShowPropertyEditorWhen(nameof(IsTextVisible), true)]
|
||||
public string Text { get => _text; set => Set(ref _text, value); }
|
||||
string _text = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Font), Description = nameof(Texts.FontDesc), ResourceType = typeof(Texts))]
|
||||
[FontComboBox]
|
||||
[ShowPropertyEditorWhen(nameof(IsFontVisible), true)]
|
||||
public string Font { get => _font; set => Set(ref _font, value); }
|
||||
string _font = "メイリオ";
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.Directory), Description = nameof(Texts.DirectoryDesc), ResourceType = typeof(Texts))]
|
||||
[DirectorySelector(PropertyEditorSize = PropertyEditorSize.FullWidth)]
|
||||
[ShowPropertyEditorWhen(nameof(IsDirectoryVisible), true)]
|
||||
public string Directory { get => _directory; set => Set(ref _directory, value); }
|
||||
string _directory = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileVideo), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.VideoItem)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileVideoVisible), true)]
|
||||
public string FileVideo { get => _fileVideo; set => Set(ref _fileVideo, value); }
|
||||
string _fileVideo = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileAudio), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.AudioItem)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileAudioVisible), true)]
|
||||
public string FileAudio { get => _fileAudio; set => Set(ref _fileAudio, value); }
|
||||
string _fileAudio = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileImage), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.ImageItem)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileImageVisible), true)]
|
||||
public string FileImage { get => _fileImage; set => Set(ref _fileImage, value); }
|
||||
string _fileImage = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileProject), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.Project)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileProjectVisible), true)]
|
||||
public string FileProject { get => _fileProject; set => Set(ref _fileProject, value); }
|
||||
string _fileProject = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileMp4), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.MP4)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileMp4Visible), true)]
|
||||
public string FileMp4 { get => _fileMp4; set => Set(ref _fileMp4, value); }
|
||||
string _fileMp4 = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileExo), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.Exo)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileExoVisible), true)]
|
||||
public string FileExo { get => _fileExo; set => Set(ref _fileExo, value); }
|
||||
string _fileExo = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileSubtitle), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.Subtitle)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileSubtitleVisible), true)]
|
||||
public string FileSubtitle { get => _fileSubtitle; set => Set(ref _fileSubtitle, value); }
|
||||
string _fileSubtitle = string.Empty;
|
||||
|
||||
[Display(GroupName = nameof(Texts.ParametersGroup), Name = nameof(Texts.FileShader), Description = nameof(Texts.FileDesc), ResourceType = typeof(Texts))]
|
||||
[FileSelector(FileGroupType.PixelShaderSource)]
|
||||
[ShowPropertyEditorWhen(nameof(IsFileShaderVisible), true)]
|
||||
public string FileShader { get => _fileShader; set => Set(ref _fileShader, value); }
|
||||
string _fileShader = string.Empty;
|
||||
|
||||
[JsonIgnore] public bool IsSlider0Visible { get => _isSlider0Visible; private set => Set(ref _isSlider0Visible, value); }
|
||||
[JsonIgnore] public bool IsSlider1Visible { get => _isSlider1Visible; private set => Set(ref _isSlider1Visible, value); }
|
||||
[JsonIgnore] public bool IsSlider2Visible { get => _isSlider2Visible; private set => Set(ref _isSlider2Visible, value); }
|
||||
[JsonIgnore] public bool IsSlider3Visible { get => _isSlider3Visible; private set => Set(ref _isSlider3Visible, value); }
|
||||
[JsonIgnore] public bool IsTrack0Visible { get => _isTrack0Visible; private set => Set(ref _isTrack0Visible, value); }
|
||||
[JsonIgnore] public bool IsTrack1Visible { get => _isTrack1Visible; private set => Set(ref _isTrack1Visible, value); }
|
||||
[JsonIgnore] public bool IsTrack2Visible { get => _isTrack2Visible; private set => Set(ref _isTrack2Visible, value); }
|
||||
@@ -101,7 +203,22 @@ namespace LuaScript
|
||||
[JsonIgnore] public bool IsCheck2Visible { get => _isCheck2Visible; private set => Set(ref _isCheck2Visible, value); }
|
||||
[JsonIgnore] public bool IsCheck3Visible { get => _isCheck3Visible; private set => Set(ref _isCheck3Visible, value); }
|
||||
[JsonIgnore] public bool IsColorVisible { get => _isColorVisible; private set => Set(ref _isColorVisible, value); }
|
||||
[JsonIgnore] public bool IsTextVisible { get => _isTextVisible; private set => Set(ref _isTextVisible, value); }
|
||||
[JsonIgnore] public bool IsFontVisible { get => _isFontVisible; private set => Set(ref _isFontVisible, value); }
|
||||
[JsonIgnore] public bool IsDirectoryVisible { get => _isDirectoryVisible; private set => Set(ref _isDirectoryVisible, value); }
|
||||
[JsonIgnore] public bool IsFileVideoVisible { get => _isFileVideoVisible; private set => Set(ref _isFileVideoVisible, value); }
|
||||
[JsonIgnore] public bool IsFileAudioVisible { get => _isFileAudioVisible; private set => Set(ref _isFileAudioVisible, value); }
|
||||
[JsonIgnore] public bool IsFileImageVisible { get => _isFileImageVisible; private set => Set(ref _isFileImageVisible, value); }
|
||||
[JsonIgnore] public bool IsFileProjectVisible { get => _isFileProjectVisible; private set => Set(ref _isFileProjectVisible, value); }
|
||||
[JsonIgnore] public bool IsFileMp4Visible { get => _isFileMp4Visible; private set => Set(ref _isFileMp4Visible, value); }
|
||||
[JsonIgnore] public bool IsFileExoVisible { get => _isFileExoVisible; private set => Set(ref _isFileExoVisible, value); }
|
||||
[JsonIgnore] public bool IsFileSubtitleVisible { get => _isFileSubtitleVisible; private set => Set(ref _isFileSubtitleVisible, value); }
|
||||
[JsonIgnore] public bool IsFileShaderVisible { get => _isFileShaderVisible; private set => Set(ref _isFileShaderVisible, value); }
|
||||
|
||||
bool _isSlider0Visible;
|
||||
bool _isSlider1Visible;
|
||||
bool _isSlider2Visible;
|
||||
bool _isSlider3Visible;
|
||||
bool _isTrack0Visible = true;
|
||||
bool _isTrack1Visible = true;
|
||||
bool _isTrack2Visible = true;
|
||||
@@ -111,6 +228,17 @@ namespace LuaScript
|
||||
bool _isCheck2Visible;
|
||||
bool _isCheck3Visible;
|
||||
bool _isColorVisible;
|
||||
bool _isTextVisible;
|
||||
bool _isFontVisible;
|
||||
bool _isDirectoryVisible;
|
||||
bool _isFileVideoVisible;
|
||||
bool _isFileAudioVisible;
|
||||
bool _isFileImageVisible;
|
||||
bool _isFileProjectVisible;
|
||||
bool _isFileMp4Visible;
|
||||
bool _isFileExoVisible;
|
||||
bool _isFileSubtitleVisible;
|
||||
bool _isFileShaderVisible;
|
||||
|
||||
private void UpdateLayout()
|
||||
{
|
||||
@@ -120,6 +248,10 @@ namespace LuaScript
|
||||
bool hasAny = layout.HasAny;
|
||||
var usage = ScriptParameterUsage.Detect(_script);
|
||||
|
||||
IsSlider0Visible = usage.Slider(0);
|
||||
IsSlider1Visible = usage.Slider(1);
|
||||
IsSlider2Visible = usage.Slider(2);
|
||||
IsSlider3Visible = usage.Slider(3);
|
||||
IsTrack0Visible = !hasAny || layout.HasTrack(0);
|
||||
IsTrack1Visible = !hasAny || layout.HasTrack(1);
|
||||
IsTrack2Visible = !hasAny || layout.HasTrack(2);
|
||||
@@ -129,6 +261,17 @@ namespace LuaScript
|
||||
IsCheck2Visible = layout.HasCheck(2) || (!hasAny && usage.Check2);
|
||||
IsCheck3Visible = layout.HasCheck(3) || (!hasAny && usage.Check3);
|
||||
IsColorVisible = layout.HasColor || (!hasAny && usage.Color);
|
||||
IsTextVisible = usage.Uses("text");
|
||||
IsFontVisible = usage.Uses("font");
|
||||
IsDirectoryVisible = usage.Uses("dir");
|
||||
IsFileVideoVisible = usage.Uses("file_video");
|
||||
IsFileAudioVisible = usage.Uses("file_audio");
|
||||
IsFileImageVisible = usage.Uses("file_image");
|
||||
IsFileProjectVisible = usage.Uses("file_project");
|
||||
IsFileMp4Visible = usage.Uses("file_mp4");
|
||||
IsFileExoVisible = usage.Uses("file_exo");
|
||||
IsFileSubtitleVisible = usage.Uses("file_subtitle");
|
||||
IsFileShaderVisible = usage.Uses("file_shader");
|
||||
|
||||
SeedDefaults(layout);
|
||||
}
|
||||
@@ -152,6 +295,19 @@ namespace LuaScript
|
||||
return Color.FromRgb(r, g, b);
|
||||
}
|
||||
|
||||
public ImmutableList<LuaAnchorPoint> Anchors
|
||||
{
|
||||
get => _anchors;
|
||||
set { if (Set(ref _anchors, value ?? ImmutableList<LuaAnchorPoint>.Empty)) AnchorVersion++; }
|
||||
}
|
||||
ImmutableList<LuaAnchorPoint> _anchors = ImmutableList<LuaAnchorPoint>.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
internal int AnchorVersion { get; private set; }
|
||||
|
||||
internal void ApplyAnchorDrag(string group, int index, double dx, double dy, double dz)
|
||||
=> Anchors = AnchorSupport.ApplyDrag(Anchors, group, index, dx, dy, dz);
|
||||
|
||||
public override IEnumerable<string> CreateExoVideoFilters(int keyFrameIndex, ExoOutputDescription exoOutputDescription) => [];
|
||||
|
||||
public override IVideoEffectProcessor CreateVideoEffect(IGraphicsDevicesAndContext devices)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using LuaScript.Anchor;
|
||||
using LuaScript.Compat;
|
||||
using LuaScript.Diagnostics;
|
||||
using LuaScript.Engine;
|
||||
@@ -30,6 +32,10 @@ namespace LuaScript
|
||||
double Track1,
|
||||
double Track2,
|
||||
double Track3,
|
||||
double Slider0,
|
||||
double Slider1,
|
||||
double Slider2,
|
||||
double Slider3,
|
||||
bool Check0,
|
||||
bool Check1,
|
||||
bool Check2,
|
||||
@@ -37,6 +43,7 @@ namespace LuaScript
|
||||
bool HasColor,
|
||||
int Color,
|
||||
string Script,
|
||||
int StringsVersion,
|
||||
TimelineSourceUsage Usage,
|
||||
Guid SceneId,
|
||||
int TimelineFrame,
|
||||
@@ -50,6 +57,7 @@ namespace LuaScript
|
||||
int GroupCount,
|
||||
int TimelineTotalFrame,
|
||||
double TimelineTotalTime,
|
||||
int AnchorVersion,
|
||||
DrawDescription InputDesc
|
||||
);
|
||||
|
||||
@@ -88,6 +96,28 @@ namespace LuaScript
|
||||
|
||||
private PixelBufferManager? _pixelManager;
|
||||
|
||||
private RawRectF _pixelBounds;
|
||||
private int _pixelWidth;
|
||||
private int _pixelHeight;
|
||||
private Func<byte[]>? _pixelLoader;
|
||||
|
||||
private string _directiveSource = string.Empty;
|
||||
private bool _directiveCached;
|
||||
private ScriptEngineKind _autoKind;
|
||||
private bool _hasExplicitDirective;
|
||||
private ScriptEngineKind _explicitDirectiveKind;
|
||||
|
||||
private byte[]? _nativeInputPixels;
|
||||
private Func<byte[]>? _nativeLoadInput;
|
||||
private Func<string, int, SceneObjectInfo?>? _nativeResolveObject;
|
||||
private Func<string, int, double, double, double, (byte[] buffer, int w, int h)>? _nativeLoadFigure;
|
||||
private Func<string, string, double, bool, bool, int, (byte[] buffer, int w, int h)>? _nativeLoadText;
|
||||
private Func<string, (byte[] buffer, int w, int h)>? _nativeLoadImage;
|
||||
private Func<string, double, (byte[] buffer, int w, int h)>? _nativeLoadMovie;
|
||||
private Action<string, IReadOnlyList<KeyValuePair<string, object>>>? _nativeAddEffect;
|
||||
private Action<DrawCommand>? _nativeAddDraw;
|
||||
private Action<string, int, bool, int, double[]>? _nativeSetAnchor;
|
||||
|
||||
private bool _isFirst = true;
|
||||
private string _sourceScript = string.Empty;
|
||||
private string _runnableScript = string.Empty;
|
||||
@@ -101,6 +131,7 @@ namespace LuaScript
|
||||
|
||||
private VideoEffectChain? _effectChain;
|
||||
private DrawCompositor? _drawCompositor;
|
||||
private FallbackCompositor? _bufferCompositor;
|
||||
private TextRenderer? _nativeTextRenderer;
|
||||
private ImageDecoder? _nativeImageDecoder;
|
||||
private MovieDecoder? _nativeMovieDecoder;
|
||||
@@ -110,10 +141,26 @@ namespace LuaScript
|
||||
_ownCtx = new GraphicsDevicesAndContext(devices);
|
||||
disposer.Collect(_ownCtx);
|
||||
_pixelManager = new PixelBufferManager(_ownCtx);
|
||||
_bufferCompositor = new FallbackCompositor(
|
||||
new HardwareCompositor(_ownCtx),
|
||||
new SoftwareCompositor(),
|
||||
WarnBufferCompositorDegraded);
|
||||
_context.ResolverProvider = GetFrameResolver;
|
||||
_context.Compositor = _bufferCompositor;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void WarnBufferCompositorDegraded(Exception ex) =>
|
||||
Log.Default.Write("LuaScript: hardware buffer compositing failed; falling back to the software compositor.", ex);
|
||||
|
||||
private AviUtlScriptContext CreateScriptContext()
|
||||
{
|
||||
var context = new AviUtlScriptContext { ResolverProvider = GetFrameResolver };
|
||||
if (_bufferCompositor is not null)
|
||||
context.Compositor = _bufferCompositor;
|
||||
return context;
|
||||
}
|
||||
|
||||
private SceneObjectResolver GetFrameResolver()
|
||||
{
|
||||
if (!_frameResolverBuilt)
|
||||
@@ -203,6 +250,7 @@ namespace LuaScript
|
||||
var t3 = ClampTrack(item.Track3.GetValue(frame, length, fps), layout, 3);
|
||||
|
||||
bool c0 = item.Check0, c1 = item.Check1, c2 = item.Check2, c3 = item.Check3;
|
||||
double s0 = item.Slider0, s1 = item.Slider1, s2 = item.Slider2, s3 = item.Slider3;
|
||||
bool hasColor = item.IsColorVisible;
|
||||
int colorRgb = hasColor ? (item.Color.R << 16) | (item.Color.G << 8) | item.Color.B : 0;
|
||||
|
||||
@@ -211,8 +259,10 @@ namespace LuaScript
|
||||
var key = new RenderKey(
|
||||
frame, time, length, fps,
|
||||
t0, t1, t2, t3,
|
||||
s0, s1, s2, s3,
|
||||
c0, c1, c2, c3, hasColor, colorRgb,
|
||||
script, desc.Usage, desc.SceneId,
|
||||
script, RefreshStringParameters(),
|
||||
desc.Usage, desc.SceneId,
|
||||
desc.TimelinePosition.Frame,
|
||||
desc.TimelinePosition.Time.TotalSeconds,
|
||||
desc.ScreenSize.Width, desc.ScreenSize.Height,
|
||||
@@ -220,6 +270,7 @@ namespace LuaScript
|
||||
desc.GroupIndex, desc.GroupCount,
|
||||
desc.TimelineDuration.Frame,
|
||||
desc.TimelineDuration.Time.TotalSeconds,
|
||||
item.AnchorVersion,
|
||||
inDesc);
|
||||
|
||||
_frameDesc = desc;
|
||||
@@ -239,7 +290,10 @@ namespace LuaScript
|
||||
|
||||
var ctx = _context;
|
||||
PopulateContext(ctx, in key, imgW, imgH);
|
||||
ctx.SetPixelLoader(() => LoadInputPixels(bounds, imgW, imgH));
|
||||
_pixelBounds = bounds;
|
||||
_pixelWidth = imgW;
|
||||
_pixelHeight = imgH;
|
||||
ctx.SetPixelLoader(_pixelLoader ??= LoadPendingInputPixels);
|
||||
|
||||
DrawDescription outDesc = inDesc;
|
||||
IReadOnlyList<LuaScriptDiagnostic> diagnostics = [];
|
||||
@@ -248,14 +302,15 @@ namespace LuaScript
|
||||
{
|
||||
string runnable = GetRunnableScript(script);
|
||||
EnsureKernel(runnable);
|
||||
EnsureDirective(runnable);
|
||||
|
||||
if (ExecuteKernelLane(runnable, ctx, bounds, imgW, imgH))
|
||||
if (ExecuteKernelLane(ctx, bounds, imgW, imgH))
|
||||
{
|
||||
outDesc = inDesc;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool wantNative = ScriptDirective.ResolveAuto(runnable) == ScriptEngineKind.Native;
|
||||
bool wantNative = _autoKind == ScriptEngineKind.Native;
|
||||
bool nativeReady = wantNative && LuaJitWorker.IsAvailable(NativeDirectory);
|
||||
if (wantNative && !nativeReady)
|
||||
WarnNativeUnavailableOnce();
|
||||
@@ -295,6 +350,8 @@ namespace LuaScript
|
||||
}
|
||||
}
|
||||
|
||||
ApplyDrawState(ctx, bounds);
|
||||
|
||||
outDesc = BuildOutputDesc(inDesc, ctx);
|
||||
|
||||
if (ctx.EffectRequests.Count > 0)
|
||||
@@ -310,12 +367,14 @@ namespace LuaScript
|
||||
WarnEffectChainFailureOnce(ex);
|
||||
}
|
||||
}
|
||||
|
||||
outDesc = AddAnchorControllers(outDesc, ctx);
|
||||
}
|
||||
}
|
||||
catch (LuaScriptTimeoutException ex)
|
||||
{
|
||||
effectOutput = null;
|
||||
_context = new AviUtlScriptContext { ResolverProvider = GetFrameResolver };
|
||||
_context = CreateScriptContext();
|
||||
_isFirst = true;
|
||||
Log.Default.Write(ex.Message, ex);
|
||||
LuaScriptDiagnostics.Instance.Report(script, [CreateDiagnostic(LuaScriptDiagnosticKind.Timeout, ex.Message)]);
|
||||
@@ -399,6 +458,52 @@ namespace LuaScript
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly string[] s_stringParameterNames =
|
||||
[
|
||||
"text", "font", "dir",
|
||||
"file_video", "file_audio", "file_image", "file_project",
|
||||
"file_mp4", "file_exo", "file_subtitle", "file_shader",
|
||||
];
|
||||
|
||||
private readonly string?[] _stringParameterValues = new string?[s_stringParameterNames.Length];
|
||||
private int _stringParametersVersion;
|
||||
|
||||
private int RefreshStringParameters()
|
||||
{
|
||||
var values = _stringParameterValues;
|
||||
bool changed = false;
|
||||
changed |= UpdateStringSlot(values, 0, item.Text);
|
||||
changed |= UpdateStringSlot(values, 1, item.Font);
|
||||
changed |= UpdateStringSlot(values, 2, item.Directory);
|
||||
changed |= UpdateStringSlot(values, 3, item.FileVideo);
|
||||
changed |= UpdateStringSlot(values, 4, item.FileAudio);
|
||||
changed |= UpdateStringSlot(values, 5, item.FileImage);
|
||||
changed |= UpdateStringSlot(values, 6, item.FileProject);
|
||||
changed |= UpdateStringSlot(values, 7, item.FileMp4);
|
||||
changed |= UpdateStringSlot(values, 8, item.FileExo);
|
||||
changed |= UpdateStringSlot(values, 9, item.FileSubtitle);
|
||||
changed |= UpdateStringSlot(values, 10, item.FileShader);
|
||||
if (changed)
|
||||
_stringParametersVersion++;
|
||||
return _stringParametersVersion;
|
||||
}
|
||||
|
||||
private static bool UpdateStringSlot(string?[] values, int index, string value)
|
||||
{
|
||||
if (ReferenceEquals(values[index], value))
|
||||
return false;
|
||||
values[index] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PopulateStringParameters(AviUtlScriptContext ctx)
|
||||
{
|
||||
var names = s_stringParameterNames;
|
||||
var values = _stringParameterValues;
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
ctx.SetStringParameter(names[i], values[i]);
|
||||
}
|
||||
|
||||
private void PopulateContext(AviUtlScriptContext ctx, in RenderKey key, int imgW, int imgH)
|
||||
{
|
||||
var zoom = key.InputDesc.Zoom;
|
||||
@@ -410,6 +515,10 @@ namespace LuaScript
|
||||
ctx.ClearQueries();
|
||||
ctx.ClearEffects();
|
||||
ctx.ClearDraws();
|
||||
ctx.ClearAnchorRequests();
|
||||
ctx.AnchorSource = item.Anchors;
|
||||
ctx.DrawStateOverride = null;
|
||||
ctx.ResetDrawTarget();
|
||||
|
||||
ctx.ImageWidth = imgW;
|
||||
ctx.ImageHeight = imgH;
|
||||
@@ -431,6 +540,10 @@ namespace LuaScript
|
||||
ctx.Track1 = key.Track1;
|
||||
ctx.Track2 = key.Track2;
|
||||
ctx.Track3 = key.Track3;
|
||||
ctx.Slider0 = key.Slider0;
|
||||
ctx.Slider1 = key.Slider1;
|
||||
ctx.Slider2 = key.Slider2;
|
||||
ctx.Slider3 = key.Slider3;
|
||||
ctx.Check0 = key.Check0;
|
||||
ctx.Check1 = key.Check1;
|
||||
ctx.Check2 = key.Check2;
|
||||
@@ -458,6 +571,7 @@ namespace LuaScript
|
||||
ctx.IsPaused = key.Usage == TimelineSourceUsage.Paused;
|
||||
ctx.SceneId = ResolveSceneId(key.SceneId);
|
||||
ctx.TimeRatio = key.Length > 0 ? key.Frame / (double)key.Length : 0d;
|
||||
PopulateStringParameters(ctx);
|
||||
}
|
||||
|
||||
private static double ClampTrack(double value, AviUtlParameterLayout layout, int index)
|
||||
@@ -465,6 +579,143 @@ namespace LuaScript
|
||||
return layout.GetTrack(index) is { } p ? Math.Clamp(value, p.Min, p.Max) : value;
|
||||
}
|
||||
|
||||
private ImmutableList<VideoEffectController> _anchorControllers = ImmutableList<VideoEffectController>.Empty;
|
||||
private AnchorRequestData[] _anchorSignature = [];
|
||||
private IReadOnlyList<LuaAnchorPoint>? _anchorSignatureSource;
|
||||
|
||||
private ImmutableList<VideoEffectController> ResolveAnchorControllers(AviUtlScriptContext ctx)
|
||||
{
|
||||
var requests = ctx.AnchorRequests;
|
||||
if (requests.Count == 0)
|
||||
{
|
||||
_anchorControllers = ImmutableList<VideoEffectController>.Empty;
|
||||
_anchorSignature = [];
|
||||
_anchorSignatureSource = null;
|
||||
return _anchorControllers;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(_anchorSignatureSource, ctx.AnchorSource) && AnchorSignatureMatches(requests))
|
||||
return _anchorControllers;
|
||||
|
||||
_anchorControllers = BuildAnchorControllers(ctx.AnchorSource, requests);
|
||||
_anchorSignature = new AnchorRequestData[requests.Count];
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
_anchorSignature[i] = requests[i];
|
||||
_anchorSignatureSource = ctx.AnchorSource;
|
||||
return _anchorControllers;
|
||||
}
|
||||
|
||||
private bool AnchorSignatureMatches(IReadOnlyList<AnchorRequestData> requests)
|
||||
{
|
||||
if (_anchorSignature.Length != requests.Count)
|
||||
return false;
|
||||
for (int i = 0; i < requests.Count; i++)
|
||||
if (!_anchorSignature[i].Equals(requests[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private DrawDescription AddAnchorControllers(DrawDescription desc, AviUtlScriptContext ctx)
|
||||
{
|
||||
var controllers = ResolveAnchorControllers(ctx);
|
||||
return controllers.Count == 0 ? desc : desc with { Controllers = desc.Controllers.AddRange(controllers) };
|
||||
}
|
||||
|
||||
private ImmutableList<VideoEffectController> BuildAnchorControllers(
|
||||
IReadOnlyList<LuaAnchorPoint>? source, IReadOnlyList<AnchorRequestData> requests)
|
||||
{
|
||||
var builder = ImmutableList.CreateBuilder<VideoEffectController>();
|
||||
foreach (var request in requests)
|
||||
{
|
||||
if (request.Count <= 0)
|
||||
continue;
|
||||
|
||||
AddConnectionControllers(builder, source, request);
|
||||
|
||||
var group = request.Group;
|
||||
bool is3D = request.Is3D;
|
||||
for (int i = 0; i < request.Count; i++)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, group, i, out double x, out double y, out double z);
|
||||
int index = i;
|
||||
var point = new ControllerPoint(
|
||||
new Vector3((float)x, (float)y, (float)(is3D ? z : 0d)),
|
||||
arg => item.ApplyAnchorDrag(group, index, arg.Delta.X, arg.Delta.Y, is3D ? arg.Delta.Z : 0d))
|
||||
{
|
||||
Shape = VideoControllerPointShape.Circle,
|
||||
};
|
||||
builder.Add(new VideoEffectController(item, [point]));
|
||||
}
|
||||
}
|
||||
return builder.ToImmutable();
|
||||
}
|
||||
|
||||
private void AddConnectionControllers(
|
||||
ImmutableList<VideoEffectController>.Builder builder, IReadOnlyList<LuaAnchorPoint>? source, in AnchorRequestData request)
|
||||
{
|
||||
switch (request.Connection)
|
||||
{
|
||||
case AnchorConnection.Line:
|
||||
for (int i = 0; i + 1 < request.Count; i++)
|
||||
AddEdge(builder, ConnectionPoint(source, request, i), ConnectionPoint(source, request, i + 1));
|
||||
break;
|
||||
case AnchorConnection.Loop:
|
||||
for (int i = 0; i + 1 < request.Count; i++)
|
||||
AddEdge(builder, ConnectionPoint(source, request, i), ConnectionPoint(source, request, i + 1));
|
||||
if (request.Count >= 2)
|
||||
AddEdge(builder, ConnectionPoint(source, request, request.Count - 1), ConnectionPoint(source, request, 0));
|
||||
break;
|
||||
case AnchorConnection.Star:
|
||||
for (int i = 0; i < request.Count; i++)
|
||||
AddEdge(builder, CenterPoint(), ConnectionPoint(source, request, i));
|
||||
break;
|
||||
case AnchorConnection.Arm:
|
||||
if (request.Count >= 1)
|
||||
AddEdge(builder, CenterPoint(), ConnectionPoint(source, request, 0));
|
||||
for (int i = 0; i + 1 < request.Count; i++)
|
||||
AddEdge(builder, ConnectionPoint(source, request, i), ConnectionPoint(source, request, i + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddEdge(ImmutableList<VideoEffectController>.Builder builder, ControllerPoint a, ControllerPoint b) =>
|
||||
builder.Add(new VideoEffectController(item, [a, b]) { Connection = VideoControllerPointConnection.Line });
|
||||
|
||||
private static ControllerPoint CenterPoint() =>
|
||||
new(Vector3.Zero) { Shape = VideoControllerPointShape.None };
|
||||
|
||||
private static ControllerPoint ConnectionPoint(IReadOnlyList<LuaAnchorPoint>? source, in AnchorRequestData request, int index)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, request.Group, index, out double x, out double y, out double z);
|
||||
return new ControllerPoint(new Vector3((float)x, (float)y, (float)(request.Is3D ? z : 0d)))
|
||||
{
|
||||
Shape = VideoControllerPointShape.None,
|
||||
};
|
||||
}
|
||||
|
||||
private void ApplyDrawState(AviUtlScriptContext ctx, RawRectF bounds)
|
||||
{
|
||||
if (ctx.DrawStateOverride is not { } drawn)
|
||||
return;
|
||||
|
||||
if (!drawn)
|
||||
{
|
||||
effectOutput = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (effectOutput is not null)
|
||||
return;
|
||||
|
||||
ctx.EnsurePixelBuffer();
|
||||
var buffer = ctx.GetPixelBuffer();
|
||||
if (buffer is null)
|
||||
return;
|
||||
|
||||
_pixelManager!.WritePixelsToOutput(buffer, ctx.ImageWidth, ctx.ImageHeight);
|
||||
effectOutput = _pixelManager.GetTransformOutput(bounds.Left, bounds.Top);
|
||||
}
|
||||
|
||||
private static DrawDescription BuildOutputDesc(DrawDescription inDesc, AviUtlScriptContext ctx)
|
||||
{
|
||||
return inDesc with
|
||||
@@ -491,12 +742,24 @@ namespace LuaScript
|
||||
_gpuKernelChecked = false;
|
||||
}
|
||||
|
||||
private bool ExecuteKernelLane(string runnable, AviUtlScriptContext ctx, RawRectF bounds, int imgW, int imgH)
|
||||
private void EnsureDirective(string runnable)
|
||||
{
|
||||
if (_directiveCached && string.Equals(runnable, _directiveSource, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
_directiveSource = runnable;
|
||||
_directiveCached = true;
|
||||
_hasExplicitDirective = ScriptDirective.TryResolveExplicit(runnable, out _explicitDirectiveKind);
|
||||
_autoKind = ScriptDirective.ResolveAuto(runnable);
|
||||
}
|
||||
|
||||
private bool ExecuteKernelLane(AviUtlScriptContext ctx, RawRectF bounds, int imgW, int imgH)
|
||||
{
|
||||
if (_kernelProgram is null || _cpuKernel is null)
|
||||
return false;
|
||||
|
||||
bool explicitDirective = ScriptDirective.TryResolveExplicit(runnable, out var kind);
|
||||
bool explicitDirective = _hasExplicitDirective;
|
||||
var kind = _explicitDirectiveKind;
|
||||
if (explicitDirective && kind is not (ScriptEngineKind.Gpu or ScriptEngineKind.Cpu))
|
||||
return false;
|
||||
|
||||
@@ -570,20 +833,30 @@ namespace LuaScript
|
||||
{
|
||||
_nativeWorker ??= new LuaJitWorker(NativeDirectory);
|
||||
_nativeFields ??= new double[NativeProtocol.FieldCount];
|
||||
_nativeLoadInput ??= () => _nativeInputPixels ??= LoadPendingInputPixels();
|
||||
_nativeResolveObject ??= (tag, frame) => _context.ResolveObject(tag, frame, out var info) ? info : null;
|
||||
_nativeLoadFigure ??= NativeLoadFigure;
|
||||
_nativeLoadText ??= NativeLoadText;
|
||||
_nativeLoadImage ??= NativeLoadImage;
|
||||
_nativeLoadMovie ??= NativeLoadMovie;
|
||||
_nativeAddEffect ??= (name, args) => _context.AddEffect(new AviUtlEffectRequest(name, args));
|
||||
_nativeAddDraw ??= command => _context.AddDraw(command);
|
||||
_nativeSetAnchor ??= ResolveNativeAnchor;
|
||||
|
||||
NativeFieldMap.ToFields(ctx, _nativeFields);
|
||||
byte[] buffer = LoadInputPixels(bounds, imgW, imgH);
|
||||
_nativeInputPixels = null;
|
||||
|
||||
bool ok = _nativeWorker.Execute(
|
||||
script, _nativeFields, buffer, imgW, imgH, NativeTimeoutMilliseconds,
|
||||
(tag, frame) => ctx.ResolveObject(tag, frame, out var info) ? info : null,
|
||||
NativeLoadFigure,
|
||||
NativeLoadText,
|
||||
NativeLoadImage,
|
||||
NativeLoadMovie,
|
||||
(name, args) => ctx.AddEffect(new AviUtlEffectRequest(name, args)),
|
||||
ctx.AddDraw,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? newPixels,
|
||||
script, _nativeFields, ctx.StringParameters, _nativeLoadInput, imgW, imgH, NativeTimeoutMilliseconds,
|
||||
_nativeResolveObject,
|
||||
_nativeLoadFigure,
|
||||
_nativeLoadText,
|
||||
_nativeLoadImage,
|
||||
_nativeLoadMovie,
|
||||
_nativeAddEffect,
|
||||
_nativeAddDraw,
|
||||
_nativeSetAnchor,
|
||||
out bool dirty, out bool bufferReplaced, out byte[]? resultPixels,
|
||||
out int resultW, out int resultH, out string? error);
|
||||
|
||||
if (!ok)
|
||||
@@ -597,25 +870,21 @@ namespace LuaScript
|
||||
|
||||
bool hasDraws = ctx.DrawCommands.Count > 0;
|
||||
|
||||
if (dirty)
|
||||
if (dirty && resultPixels is not null)
|
||||
{
|
||||
int outW = bufferReplaced ? resultW : imgW;
|
||||
int outH = bufferReplaced ? resultH : imgH;
|
||||
byte[] outPixels = buffer;
|
||||
|
||||
if (bufferReplaced && newPixels != null)
|
||||
{
|
||||
outPixels = newPixels;
|
||||
ctx.ReplaceBuffer(outPixels, outW, outH);
|
||||
}
|
||||
if (bufferReplaced)
|
||||
ctx.ReplaceBuffer(resultPixels, outW, outH);
|
||||
|
||||
if (hasDraws)
|
||||
{
|
||||
ctx.SetResolvedBuffer(outPixels, outW, outH);
|
||||
ctx.SetResolvedBuffer(resultPixels, outW, outH);
|
||||
return true;
|
||||
}
|
||||
|
||||
_pixelManager!.WritePixelsToOutput(outPixels, outW, outH);
|
||||
_pixelManager!.WritePixelsToOutput(resultPixels, outW, outH);
|
||||
if (bufferReplaced)
|
||||
effectOutput = _pixelManager.GetTransformOutput(-outW / 2f, -outH / 2f);
|
||||
else
|
||||
@@ -625,7 +894,7 @@ namespace LuaScript
|
||||
|
||||
if (hasDraws)
|
||||
{
|
||||
ctx.SetResolvedBuffer(buffer, imgW, imgH);
|
||||
ctx.SetResolvedBuffer(_nativeLoadInput(), imgW, imgH);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -633,6 +902,22 @@ namespace LuaScript
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ResolveNativeAnchor(string group, int count, bool is3D, int connection, double[] positions)
|
||||
{
|
||||
_context.AddAnchorRequest(new AnchorRequestData(group, count, (AnchorConnection)connection, is3D));
|
||||
|
||||
int stride = is3D ? 3 : 2;
|
||||
var source = _context.AnchorSource;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, group, i, out double x, out double y, out double z);
|
||||
positions[i * stride + 0] = x;
|
||||
positions[i * stride + 1] = y;
|
||||
if (is3D)
|
||||
positions[i * stride + 2] = z;
|
||||
}
|
||||
}
|
||||
|
||||
private (byte[] buffer, int w, int h) NativeLoadText(string family, string text, double size, bool bold, bool italic, int color)
|
||||
{
|
||||
_nativeTextRenderer ??= new TextRenderer();
|
||||
@@ -666,6 +951,8 @@ namespace LuaScript
|
||||
return (buffer, fw, fh);
|
||||
}
|
||||
|
||||
private byte[] LoadPendingInputPixels() => LoadInputPixels(_pixelBounds, _pixelWidth, _pixelHeight);
|
||||
|
||||
private byte[] LoadInputPixels(RawRectF bounds, int width, int height)
|
||||
{
|
||||
_pixelLoaderSemaphore.Wait();
|
||||
@@ -688,6 +975,7 @@ namespace LuaScript
|
||||
_nativeWorker?.Dispose();
|
||||
_effectChain?.Dispose();
|
||||
_drawCompositor?.Dispose();
|
||||
_bufferCompositor?.Dispose();
|
||||
_nativeTextRenderer?.Dispose();
|
||||
_nativeImageDecoder?.Dispose();
|
||||
_pixelLoaderSemaphore.Dispose();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using LuaScript.Anchor;
|
||||
using LuaScript.Compat;
|
||||
using MoonSharp.Interpreter;
|
||||
using MoonSharp.Interpreter.Debugging;
|
||||
@@ -333,6 +334,12 @@ namespace LuaScript
|
||||
_objTable!["track1"] = ctx.Track1;
|
||||
_objTable!["track2"] = ctx.Track2;
|
||||
_objTable!["track3"] = ctx.Track3;
|
||||
_objTable!["slider0"] = ctx.Slider0;
|
||||
_objTable!["slider1"] = ctx.Slider1;
|
||||
_objTable!["slider2"] = ctx.Slider2;
|
||||
_objTable!["slider3"] = ctx.Slider3;
|
||||
foreach (var parameter in ctx.StringParameters)
|
||||
_objTable![parameter.Key] = parameter.Value;
|
||||
_objTable!["check0"] = ctx.Check0;
|
||||
_objTable!["check1"] = ctx.Check1;
|
||||
_objTable!["check2"] = ctx.Check2;
|
||||
@@ -581,7 +588,7 @@ namespace LuaScript
|
||||
double alpha = args.Count > 4 ? args[4].CastToNumber() ?? 1d : 1d;
|
||||
double aspect = args.Count > 5 ? args[5].CastToNumber() ?? 0d : 0d;
|
||||
|
||||
_activeContext.AddDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, CurrentAntialias()));
|
||||
_activeContext.SubmitDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect, null, CurrentAntialias(), CurrentBlend()));
|
||||
return DynValue.Void;
|
||||
});
|
||||
|
||||
@@ -617,7 +624,7 @@ namespace LuaScript
|
||||
_ => 1d,
|
||||
};
|
||||
|
||||
_activeContext.AddDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, CurrentAntialias()));
|
||||
_activeContext.SubmitDraw(new DrawCommand(0d, 0d, 0d, 1d, poly[20], 0d, poly, CurrentAntialias(), CurrentBlend()));
|
||||
return DynValue.Void;
|
||||
});
|
||||
|
||||
@@ -642,12 +649,68 @@ namespace LuaScript
|
||||
return value.Type == DataType.Number ? value : DynValue.NewNumber(0d);
|
||||
});
|
||||
|
||||
obj["setanchor"] = DynValue.NewCallback((_, args) =>
|
||||
{
|
||||
_activeCancellation.ThrowIfCancellationRequested();
|
||||
if (_activeContext is null || _script is null || args.Count < 2 || args[0].Type != DataType.String)
|
||||
return DynValue.NewNumber(0d);
|
||||
|
||||
var anchorName = args[0].String;
|
||||
int count = AnchorSupport.ClampCount((int)(args[1].CastToNumber() ?? 0d));
|
||||
if (string.Equals(anchorName, AnchorSupport.TrackGroup, StringComparison.Ordinal))
|
||||
return DynValue.NewNumber(0d);
|
||||
|
||||
var connection = AnchorConnection.None;
|
||||
bool is3D = false;
|
||||
for (int i = 2; i < args.Count; i++)
|
||||
{
|
||||
if (args[i].Type == DataType.String)
|
||||
AnchorSupport.ApplyOption(args[i].String, ref connection, ref is3D);
|
||||
}
|
||||
|
||||
int stride = is3D ? 3 : 2;
|
||||
var table = new Table(_script);
|
||||
var source = _activeContext.AnchorSource;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
AnchorSupport.ResolvePosition(source, anchorName, i, out double x, out double y, out double z);
|
||||
table.Set(i * stride + 1, DynValue.NewNumber(x));
|
||||
table.Set(i * stride + 2, DynValue.NewNumber(y));
|
||||
if (is3D)
|
||||
table.Set(i * stride + 3, DynValue.NewNumber(z));
|
||||
}
|
||||
_script.Globals.Set(anchorName, DynValue.NewTable(table));
|
||||
|
||||
_activeContext.AddAnchorRequest(new AnchorRequestData(anchorName, count, connection, is3D));
|
||||
return DynValue.NewNumber(count);
|
||||
});
|
||||
|
||||
obj["setoption"] = DynValue.NewCallback((_, args) =>
|
||||
{
|
||||
_activeCancellation.ThrowIfCancellationRequested();
|
||||
if (args.Count == 0 || args[0].Type != DataType.String)
|
||||
return DynValue.Void;
|
||||
_options[args[0].String] = args.Count > 1 ? args[1] : DynValue.True;
|
||||
var name = args[0].String;
|
||||
var value = args.Count > 1 ? args[1] : DynValue.True;
|
||||
_options[name] = value;
|
||||
if (name == "draw_state" && _activeContext is not null)
|
||||
_activeContext.DrawStateOverride = value.Type == DataType.Boolean
|
||||
? value.Boolean
|
||||
: (value.CastToNumber() ?? 0d) != 0d;
|
||||
if (name == "drawtarget" && _activeContext is not null)
|
||||
{
|
||||
if (value.Type == DataType.String && value.String == "tempbuffer")
|
||||
{
|
||||
bool hasSize = args.Count > 3;
|
||||
int w = hasSize ? (int)(args[2].CastToNumber() ?? 0d) : 0;
|
||||
int h = hasSize ? (int)(args[3].CastToNumber() ?? 0d) : 0;
|
||||
_activeContext.SetDrawTarget(true, w, h, hasSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
_activeContext.SetDrawTarget(false, 0, 0, false);
|
||||
}
|
||||
}
|
||||
return DynValue.Void;
|
||||
});
|
||||
|
||||
@@ -674,6 +737,11 @@ namespace LuaScript
|
||||
? value.Number
|
||||
: 1d;
|
||||
|
||||
private double CurrentBlend() =>
|
||||
_options.TryGetValue("blend", out var value) && value.Type == DataType.Number
|
||||
? value.Number
|
||||
: 0d;
|
||||
|
||||
private void LoadFigure(string name, int color, double size, double line, double aspect)
|
||||
{
|
||||
int boundingSize = Math.Max(1, (int)Math.Round(size));
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LuaScript
|
||||
{
|
||||
internal sealed class SoftwareCompositor : IBufferCompositor
|
||||
{
|
||||
public void Compose(byte[] dst, int dstW, int dstH, byte[] src, int srcW, int srcH, in DrawCommand command)
|
||||
{
|
||||
bool linear = command.Antialias != 0d;
|
||||
if (command.Poly is { } poly)
|
||||
DrawPolyInto(dst, dstW, dstH, src, srcW, srcH, poly, command.Alpha, linear);
|
||||
else
|
||||
DrawInto(dst, dstW, dstH, src, srcW, srcH, command.Ox, command.Oy, command.Zoom, command.Aspect, command.Alpha, linear);
|
||||
}
|
||||
|
||||
public static void DrawInto(
|
||||
byte[] dst, int dstW, int dstH,
|
||||
byte[] src, int srcW, int srcH,
|
||||
double ox, double oy, double zoom, double aspect, double alpha, bool linear)
|
||||
{
|
||||
if (srcW <= 0 || srcH <= 0 || dstW <= 0 || dstH <= 0)
|
||||
return;
|
||||
|
||||
double clampedAspect = Math.Clamp(aspect, -1d, 1d);
|
||||
double zx = zoom * (1d + clampedAspect);
|
||||
double zy = zoom * (1d - clampedAspect);
|
||||
if (zx == 0d || zy == 0d)
|
||||
return;
|
||||
|
||||
double ka = Math.Clamp(alpha, 0d, 1d);
|
||||
if (ka <= 0d)
|
||||
return;
|
||||
|
||||
double halfW = srcW * 0.5;
|
||||
double halfH = srcH * 0.5;
|
||||
double spanX = Math.Abs(halfW * zx);
|
||||
double spanY = Math.Abs(halfH * zy);
|
||||
|
||||
int x0 = Math.Max(0, (int)Math.Floor(ox - spanX));
|
||||
int x1 = Math.Min(dstW - 1, (int)Math.Ceiling(ox + spanX));
|
||||
int y0 = Math.Max(0, (int)Math.Floor(oy - spanY));
|
||||
int y1 = Math.Min(dstH - 1, (int)Math.Ceiling(oy + spanY));
|
||||
|
||||
for (int py = y0; py <= y1; py++)
|
||||
{
|
||||
for (int px = x0; px <= x1; px++)
|
||||
{
|
||||
double u = (px + 0.5 - ox) / zx + halfW;
|
||||
double v = (py + 0.5 - oy) / zy + halfH;
|
||||
if (u < 0d || u >= srcW || v < 0d || v >= srcH)
|
||||
continue;
|
||||
|
||||
Sample(src, srcW, srcH, u, v, linear, out double sb, out double sg, out double sr, out double sa);
|
||||
CompositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawPolyInto(
|
||||
byte[] dst, int dstW, int dstH,
|
||||
byte[] src, int srcW, int srcH,
|
||||
double[] poly, double alpha, bool linear)
|
||||
{
|
||||
if (srcW <= 0 || srcH <= 0 || dstW <= 0 || dstH <= 0)
|
||||
return;
|
||||
if (!DrawPolyMath.TrySolveAffine(poly, out var forward))
|
||||
return;
|
||||
if (!Matrix3x2.Invert(forward, out var inverse))
|
||||
return;
|
||||
|
||||
double ka = Math.Clamp(alpha, 0d, 1d);
|
||||
if (ka <= 0d)
|
||||
return;
|
||||
|
||||
DrawPolyMath.Bounds(poly, out double minX, out double minY, out double maxX, out double maxY);
|
||||
int x0 = Math.Max(0, (int)Math.Floor(minX));
|
||||
int x1 = Math.Min(dstW - 1, (int)Math.Ceiling(maxX));
|
||||
int y0 = Math.Max(0, (int)Math.Floor(minY));
|
||||
int y1 = Math.Min(dstH - 1, (int)Math.Ceiling(maxY));
|
||||
|
||||
for (int py = y0; py <= y1; py++)
|
||||
{
|
||||
for (int px = x0; px <= x1; px++)
|
||||
{
|
||||
var uv = Vector2.Transform(new Vector2(px + 0.5f, py + 0.5f), inverse);
|
||||
double u = uv.X;
|
||||
double v = uv.Y;
|
||||
if (u < 0d || u >= srcW || v < 0d || v >= srcH)
|
||||
continue;
|
||||
|
||||
Sample(src, srcW, srcH, u, v, linear, out double sb, out double sg, out double sr, out double sa);
|
||||
CompositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Sample(byte[] src, int srcW, int srcH, double u, double v, bool linear,
|
||||
out double b, out double g, out double r, out double a)
|
||||
{
|
||||
if (!linear)
|
||||
{
|
||||
int su = Math.Clamp((int)Math.Floor(u), 0, srcW - 1);
|
||||
int sv = Math.Clamp((int)Math.Floor(v), 0, srcH - 1);
|
||||
int si = (sv * srcW + su) * 4;
|
||||
b = src[si];
|
||||
g = src[si + 1];
|
||||
r = src[si + 2];
|
||||
a = src[si + 3];
|
||||
return;
|
||||
}
|
||||
|
||||
double fx = u - 0.5;
|
||||
double fy = v - 0.5;
|
||||
int x0 = (int)Math.Floor(fx);
|
||||
int y0 = (int)Math.Floor(fy);
|
||||
double tx = fx - x0;
|
||||
double ty = fy - y0;
|
||||
|
||||
b = g = r = a = 0d;
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
int sy = Math.Clamp(y0 + j, 0, srcH - 1);
|
||||
double wy = j == 0 ? 1d - ty : ty;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int sx = Math.Clamp(x0 + i, 0, srcW - 1);
|
||||
double w = wy * (i == 0 ? 1d - tx : tx);
|
||||
int si = (sy * srcW + sx) * 4;
|
||||
b += src[si] * w;
|
||||
g += src[si + 1] * w;
|
||||
r += src[si + 2] * w;
|
||||
a += src[si + 3] * w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CompositeOver(byte[] dst, int di, double sb, double sg, double sr, double sa)
|
||||
{
|
||||
double inv = 1d - sa / 255d;
|
||||
dst[di] = (byte)Math.Clamp(sb + dst[di] * inv, 0d, 255d);
|
||||
dst[di + 1] = (byte)Math.Clamp(sg + dst[di + 1] * inv, 0d, 255d);
|
||||
dst[di + 2] = (byte)Math.Clamp(sr + dst[di + 2] * inv, 0d, 255d);
|
||||
dst[di + 3] = (byte)Math.Clamp(sa + dst[di + 3] * inv, 0d, 255d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>مسار 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>مسار 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>قيمة المنزلق (متوافق مع AviUtl: track0-3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>منزلق 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>منزلق 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>منزلق 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>منزلق 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>منزلق رقمي (obj.slider0-3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>خانة 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>خانة 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>خانة 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>قيمة خانة الاختيار (متوافق مع AviUtl: check0-3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>اللون</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>اللون (متوافق مع AviUtl: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>نص</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>إدخال نص (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>خط</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>اختيار الخط (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>مجلد</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>اختيار المجلد (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>اختيار الملف (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>ملف فيديو</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>ملف صوتي</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>ملف صورة</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>ملف المشروع</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>ملف MP4</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>ملف EXO</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>ملف الترجمة</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>ملف التظليل</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>استيراد</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>تصدير</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>مسح</value></data>
|
||||
|
||||
@@ -9,6 +9,11 @@ Track1,,トラック1,Track 1,轨道1,軌道1,트랙1,Pista 1,مسار 1,Jalur 1
|
||||
Track2,,トラック2,Track 2,轨道2,軌道2,트랙2,Pista 2,مسار 2,Jalur 2
|
||||
Track3,,トラック3,Track 3,轨道3,軌道3,트랙3,Pista 3,مسار 3,Jalur 3
|
||||
TrackDesc,,スライダー値 (AviUtl準拠 track0〜3 に対応),Slider value (AviUtl compatible: track0–3),滑块值(AviUtl兼容: track0~3),滑塊值(AviUtl兼容: track0~3),슬라이더 값 (AviUtl 호환: track0~3),Valor del deslizador (compatible AviUtl: track0-3),قيمة المنزلق (متوافق مع AviUtl: track0-3),Nilai slider (kompatibel AviUtl: track0-3)
|
||||
Slider0,,スライダー0,Slider 0,滑块0,滑塊0,슬라이더0,Deslizador 0,منزلق 0,Slider 0
|
||||
Slider1,,スライダー1,Slider 1,滑块1,滑塊1,슬라이더1,Deslizador 1,منزلق 1,Slider 1
|
||||
Slider2,,スライダー2,Slider 2,滑块2,滑塊2,슬라이더2,Deslizador 2,منزلق 2,Slider 2
|
||||
Slider3,,スライダー3,Slider 3,滑块3,滑塊3,슬라이더3,Deslizador 3,منزلق 3,Slider 3
|
||||
SliderDesc,,数値スライダー (obj.slider0〜3 で参照),Numeric slider (obj.slider0–3),数值滑块 (obj.slider0~3),數值滑塊 (obj.slider0~3),숫자 슬라이더 (obj.slider0~3),Deslizador numérico (obj.slider0-3),منزلق رقمي (obj.slider0-3),Slider numerik (obj.slider0-3)
|
||||
Check0,,チェック0,Check 0,复选框0,核取方塊0,체크0,Casilla 0,خانة 0,Centang 0
|
||||
Check1,,チェック1,Check 1,复选框1,核取方塊1,체크1,Casilla 1,خانة 1,Centang 1
|
||||
Check2,,チェック2,Check 2,复选框2,核取方塊2,체크2,Casilla 2,خانة 2,Centang 2
|
||||
@@ -16,6 +21,21 @@ Check3,,チェック3,Check 3,复选框3,核取方塊3,체크3,Casilla 3,خان
|
||||
CheckDesc,,チェックボックス値 (AviUtl準拠 check0〜3 に対応),Checkbox value (AviUtl compatible: check0–3),复选框值(AviUtl兼容: check0~3),核取方塊值(AviUtl兼容: check0~3),체크박스 값 (AviUtl 호환: check0~3),Valor de casilla (compatible AviUtl: check0-3),قيمة خانة الاختيار (متوافق مع AviUtl: check0-3),Nilai kotak centang (kompatibel AviUtl: check0-3)
|
||||
Color,,色,Color,颜色,顏色,색,Color,اللون,Warna
|
||||
ColorDesc,,色 (AviUtl準拠 --color に対応),Color (AviUtl compatible: --color),颜色(AviUtl兼容: --color),顏色(AviUtl兼容: --color),색 (AviUtl 호환: --color),Color (compatible AviUtl: --color),اللون (متوافق مع AviUtl: --color),Warna (kompatibel AviUtl: --color)
|
||||
Text,,テキスト,Text,文本,文字,텍스트,Texto,نص,Teks
|
||||
TextDesc,,テキスト入力 (obj.text で参照),Text input (obj.text),文本输入 (obj.text),文字輸入 (obj.text),텍스트 입력 (obj.text),Entrada de texto (obj.text),إدخال نص (obj.text),Masukan teks (obj.text)
|
||||
Font,,フォント,Font,字体,字型,글꼴,Fuente,خط,Font
|
||||
FontDesc,,フォント選択 (obj.font で参照),Font selection (obj.font),字体选择 (obj.font),字型選擇 (obj.font),글꼴 선택 (obj.font),Selección de fuente (obj.font),اختيار الخط (obj.font),Pilihan font (obj.font)
|
||||
Directory,,フォルダ,Folder,文件夹,資料夾,폴더,Carpeta,مجلد,Folder
|
||||
DirectoryDesc,,フォルダ選択 (obj.dir で参照),Folder selection (obj.dir),文件夹选择 (obj.dir),資料夾選擇 (obj.dir),폴더 선택 (obj.dir),Selección de carpeta (obj.dir),اختيار المجلد (obj.dir),Pilihan folder (obj.dir)
|
||||
FileDesc,,ファイル選択 (obj.file_* で参照),File selection (obj.file_*),文件选择 (obj.file_*),檔案選擇 (obj.file_*),파일 선택 (obj.file_*),Selección de archivo (obj.file_*),اختيار الملف (obj.file_*),Pilihan file (obj.file_*)
|
||||
FileVideo,,動画ファイル,Video File,视频文件,影片檔案,동영상 파일,Archivo de video,ملف فيديو,File Video
|
||||
FileAudio,,音声ファイル,Audio File,音频文件,音訊檔案,음성 파일,Archivo de audio,ملف صوتي,File Audio
|
||||
FileImage,,画像ファイル,Image File,图像文件,圖片檔案,이미지 파일,Archivo de imagen,ملف صورة,File Gambar
|
||||
FileProject,,プロジェクトファイル,Project File,项目文件,專案檔案,프로젝트 파일,Archivo de proyecto,ملف المشروع,File Proyek
|
||||
FileMp4,,MP4ファイル,MP4 File,MP4文件,MP4檔案,MP4 파일,Archivo MP4,ملف MP4,File MP4
|
||||
FileExo,,EXOファイル,EXO File,EXO文件,EXO檔案,EXO 파일,Archivo EXO,ملف EXO,File EXO
|
||||
FileSubtitle,,字幕ファイル,Subtitle File,字幕文件,字幕檔案,자막 파일,Archivo de subtítulos,ملف الترجمة,File Subtitle
|
||||
FileShader,,シェーダーファイル,Shader File,着色器文件,著色器檔案,셰이더 파일,Archivo de sombreador,ملف التظليل,File Shader
|
||||
ToolBarImport,,インポート,Import,导入,導入,가져오기,Importar,استيراد,Impor
|
||||
ToolBarExport,,エクスポート,Export,导出,導出,내보내기,Exportar,تصدير,Ekspor
|
||||
ToolBarClear,,クリア,Clear,清除,清除,지우기,Limpiar,مسح,Hapus
|
||||
|
||||
|
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>Track 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>Track 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>Slider value (AviUtl compatible: track0–3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>Slider 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>Slider 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>Slider 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>Slider 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>Numeric slider (obj.slider0–3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>Check 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>Check 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>Check 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>Checkbox value (AviUtl compatible: check0–3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>Color</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>Color (AviUtl compatible: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>Text</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>Text input (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>Font</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>Font selection (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>Folder</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>Folder selection (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>File selection (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>Video File</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>Audio File</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>Image File</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>Project File</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4 File</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO File</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>Subtitle File</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>Shader File</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>Import</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>Export</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>Clear</value></data>
|
||||
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>Pista 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>Pista 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>Valor del deslizador (compatible AviUtl: track0-3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>Deslizador 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>Deslizador 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>Deslizador 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>Deslizador 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>Deslizador numérico (obj.slider0-3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>Casilla 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>Casilla 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>Casilla 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>Valor de casilla (compatible AviUtl: check0-3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>Color</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>Color (compatible AviUtl: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>Texto</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>Entrada de texto (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>Fuente</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>Selección de fuente (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>Carpeta</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>Selección de carpeta (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>Selección de archivo (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>Archivo de video</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>Archivo de audio</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>Archivo de imagen</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>Archivo de proyecto</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>Archivo MP4</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>Archivo EXO</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>Archivo de subtítulos</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>Archivo de sombreador</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>Importar</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>Exportar</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>Limpiar</value></data>
|
||||
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>Jalur 2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>Jalur 3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>Nilai slider (kompatibel AviUtl: track0-3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>Slider 0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>Slider 1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>Slider 2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>Slider 3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>Slider numerik (obj.slider0-3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>Centang 0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>Centang 1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>Centang 2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>Nilai kotak centang (kompatibel AviUtl: check0-3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>Warna</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>Warna (kompatibel AviUtl: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>Teks</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>Masukan teks (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>Font</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>Pilihan font (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>Folder</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>Pilihan folder (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>Pilihan file (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>File Video</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>File Audio</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>File Gambar</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>File Proyek</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>File MP4</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>File EXO</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>File Subtitle</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>File Shader</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>Impor</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>Ekspor</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>Hapus</value></data>
|
||||
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>트랙2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>트랙3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>슬라이더 값 (AviUtl 호환: track0~3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>슬라이더0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>슬라이더1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>슬라이더2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>슬라이더3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>숫자 슬라이더 (obj.slider0~3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>체크0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>체크1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>체크2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>체크박스 값 (AviUtl 호환: check0~3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>색</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>색 (AviUtl 호환: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>텍스트</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>텍스트 입력 (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>글꼴</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>글꼴 선택 (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>폴더</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>폴더 선택 (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>파일 선택 (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>동영상 파일</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>음성 파일</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>이미지 파일</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>프로젝트 파일</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4 파일</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO 파일</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>자막 파일</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>셰이더 파일</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>가져오기</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>내보내기</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>지우기</value></data>
|
||||
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>トラック2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>トラック3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>スライダー値 (AviUtl準拠 track0〜3 に対応)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>スライダー0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>スライダー1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>スライダー2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>スライダー3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>数値スライダー (obj.slider0〜3 で参照)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>チェック0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>チェック1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>チェック2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>チェックボックス値 (AviUtl準拠 check0〜3 に対応)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>色</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>色 (AviUtl準拠 --color に対応)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>テキスト</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>テキスト入力 (obj.text で参照)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>フォント</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>フォント選択 (obj.font で参照)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>フォルダ</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>フォルダ選択 (obj.dir で参照)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>ファイル選択 (obj.file_* で参照)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>動画ファイル</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>音声ファイル</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>画像ファイル</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>プロジェクトファイル</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4ファイル</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXOファイル</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>字幕ファイル</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>シェーダーファイル</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>インポート</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>エクスポート</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>クリア</value></data>
|
||||
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>轨道2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>轨道3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>滑块值(AviUtl兼容: track0~3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>滑块0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>滑块1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>滑块2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>滑块3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>数值滑块 (obj.slider0~3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>复选框0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>复选框1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>复选框2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>复选框值(AviUtl兼容: check0~3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>颜色</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>颜色(AviUtl兼容: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>文本</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>文本输入 (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>字体</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>字体选择 (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>文件夹</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>文件夹选择 (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>文件选择 (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>视频文件</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>音频文件</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>图像文件</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>项目文件</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4文件</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO文件</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>字幕文件</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>着色器文件</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>导入</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>导出</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>清除</value></data>
|
||||
|
||||
@@ -69,6 +69,11 @@
|
||||
<data name="Track2" xml:space="preserve"><value>軌道2</value></data>
|
||||
<data name="Track3" xml:space="preserve"><value>軌道3</value></data>
|
||||
<data name="TrackDesc" xml:space="preserve"><value>滑塊值(AviUtl兼容: track0~3)</value></data>
|
||||
<data name="Slider0" xml:space="preserve"><value>滑塊0</value></data>
|
||||
<data name="Slider1" xml:space="preserve"><value>滑塊1</value></data>
|
||||
<data name="Slider2" xml:space="preserve"><value>滑塊2</value></data>
|
||||
<data name="Slider3" xml:space="preserve"><value>滑塊3</value></data>
|
||||
<data name="SliderDesc" xml:space="preserve"><value>數值滑塊 (obj.slider0~3)</value></data>
|
||||
<data name="Check0" xml:space="preserve"><value>核取方塊0</value></data>
|
||||
<data name="Check1" xml:space="preserve"><value>核取方塊1</value></data>
|
||||
<data name="Check2" xml:space="preserve"><value>核取方塊2</value></data>
|
||||
@@ -76,6 +81,21 @@
|
||||
<data name="CheckDesc" xml:space="preserve"><value>核取方塊值(AviUtl兼容: check0~3)</value></data>
|
||||
<data name="Color" xml:space="preserve"><value>顏色</value></data>
|
||||
<data name="ColorDesc" xml:space="preserve"><value>顏色(AviUtl兼容: --color)</value></data>
|
||||
<data name="Text" xml:space="preserve"><value>文字</value></data>
|
||||
<data name="TextDesc" xml:space="preserve"><value>文字輸入 (obj.text)</value></data>
|
||||
<data name="Font" xml:space="preserve"><value>字型</value></data>
|
||||
<data name="FontDesc" xml:space="preserve"><value>字型選擇 (obj.font)</value></data>
|
||||
<data name="Directory" xml:space="preserve"><value>資料夾</value></data>
|
||||
<data name="DirectoryDesc" xml:space="preserve"><value>資料夾選擇 (obj.dir)</value></data>
|
||||
<data name="FileDesc" xml:space="preserve"><value>檔案選擇 (obj.file_*)</value></data>
|
||||
<data name="FileVideo" xml:space="preserve"><value>影片檔案</value></data>
|
||||
<data name="FileAudio" xml:space="preserve"><value>音訊檔案</value></data>
|
||||
<data name="FileImage" xml:space="preserve"><value>圖片檔案</value></data>
|
||||
<data name="FileProject" xml:space="preserve"><value>專案檔案</value></data>
|
||||
<data name="FileMp4" xml:space="preserve"><value>MP4檔案</value></data>
|
||||
<data name="FileExo" xml:space="preserve"><value>EXO檔案</value></data>
|
||||
<data name="FileSubtitle" xml:space="preserve"><value>字幕檔案</value></data>
|
||||
<data name="FileShader" xml:space="preserve"><value>著色器檔案</value></data>
|
||||
<data name="ToolBarImport" xml:space="preserve"><value>導入</value></data>
|
||||
<data name="ToolBarExport" xml:space="preserve"><value>導出</value></data>
|
||||
<data name="ToolBarClear" xml:space="preserve"><value>清除</value></data>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
يستخدم تأثير الفيديو "نص Lua" في YukkuriMovieMaker4
|
||||
لغة Lua لكتابة النصوص البرمجية.
|
||||
يعتمد محرك النصوص على MoonSharp (متوافق مع Lua 5.2).
|
||||
تُنفَّذ النصوص على بيئة التشغيل السريعة المرفقة (LuaJIT)،
|
||||
وتعمل على MoonSharp (متوافق مع Lua 5.2) عندما لا تتوفر تلك البيئة.
|
||||
|
||||
* هذا التأثير تطبيق مستقل ويختلف عن مواصفات نصوص AviUtl2.
|
||||
* يختلف في مواصفاته عن ملفات نصوص AviUtl2 (*.anm2 وما شابه).
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
- ملاحظات -
|
||||
|
||||
○ محرك تنفيذ النصوص هو MoonSharp (متوافق مع Lua 5.2).
|
||||
○ محركا تنفيذ النصوص هما LuaJIT (الافتراضي) وMoonSharp (متوافق مع Lua 5.2).
|
||||
○ المكتبات القياسية المتاحة محدودة بما يلي:
|
||||
table, string, math, bit32
|
||||
* io, os, debug, ffi, require وغيرها غير متاحة.
|
||||
@@ -26,16 +27,16 @@
|
||||
|
||||
- محركات التنفيذ والتسريع التلقائي -
|
||||
|
||||
النصوص التي تحتوي على معالجة بكسل (حلقة getpixel/setpixel متداخلة)
|
||||
يُحلَّل تركيبها وتُوجَّه تلقائياً إلى محرك أسرع.
|
||||
أما النصوص العادية (الإحداثيات، الدوران، الشفافية، إلخ) فتظل تعمل على
|
||||
MoonSharp كما في السابق دون أي تغيير في السلوك.
|
||||
يُحلَّل تركيب النصوص وتُوجَّه تلقائياً إلى المحرك الأنسب.
|
||||
النصوص التي لا تحمل توجيهاً تُنفَّذ على بيئة التشغيل السريعة المرفقة
|
||||
(LuaJIT)، أما تخطيطات البكسل المكتفية بنفسها فتُترجَم إضافةً إلى ذلك
|
||||
إلى نواة CPU الأسرع. وفي كلتا الحالتين تطابق النتائج MoonSharp.
|
||||
|
||||
○ التوجيه التلقائي (عند عدم وجود توجيه)
|
||||
· تخطيط بكسل مكتفٍ بنفسه (انظر الشروط أدناه)
|
||||
→ نواة CPU (سريعة ودقيقة)
|
||||
· عمليات البكسل الأخرى → Native (LuaJIT، فقط عند نشره)
|
||||
· بلا عمليات بكسل → MoonSharp
|
||||
· كل ما عدا ذلك → Native (LuaJIT، فقط عند نشره)
|
||||
· عند عدم نشر native أو كون النص فارغاً → MoonSharp
|
||||
|
||||
○ توجيهات المحرك (تعليق في السطر الأول من النص)
|
||||
--!cpu : نواة CPU. تُترجَم وقت التشغيل إلى شجرة تعابير
|
||||
@@ -93,6 +94,32 @@
|
||||
العام لا يصاحبه إعلان نطاق/قيمة افتراضية، لذا تعامل مع نطاقات القيم داخل النص.
|
||||
وتبقى رؤوس AviUtl --track / --check / --color تعمل كما كانت.
|
||||
|
||||
توجد 4 منزلقات رقمية، ويُشار إليها عبر obj.slider0 إلى obj.slider3.
|
||||
القيم أعداد صحيحة ولا تحمل كسوراً عشرية.
|
||||
|
||||
Slider0 : منزلق صحيح (النطاق: 1 ~ 10)
|
||||
Slider1 : منزلق صحيح (النطاق: 0 ~ 100)
|
||||
Slider2 : منزلق صحيح (النطاق: 0 ~ 1000)
|
||||
Slider3 : منزلق صحيح (النطاق: -1000 ~ 1000)
|
||||
|
||||
تتوفر أيضاً معاملات نصية، ويُشار إلى كل قيمة بالأسماء التالية.
|
||||
|
||||
obj.text : نص حقل إدخال النص
|
||||
obj.font : اسم الخط من محدد الخطوط
|
||||
obj.dir : مسار محدد المجلدات
|
||||
obj.file_video : مسار ملف فيديو
|
||||
obj.file_audio : مسار ملف صوتي
|
||||
obj.file_image : مسار ملف صورة
|
||||
obj.file_project : مسار ملف مشروع
|
||||
obj.file_mp4 : مسار ملف MP4
|
||||
obj.file_exo : مسار ملف EXO
|
||||
obj.file_subtitle : مسار ملف ترجمة
|
||||
obj.file_shader : مسار ملف تظليل
|
||||
|
||||
※تظهر المنزلقات والمعاملات النصية في لوح التأثيرات تلقائياً عندما يشير إليها النص البرمجي.
|
||||
※يمكن تمرير مسار الملف إلى obj.load لتحميل صورة أو فيديو.
|
||||
※تتوفر هذه المعاملات في محركَي MoonSharp والمحرك الأصلي معاً.
|
||||
|
||||
|
||||
- المتغيرات العامة -
|
||||
|
||||
@@ -213,6 +240,18 @@
|
||||
obj.track2 : القيمة الحالية لـ Track2 في لوح التأثيرات [للقراءة فقط]
|
||||
obj.track3 : القيمة الحالية لـ Track3 في لوح التأثيرات [للقراءة فقط]
|
||||
|
||||
○ المنزلقات
|
||||
obj.slider0 : القيمة الحالية لـ Slider0 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
obj.slider1 : القيمة الحالية لـ Slider1 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
obj.slider2 : القيمة الحالية لـ Slider2 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
obj.slider3 : القيمة الحالية لـ Slider3 في لوح التأثيرات (عدد صحيح) [للقراءة فقط]
|
||||
|
||||
○ المعاملات النصية
|
||||
obj.text : نص حقل إدخال النص [للقراءة فقط]
|
||||
obj.font : اسم الخط من محدد الخطوط [للقراءة فقط]
|
||||
obj.dir : مسار محدد المجلدات [للقراءة فقط]
|
||||
obj.file_video ~ obj.file_shader : مسار كل محدد ملفات [للقراءة فقط]
|
||||
|
||||
○ الطبقة
|
||||
obj.layer : رقم الطبقة التي يوجد فيها الكائن [للقراءة فقط]
|
||||
* نفس قيمة المتغير العام layer.
|
||||
@@ -451,10 +490,57 @@
|
||||
الخيارات التي تؤثر على الرسم حالياً:
|
||||
"antialias" : 0 = أقرب جار، وإلا استيفاء خطّي
|
||||
(obj.draw / obj.drawpoly).
|
||||
"blend" : رقم وضع الدمج (obj.draw / obj.drawpoly). بنفس ترتيب
|
||||
القائمة المنسدلة "وضع الدمج" في لوحة الخصائص في YMM4 (يبدأ من 0):
|
||||
0=عادي,1=اكتمل الذوبان,2=أغمق,3=ضرب,4=حرق اللون,
|
||||
5=احتراق خطي,6=معالجة (أخفّ),7=شاشة,8=تراكب اللون,
|
||||
9=المزج الخطي (إضافة),10=إضافة,11=تراكب,12=ضوء ناعم,
|
||||
13=ضوء قوي,14=ضوء حيوي,15=الضوء الخطي,16=ضوء دبوس,
|
||||
17=مزج قوي,18=الفرق,19=استبعاد,20=طرح,21=القسمة,22=تدرج,
|
||||
23=التشبع,24=لون,25=السطوع,26=لون أفتح,27=خلفية,
|
||||
28=لون أغمق,29=مسح,30=القص حسب الخلفية,
|
||||
31=فقط الأجزاء غير المتراكبة,32=قناع عكس الألوان.
|
||||
القيم خارج النطاق أو غير الصالحة تُعامَل كـ 0 (عادي).
|
||||
"draw_state" : قيمة منطقية تحدد ما إذا كان هذا التأثير يُخرج صورة
|
||||
العمل. true تُخرج صورة العمل، وfalse تمرر الدخل كما هو. تُستخدم
|
||||
لإخراج صورة العمل دون obj.draw أو setpixel، أو لإيقاف الإخراج.
|
||||
تعمل في المحركين معاً.
|
||||
"drawtarget" : يبدّل وجهة رسم obj.draw / obj.drawpoly.
|
||||
"framebuffer" (الافتراضي) يركّب في مخزن الإطار. "tempbuffer"
|
||||
يركّب في مخزن العمل tmp مباشرة. في
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) تُحدد w, h حجم
|
||||
تهيئة مخزن tmp، وحذفهما يُبقيه كما هو. أعِد نتيجة tmp إلى صورة
|
||||
العمل عبر obj.copybuffer("obj", "tmp"). التركيب في tempbuffer
|
||||
عادي (source-over)، وblend يُطبَّق على الرسم في framebuffer.
|
||||
تعمل في المحركين معاً. في MoonSharp يُنفَّذ التركيب في tempbuffer
|
||||
على GPU، ويتحوّل تلقائياً إلى التركيب على CPU عندما تكون GPU
|
||||
غير متاحة. وبسبب اختلاف التقريب قد تختلف نتيجة التركيب
|
||||
اختلافاً طفيفاً جداً بين المحركين.
|
||||
|
||||
○ obj.pixeloption(name, value)
|
||||
يحفظ خياراً لعمليات البكسل كحالة.
|
||||
|
||||
○ obj.setanchor(name, count [, option, ..])
|
||||
يعرض نقاط الإرساء على المعاينة لضبط إحداثياتها بالسحب بالفأرة.
|
||||
تُحفَظ الإحداثيات المعدّلة مع المشروع.
|
||||
name : اسم متغير Lua الذي يستقبل الإحداثيات، كسلسلة نصية. يكون
|
||||
المتغير بالترتيب pos={x0,y0,x1,y1,…}، أو {x0,y0,z0,x1,y1,z1,…}
|
||||
مع "xyz". الإحداثيات بالنسبة إلى مركز الكائن.
|
||||
count : عدد نقاط الإرساء. حتى 32.
|
||||
option : تُذكَر كسلاسل نصية.
|
||||
"line" : يصل نقاط الإرساء بخطوط.
|
||||
"loop" : يصل نقاط الإرساء ويغلق الحلقة.
|
||||
"star" : يصل كل نقطة إرساء بمركز الكائن.
|
||||
"arm" : يصل مركز الكائن بكل نقطة إرساء بالترتيب.
|
||||
"xyz" : يعامل النقاط كإحداثيات ثلاثية الأبعاد. الافتراضي ثنائي.
|
||||
يعيد عدد نقاط الإرساء. يعمل في المحركين معاً.
|
||||
وضع شريط "track" غير مدعوم حالياً ويعيد 0.
|
||||
مثال:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
The "Lua Script" video effect in YukkuriMovieMaker4 uses
|
||||
the Lua language for scripting.
|
||||
The scripting engine is MoonSharp (Lua 5.2 compatible).
|
||||
Scripts run on the bundled fast runtime (LuaJIT), and fall back to
|
||||
MoonSharp (Lua 5.2 compatible) when the runtime is unavailable.
|
||||
|
||||
* This effect is a custom implementation and differs from the AviUtl2 script specification.
|
||||
* This is a separate specification from AviUtl2 script files (*.anm2, etc.).
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
- Notes -
|
||||
|
||||
o The script execution engine is MoonSharp (Lua 5.2 compatible).
|
||||
o The script execution engines are LuaJIT (default) and MoonSharp (Lua 5.2 compatible).
|
||||
o Available standard libraries are limited to the following:
|
||||
table, string, math, bit32
|
||||
* io, os, debug, ffi, require, etc. are not available.
|
||||
@@ -26,16 +27,16 @@
|
||||
|
||||
- Execution Engines and Automatic Acceleration -
|
||||
|
||||
Scripts that contain pixel processing (a nested getpixel/setpixel loop)
|
||||
are analyzed and automatically routed to a faster engine.
|
||||
Ordinary scripts (coordinate, rotation, opacity changes, etc.) keep
|
||||
running on MoonSharp as before, with no change in behavior.
|
||||
Scripts are analyzed and automatically routed to the best engine.
|
||||
Scripts without a directive run on the bundled fast runtime (LuaJIT),
|
||||
and self-contained per-pixel maps are further compiled to the even
|
||||
faster CPU kernel. Either way the results match MoonSharp.
|
||||
|
||||
o Automatic routing (when no directive is present)
|
||||
- A self-contained per-pixel map (see conditions below)
|
||||
-> CPU kernel (fast, exact)
|
||||
- Other pixel operations -> Native (LuaJIT, only when deployed)
|
||||
- No pixel operations -> MoonSharp
|
||||
- Everything else -> Native (LuaJIT, only when deployed)
|
||||
- Native not deployed, or an empty script -> MoonSharp
|
||||
|
||||
o Engine directives (a comment on the first line of the script)
|
||||
--!cpu : CPU kernel. Compiled at runtime to an expression
|
||||
@@ -97,6 +98,33 @@
|
||||
value ranges within the script. The AviUtl --track / --check / --color headers
|
||||
still work as before.
|
||||
|
||||
There are 4 numeric sliders, referenced as obj.slider0 through obj.slider3.
|
||||
The values are integers and do not hold decimals.
|
||||
|
||||
Slider0 : Integer slider (Range: 1 ~ 10)
|
||||
Slider1 : Integer slider (Range: 0 ~ 100)
|
||||
Slider2 : Integer slider (Range: 0 ~ 1000)
|
||||
Slider3 : Integer slider (Range: -1000 ~ 1000)
|
||||
|
||||
String parameters are also available, referenced by the following names.
|
||||
|
||||
obj.text : String from the text input field
|
||||
obj.font : Font name from the font selector
|
||||
obj.dir : Path from the folder selector
|
||||
obj.file_video : Path of a video file
|
||||
obj.file_audio : Path of an audio file
|
||||
obj.file_image : Path of an image file
|
||||
obj.file_project : Path of a project file
|
||||
obj.file_mp4 : Path of an MP4 file
|
||||
obj.file_exo : Path of an EXO file
|
||||
obj.file_subtitle : Path of a subtitle file
|
||||
obj.file_shader : Path of a shader file
|
||||
|
||||
* The sliders and string parameters appear in the effect panel automatically
|
||||
when the script references them.
|
||||
* A file path can be passed to obj.load to load an image or movie.
|
||||
* These parameters are available in both the MoonSharp and native engines.
|
||||
|
||||
|
||||
- Global Variables -
|
||||
|
||||
@@ -220,6 +248,18 @@
|
||||
obj.track2 : Current value of Track2 in the effect panel [ReadOnly]
|
||||
obj.track3 : Current value of Track3 in the effect panel [ReadOnly]
|
||||
|
||||
o Sliders
|
||||
obj.slider0 : Current value of Slider0 in the effect panel (integer) [ReadOnly]
|
||||
obj.slider1 : Current value of Slider1 in the effect panel (integer) [ReadOnly]
|
||||
obj.slider2 : Current value of Slider2 in the effect panel (integer) [ReadOnly]
|
||||
obj.slider3 : Current value of Slider3 in the effect panel (integer) [ReadOnly]
|
||||
|
||||
o String parameters
|
||||
obj.text : String from the text input field [ReadOnly]
|
||||
obj.font : Font name from the font selector [ReadOnly]
|
||||
obj.dir : Path from the folder selector [ReadOnly]
|
||||
obj.file_video ~ obj.file_shader : Path from each file selector [ReadOnly]
|
||||
|
||||
o Layer
|
||||
obj.layer : Layer number where the object is placed [ReadOnly]
|
||||
* Same value as global variable layer.
|
||||
@@ -467,10 +507,61 @@
|
||||
Options that currently affect drawing:
|
||||
"antialias" : 0 = nearest neighbor, otherwise linear interpolation
|
||||
(obj.draw / obj.drawpoly).
|
||||
"blend" : blend mode number (obj.draw / obj.drawpoly). Same order
|
||||
(0-based) as YMM4's own "Blend mode" dropdown in the property
|
||||
panel: 0=Normal,1=Dissolve,2=Darker,3=Multiply,4=Color burn,
|
||||
5=Linear burn,6=Lighter,7=Screen,8=Color dodge,
|
||||
9=Linear dodge (Add),10=Add,11=Overlay,12=Soft light,
|
||||
13=Hard light,14=Vivid light,15=Linear light,16=Pin light,
|
||||
17=Hard mix,18=Difference,19=Exclution,20=Subtract,
|
||||
21=Division,22=Hue,23=Saturation,24=Color,25=Luminance,
|
||||
26=Lighter color,27=Behind,28=Darker color,29=Clear,
|
||||
30=Clipping by background,31=XOR,32=Color inversion mask.
|
||||
Out-of-range or invalid values are treated as 0 (Normal).
|
||||
"draw_state" : a boolean that decides whether this effect emits
|
||||
its working image. true outputs the working image; false passes
|
||||
the input through unchanged. Use it to emit the working image
|
||||
without obj.draw or setpixel, or to suppress the output. It works
|
||||
in both engines.
|
||||
"drawtarget" : switches the destination of obj.draw / obj.drawpoly.
|
||||
"framebuffer" (default) composites into the frame buffer.
|
||||
"tempbuffer" composites into the working tmp buffer in place. In
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) the w, h give the
|
||||
size to initialize the tmp buffer; omit them to keep it. Bring the
|
||||
tmp result back to the working image with
|
||||
obj.copybuffer("obj", "tmp"). Compositing into tempbuffer is
|
||||
normal (source-over); blend applies to framebuffer drawing. It
|
||||
works in both engines. In MoonSharp the compositing into
|
||||
tempbuffer runs on the GPU and switches to the CPU compositing
|
||||
automatically when the GPU is unavailable. Due to rounding, the
|
||||
composited result may differ very slightly between the engines.
|
||||
|
||||
o obj.pixeloption(name, value)
|
||||
Stores an option for pixel operations as state.
|
||||
|
||||
o obj.setanchor(name, count [, option, ..])
|
||||
Shows anchor points on the preview so their coordinates can be
|
||||
adjusted by mouse dragging. The adjusted coordinates are saved with
|
||||
the project.
|
||||
name : the name of the Lua variable that receives the coordinates,
|
||||
given as a string. The variable is laid out as
|
||||
pos={x0,y0,x1,y1,…}, or {x0,y0,z0,x1,y1,z1,…} with "xyz".
|
||||
Coordinates are relative to the object center.
|
||||
count : the number of anchor points. Up to 32.
|
||||
option : enumerated as strings.
|
||||
"line" : connect the anchor points with lines.
|
||||
"loop" : connect the anchor points and close the loop.
|
||||
"star" : connect each anchor point to the object center.
|
||||
"arm" : connect the object center to each anchor point in order.
|
||||
"xyz" : treat the anchor points as 3D coordinates. 2D by default.
|
||||
Returns the number of anchor points. It works in both engines.
|
||||
The "track" trackbar mode is not supported yet and returns 0.
|
||||
Example:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
El efecto de video «Script Lua» de YukkuriMovieMaker4 utiliza
|
||||
el lenguaje Lua para los scripts.
|
||||
El motor de scripts empleado es MoonSharp (compatible con Lua 5.2).
|
||||
Los scripts se ejecutan en el runtime rápido incluido (LuaJIT) y,
|
||||
cuando este no está disponible, en MoonSharp (compatible con Lua 5.2).
|
||||
|
||||
* Este efecto es una implementación propia y difiere de la especificación de scripts de AviUtl2.
|
||||
* Tiene una especificación distinta a los archivos de script de AviUtl2 (*.anm2, etc.).
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
- Notas -
|
||||
|
||||
o El motor de ejecución de scripts es MoonSharp (compatible con Lua 5.2).
|
||||
o Los motores de ejecución son LuaJIT (predeterminado) y MoonSharp (compatible con Lua 5.2).
|
||||
o Las bibliotecas estándar disponibles se limitan a las siguientes:
|
||||
table, string, math, bit32
|
||||
* io, os, debug, ffi, require, etc. no están disponibles.
|
||||
@@ -26,17 +27,17 @@
|
||||
|
||||
- Motores de ejecución y aceleración automática -
|
||||
|
||||
Los scripts que contienen procesamiento de píxeles (un bucle anidado
|
||||
getpixel/setpixel) se analizan y se enrutan automáticamente a un motor
|
||||
más rápido. Los scripts normales (coordenadas, rotación, opacidad, etc.)
|
||||
siguen ejecutándose en MoonSharp como antes, sin cambios de comportamiento.
|
||||
Los scripts se analizan y se enrutan automáticamente al mejor motor.
|
||||
Los scripts sin directiva se ejecutan en el runtime rápido incluido
|
||||
(LuaJIT), y los mapeos por píxel autocontenidos se compilan además al
|
||||
núcleo CPU, aún más rápido. En ambos casos los resultados coinciden
|
||||
con MoonSharp.
|
||||
|
||||
o Enrutamiento automático (cuando no hay directiva)
|
||||
- Un mapeo por píxel autocontenido (ver condiciones abajo)
|
||||
-> núcleo CPU (rápido, exacto)
|
||||
- Otras operaciones de píxeles -> Nativo (LuaJIT, solo si está
|
||||
desplegado)
|
||||
- Sin operaciones de píxeles -> MoonSharp
|
||||
- Todo lo demás -> Nativo (LuaJIT, solo si está desplegado)
|
||||
- Nativo no desplegado, o script vacío -> MoonSharp
|
||||
|
||||
o Directivas de motor (un comentario en la primera línea del script)
|
||||
--!cpu : Núcleo CPU. Compilado en tiempo de ejecución a un
|
||||
@@ -97,6 +98,33 @@
|
||||
así que gestione los rangos dentro del script. Las cabeceras --track / --check /
|
||||
--color de AviUtl siguen funcionando como antes.
|
||||
|
||||
Hay 4 deslizadores numéricos, referenciados como obj.slider0 ~ obj.slider3.
|
||||
Los valores son enteros y no contienen decimales.
|
||||
|
||||
Slider0 : Deslizador entero (Rango: 1 ~ 10)
|
||||
Slider1 : Deslizador entero (Rango: 0 ~ 100)
|
||||
Slider2 : Deslizador entero (Rango: 0 ~ 1000)
|
||||
Slider3 : Deslizador entero (Rango: -1000 ~ 1000)
|
||||
|
||||
También hay parámetros de cadena, referenciados por los siguientes nombres.
|
||||
|
||||
obj.text : Cadena del campo de entrada de texto
|
||||
obj.font : Nombre de fuente del selector de fuentes
|
||||
obj.dir : Ruta del selector de carpetas
|
||||
obj.file_video : Ruta de un archivo de video
|
||||
obj.file_audio : Ruta de un archivo de audio
|
||||
obj.file_image : Ruta de un archivo de imagen
|
||||
obj.file_project : Ruta de un archivo de proyecto
|
||||
obj.file_mp4 : Ruta de un archivo MP4
|
||||
obj.file_exo : Ruta de un archivo EXO
|
||||
obj.file_subtitle : Ruta de un archivo de subtítulos
|
||||
obj.file_shader : Ruta de un archivo de sombreador
|
||||
|
||||
* Los deslizadores y los parámetros de cadena aparecen en el panel de efectos
|
||||
automáticamente cuando el script los referencia.
|
||||
* Una ruta de archivo puede pasarse a obj.load para cargar una imagen o un video.
|
||||
* Estos parámetros están disponibles en los motores MoonSharp y nativo.
|
||||
|
||||
|
||||
- Variables globales -
|
||||
|
||||
@@ -217,6 +245,18 @@
|
||||
obj.track2 : Valor actual de Track2 en el panel de efectos [Solo lectura]
|
||||
obj.track3 : Valor actual de Track3 en el panel de efectos [Solo lectura]
|
||||
|
||||
o Deslizadores
|
||||
obj.slider0 : Valor actual de Slider0 en el panel de efectos (entero) [Solo lectura]
|
||||
obj.slider1 : Valor actual de Slider1 en el panel de efectos (entero) [Solo lectura]
|
||||
obj.slider2 : Valor actual de Slider2 en el panel de efectos (entero) [Solo lectura]
|
||||
obj.slider3 : Valor actual de Slider3 en el panel de efectos (entero) [Solo lectura]
|
||||
|
||||
o Parámetros de cadena
|
||||
obj.text : Cadena del campo de entrada de texto [Solo lectura]
|
||||
obj.font : Nombre de fuente del selector de fuentes [Solo lectura]
|
||||
obj.dir : Ruta del selector de carpetas [Solo lectura]
|
||||
obj.file_video ~ obj.file_shader : Ruta de cada selector de archivos [Solo lectura]
|
||||
|
||||
o Capa
|
||||
obj.layer : Número de capa donde se encuentra el objeto [Solo lectura]
|
||||
* Mismo valor que la variable global layer.
|
||||
@@ -466,10 +506,66 @@
|
||||
Opciones que afectan al dibujo actualmente:
|
||||
"antialias" : 0 = vecino más cercano, en otro caso interpolación
|
||||
lineal (obj.draw / obj.drawpoly).
|
||||
"blend" : número de modo de fusión (obj.draw / obj.drawpoly). El
|
||||
mismo orden (empezando en 0) que la lista desplegable "Modo de
|
||||
fusión" del panel de propiedades de YMM4:
|
||||
0=Normal,1=Síntesis de interpolación,2=Comparación (oscura),
|
||||
3=Multiplicar,4=Color de relleno,5=Burn-in (lineal),
|
||||
6=Comparación (clara),7=Pantalla,8=Color sin máscara,
|
||||
9=Sin máscara (lineal) - Aditivo,10=Adición,11=Superponer,
|
||||
12=Luz suave,13=Luz dura,14=Luz viva,15=Luz lineal,
|
||||
16=Pin Light,17=Mezcla dura,18=diferencia,19=Excluido,
|
||||
20=Sustracción,21=División,22=Tono,23=Saturación,24=Color,
|
||||
25=Luminosidad,26=Comparación de colores (claro),27=Fondo,
|
||||
28=Comparación de colores (oscuro),29=Supresión,
|
||||
30=Recorte en el fondo,31=Sólo partes no superpuestas,
|
||||
32=Máscara de inversión de color. Los valores fuera de rango
|
||||
o no válidos se tratan como 0 (Normal).
|
||||
"draw_state" : un booleano que decide si este efecto emite su
|
||||
imagen de trabajo. true emite la imagen de trabajo; false deja
|
||||
pasar la entrada sin cambios. Sirve para emitir la imagen de
|
||||
trabajo sin obj.draw ni setpixel, o para suprimir la salida.
|
||||
Funciona en ambos motores.
|
||||
"drawtarget" : cambia el destino de obj.draw / obj.drawpoly.
|
||||
"framebuffer" (por defecto) compone en el búfer de fotograma.
|
||||
"tempbuffer" compone en el búfer de trabajo tmp en el momento. En
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) los valores w, h
|
||||
dan el tamaño con que se inicializa el búfer tmp; omítelos para
|
||||
conservarlo. Recupera el resultado de tmp a la imagen de trabajo
|
||||
con obj.copybuffer("obj", "tmp"). La composición en tempbuffer es
|
||||
normal (source-over); blend se aplica al dibujo en framebuffer.
|
||||
Funciona en ambos motores. En MoonSharp la composición en
|
||||
tempbuffer se ejecuta en la GPU y cambia automáticamente a la
|
||||
composición por CPU cuando la GPU no está disponible. Por el
|
||||
redondeo, el resultado puede diferir muy ligeramente entre los
|
||||
motores.
|
||||
|
||||
o obj.pixeloption(nombre, valor)
|
||||
Guarda como estado una opción para las operaciones de píxeles.
|
||||
|
||||
o obj.setanchor(nombre, cantidad [, opción, ..])
|
||||
Muestra puntos de anclaje en la vista previa para ajustar sus
|
||||
coordenadas arrastrando con el ratón. Las coordenadas ajustadas se
|
||||
guardan con el proyecto.
|
||||
nombre : el nombre de la variable Lua que recibe las coordenadas,
|
||||
como cadena. La variable se dispone como pos={x0,y0,x1,y1,…}, o
|
||||
{x0,y0,z0,x1,y1,z1,…} con "xyz". Las coordenadas son relativas
|
||||
al centro del objeto.
|
||||
cantidad : el número de puntos de anclaje. Hasta 32.
|
||||
opción : se enumeran como cadenas.
|
||||
"line" : une los puntos de anclaje con líneas.
|
||||
"loop" : une los puntos de anclaje y cierra el bucle.
|
||||
"star" : une cada punto de anclaje con el centro del objeto.
|
||||
"arm" : une el centro del objeto con cada punto en orden.
|
||||
"xyz" : trata los puntos como coordenadas 3D. 2D por defecto.
|
||||
Devuelve el número de puntos de anclaje. Funciona en ambos motores.
|
||||
El modo de barra "track" aún no se admite y devuelve 0.
|
||||
Ejemplo:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
Efek video "Script Lua" di YukkuriMovieMaker4 menggunakan
|
||||
bahasa Lua untuk penulisan skrip.
|
||||
Mesin skrip yang digunakan adalah MoonSharp (kompatibel dengan Lua 5.2).
|
||||
Skrip dijalankan pada runtime cepat yang disertakan (LuaJIT), dan
|
||||
berjalan pada MoonSharp (kompatibel dengan Lua 5.2) jika runtime
|
||||
tersebut tidak tersedia.
|
||||
|
||||
* Efek ini adalah implementasi mandiri dan berbeda dari spesifikasi skrip AviUtl2.
|
||||
* Memiliki spesifikasi yang berbeda dari file skrip AviUtl2 (*.anm2, dll.).
|
||||
@@ -11,7 +13,7 @@
|
||||
|
||||
- Catatan -
|
||||
|
||||
o Mesin eksekusi skrip adalah MoonSharp (kompatibel dengan Lua 5.2).
|
||||
o Mesin eksekusi skrip adalah LuaJIT (bawaan) dan MoonSharp (kompatibel dengan Lua 5.2).
|
||||
o Pustaka standar yang tersedia terbatas pada berikut ini:
|
||||
table, string, math, bit32
|
||||
* io, os, debug, ffi, require, dll. tidak tersedia.
|
||||
@@ -26,16 +28,17 @@
|
||||
|
||||
- Mesin Eksekusi dan Akselerasi Otomatis -
|
||||
|
||||
Skrip yang berisi pemrosesan piksel (loop bersarang getpixel/setpixel)
|
||||
dianalisis sintaksnya dan secara otomatis dialihkan ke mesin yang lebih
|
||||
cepat. Skrip biasa (koordinat, rotasi, opasitas, dll.) tetap berjalan di
|
||||
MoonSharp seperti sebelumnya, tanpa perubahan perilaku.
|
||||
Skrip dianalisis sintaksnya dan secara otomatis dialihkan ke mesin
|
||||
yang paling sesuai. Skrip tanpa direktif dijalankan pada runtime cepat
|
||||
yang disertakan (LuaJIT), dan pemetaan per-piksel mandiri dikompilasi
|
||||
lebih lanjut ke kernel CPU yang lebih cepat lagi. Hasil keduanya sama
|
||||
dengan MoonSharp.
|
||||
|
||||
o Pengalihan otomatis (saat tidak ada direktif)
|
||||
- Pemetaan per-piksel mandiri (lihat syarat di bawah)
|
||||
-> kernel CPU (cepat, tepat)
|
||||
- Operasi piksel lainnya -> Native (LuaJIT, hanya jika di-deploy)
|
||||
- Tanpa operasi piksel -> MoonSharp
|
||||
- Selain itu -> Native (LuaJIT, hanya jika di-deploy)
|
||||
- Native tidak di-deploy, atau skrip kosong -> MoonSharp
|
||||
|
||||
o Direktif mesin (komentar pada baris pertama skrip)
|
||||
--!cpu : Kernel CPU. Dikompilasi saat runtime menjadi pohon
|
||||
@@ -96,6 +99,33 @@
|
||||
rentang nilai di dalam skrip. Header --track / --check / --color AviUtl tetap
|
||||
berfungsi seperti sebelumnya.
|
||||
|
||||
Ada 4 slider numerik, direferensikan sebagai obj.slider0 hingga obj.slider3.
|
||||
Nilainya berupa bilangan bulat dan tidak memuat desimal.
|
||||
|
||||
Slider0 : Slider bilangan bulat (Rentang: 1 ~ 10)
|
||||
Slider1 : Slider bilangan bulat (Rentang: 0 ~ 100)
|
||||
Slider2 : Slider bilangan bulat (Rentang: 0 ~ 1000)
|
||||
Slider3 : Slider bilangan bulat (Rentang: -1000 ~ 1000)
|
||||
|
||||
Parameter string juga tersedia, direferensikan dengan nama berikut.
|
||||
|
||||
obj.text : String dari kolom input teks
|
||||
obj.font : Nama font dari pemilih font
|
||||
obj.dir : Path dari pemilih folder
|
||||
obj.file_video : Path file video
|
||||
obj.file_audio : Path file audio
|
||||
obj.file_image : Path file gambar
|
||||
obj.file_project : Path file proyek
|
||||
obj.file_mp4 : Path file MP4
|
||||
obj.file_exo : Path file EXO
|
||||
obj.file_subtitle : Path file subtitle
|
||||
obj.file_shader : Path file shader
|
||||
|
||||
* Slider dan parameter string muncul di panel efek secara otomatis saat skrip
|
||||
mereferensikannya.
|
||||
* Path file dapat diteruskan ke obj.load untuk memuat gambar atau video.
|
||||
* Parameter ini tersedia pada mesin MoonSharp maupun native.
|
||||
|
||||
|
||||
- Variabel Global -
|
||||
|
||||
@@ -216,6 +246,18 @@
|
||||
obj.track2 : Nilai saat ini Track2 di panel efek [Hanya Baca]
|
||||
obj.track3 : Nilai saat ini Track3 di panel efek [Hanya Baca]
|
||||
|
||||
o Slider
|
||||
obj.slider0 : Nilai saat ini Slider0 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
obj.slider1 : Nilai saat ini Slider1 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
obj.slider2 : Nilai saat ini Slider2 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
obj.slider3 : Nilai saat ini Slider3 di panel efek (bilangan bulat) [Hanya Baca]
|
||||
|
||||
o Parameter string
|
||||
obj.text : String dari kolom input teks [Hanya Baca]
|
||||
obj.font : Nama font dari pemilih font [Hanya Baca]
|
||||
obj.dir : Path dari pemilih folder [Hanya Baca]
|
||||
obj.file_video ~ obj.file_shader : Path dari setiap pemilih file [Hanya Baca]
|
||||
|
||||
o Layer
|
||||
obj.layer : Nomor layer tempat objek ditempatkan [Hanya Baca]
|
||||
* Nilai yang sama dengan variabel global layer.
|
||||
@@ -462,10 +504,64 @@
|
||||
Opsi yang saat ini memengaruhi penggambaran:
|
||||
"antialias" : 0 = tetangga terdekat, selain itu interpolasi linear
|
||||
(obj.draw / obj.drawpoly).
|
||||
"blend" : nomor mode blend (obj.draw / obj.drawpoly). Urutan yang
|
||||
sama (mulai dari 0) dengan dropdown "Mode blend" pada panel
|
||||
properti YMM4:
|
||||
0=Normal,1=Larut,2=Gelap,3=Multiply,4=Bakar warna,
|
||||
5=Bakar linier,6=Terang,7=Layar,8=Peleburan warna,
|
||||
9=Peleburan linier (tambah),10=Tambah,11=Overlay,
|
||||
12=Cahaya lembut,13=Cahaya keras,14=Cahaya hidup,
|
||||
15=Cahaya linier,16=Cahaya pin,17=Campuran keras,
|
||||
18=Perbedaan,19=Ekslklusi,20=Pengurangan,21=Divisi,22=Hue,
|
||||
23=Saturasi,24=Warna,25=Pencahayaan,26=Warna terang,
|
||||
27=Belakang,28=Warna gelap,29=Bersih,
|
||||
30=Potong dengan latar belakang,
|
||||
31=Hanya bagian yang tidak tumpang tindih,32=Mask inversi warna.
|
||||
Nilai di luar jangkauan atau tidak valid dianggap 0 (Normal).
|
||||
"draw_state" : boolean yang menentukan apakah efek ini
|
||||
mengeluarkan citra kerjanya. true mengeluarkan citra kerja;
|
||||
false meneruskan input apa adanya. Berguna untuk mengeluarkan
|
||||
citra kerja tanpa obj.draw atau setpixel, atau untuk menekan
|
||||
keluaran. Bekerja pada kedua mesin.
|
||||
"drawtarget" : mengganti tujuan gambar obj.draw / obj.drawpoly.
|
||||
"framebuffer" (bawaan) mengomposit ke frame buffer. "tempbuffer"
|
||||
mengomposit ke buffer kerja tmp secara langsung. Pada
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h), w, h adalah
|
||||
ukuran untuk menginisialisasi buffer tmp; hilangkan untuk
|
||||
mempertahankannya. Kembalikan hasil tmp ke citra kerja dengan
|
||||
obj.copybuffer("obj", "tmp"). Komposit ke tempbuffer bersifat
|
||||
normal (source-over); blend berlaku untuk gambar ke framebuffer.
|
||||
Bekerja pada kedua mesin. Pada MoonSharp, komposit ke tempbuffer
|
||||
dijalankan di GPU dan beralih secara otomatis ke komposit CPU
|
||||
saat GPU tidak tersedia. Karena pembulatan, hasil komposit dapat
|
||||
sedikit berbeda antara kedua mesin.
|
||||
|
||||
o obj.pixeloption(name, value)
|
||||
Menyimpan opsi untuk operasi piksel sebagai status.
|
||||
|
||||
o obj.setanchor(name, count [, option, ..])
|
||||
Menampilkan titik jangkar pada pratinjau agar koordinatnya dapat
|
||||
disesuaikan dengan menyeret mouse. Koordinat yang disesuaikan
|
||||
disimpan bersama proyek.
|
||||
name : nama variabel Lua yang menerima koordinat, sebagai string.
|
||||
Variabel disusun sebagai pos={x0,y0,x1,y1,…}, atau
|
||||
{x0,y0,z0,x1,y1,z1,…} dengan "xyz". Koordinat relatif terhadap
|
||||
pusat objek.
|
||||
count : jumlah titik jangkar. Hingga 32.
|
||||
option : dicantumkan sebagai string.
|
||||
"line" : menghubungkan titik jangkar dengan garis.
|
||||
"loop" : menghubungkan titik jangkar dan menutup lingkaran.
|
||||
"star" : menghubungkan tiap titik jangkar ke pusat objek.
|
||||
"arm" : menghubungkan pusat objek ke tiap titik secara berurutan.
|
||||
"xyz" : memperlakukan titik sebagai koordinat 3D. Bawaan 2D.
|
||||
Mengembalikan jumlah titik jangkar. Bekerja pada kedua mesin.
|
||||
Mode bilah "track" belum didukung dan mengembalikan 0.
|
||||
Contoh:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 Table -
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
YukkuriMovieMaker4 の「Luaスクリプト」映像エフェクトで
|
||||
利用可能なスクリプトには Lua 言語を使用します。
|
||||
スクリプトエンジンには MoonSharp (Lua 5.2 互換) が採用されています。
|
||||
スクリプトは同梱の高速ランタイム(LuaJIT)で実行され、
|
||||
利用できない環境では MoonSharp (Lua 5.2 互換) で実行されます。
|
||||
|
||||
※このエフェクトは AviUtl2 のスクリプト仕様とは異なる独自実装です。
|
||||
※AviUtl2 のスクリプトファイル(*.anm2 等)とは別仕様です。
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
- 注意点 -
|
||||
|
||||
○スクリプトの実行エンジンは MoonSharp (Lua 5.2 互換) です。
|
||||
○スクリプトの実行エンジンは LuaJIT(標準)と MoonSharp (Lua 5.2 互換) です。
|
||||
○利用可能な標準ライブラリは以下に限定されます。
|
||||
table, string, math, bit32
|
||||
※io, os, debug, ffi, require 等は使用できません。
|
||||
@@ -26,15 +27,15 @@
|
||||
|
||||
- 実行エンジンと自動高速化 -
|
||||
|
||||
ピクセル処理(getpixel/setpixel の二重ループ)を含むスクリプトは、
|
||||
構文を解析して自動的に高速なエンジンへ振り分けられます。
|
||||
座標・回転・不透明度などの通常スクリプトは従来どおり MoonSharp で
|
||||
実行され、挙動は一切変わりません。
|
||||
スクリプトは構文を解析して自動的に最適なエンジンへ振り分けられます。
|
||||
ディレクティブ無しのスクリプトは同梱の高速ランタイム(LuaJIT)で
|
||||
実行され、自ピクセル完結のピクセル写像はさらに高速な CPU カーネルへ
|
||||
変換されます。いずれの結果も MoonSharp と一致します。
|
||||
|
||||
○自動振り分け(ディレクティブ無しのとき)
|
||||
・自ピクセル完結のピクセル写像(下記条件) → CPU カーネル(高速・厳密)
|
||||
・上記以外のピクセル操作 → ネイティブ(LuaJIT, 配備時のみ)
|
||||
・ピクセル操作なし → MoonSharp
|
||||
・上記以外 → ネイティブ(LuaJIT, 配備時のみ)
|
||||
・native 未配備または空のスクリプト → MoonSharp
|
||||
|
||||
○エンジン指定ディレクティブ(スクリプト先頭行のコメント)
|
||||
--!cpu : CPU カーネル。式ツリーへ実行時コンパイルして
|
||||
@@ -91,6 +92,33 @@
|
||||
この一般利用では範囲・既定値の宣言を伴わないため、値はスクリプト内で扱います。
|
||||
--track / --check / --color ヘッダによる宣言表示も従来どおり利用できます。
|
||||
|
||||
数値スライダーが 4 つあり、各値は obj.slider0 ~ obj.slider3 として参照できます。
|
||||
値は整数で、小数は扱いません。
|
||||
|
||||
Slider0 : 整数スライダー (範囲: 1 ~ 10)
|
||||
Slider1 : 整数スライダー (範囲: 0 ~ 100)
|
||||
Slider2 : 整数スライダー (範囲: 0 ~ 1000)
|
||||
Slider3 : 整数スライダー (範囲: -1000 ~ 1000)
|
||||
|
||||
文字列パラメータも利用でき、各値は以下の名前で参照できます。
|
||||
|
||||
obj.text : テキスト入力欄の文字列
|
||||
obj.font : フォント選択欄のフォント名
|
||||
obj.dir : フォルダ選択欄のパス
|
||||
obj.file_video : 動画ファイルのパス
|
||||
obj.file_audio : 音声ファイルのパス
|
||||
obj.file_image : 画像ファイルのパス
|
||||
obj.file_project : プロジェクトファイルのパス
|
||||
obj.file_mp4 : MP4 ファイルのパス
|
||||
obj.file_exo : EXO ファイルのパス
|
||||
obj.file_subtitle : 字幕ファイルのパス
|
||||
obj.file_shader : シェーダーファイルのパス
|
||||
|
||||
※スライダーと文字列パラメータは、スクリプト本体でそれらを参照すると
|
||||
自動的にエフェクトパネルへ表示されます。
|
||||
※ファイル選択のパスは obj.load へ渡して画像・動画の読み込みに使えます。
|
||||
※これらのパラメータは MoonSharp とネイティブのどちらのエンジンでも参照できます。
|
||||
|
||||
|
||||
- グローバル変数 -
|
||||
|
||||
@@ -214,6 +242,18 @@
|
||||
obj.track2 : エフェクトパネルの Track2 の現在値 [ReadOnly]
|
||||
obj.track3 : エフェクトパネルの Track3 の現在値 [ReadOnly]
|
||||
|
||||
○スライダー
|
||||
obj.slider0 : エフェクトパネルの Slider0 の現在値(整数) [ReadOnly]
|
||||
obj.slider1 : エフェクトパネルの Slider1 の現在値(整数) [ReadOnly]
|
||||
obj.slider2 : エフェクトパネルの Slider2 の現在値(整数) [ReadOnly]
|
||||
obj.slider3 : エフェクトパネルの Slider3 の現在値(整数) [ReadOnly]
|
||||
|
||||
○文字列パラメータ
|
||||
obj.text : テキスト入力欄の文字列 [ReadOnly]
|
||||
obj.font : フォント選択欄のフォント名 [ReadOnly]
|
||||
obj.dir : フォルダ選択欄のパス [ReadOnly]
|
||||
obj.file_video 〜 obj.file_shader : 各ファイル選択欄のパス [ReadOnly]
|
||||
|
||||
○レイヤー
|
||||
obj.layer : オブジェクトが配置されているレイヤー番号 [ReadOnly]
|
||||
※ グローバル変数 layer と同じ値です。
|
||||
@@ -451,10 +491,61 @@
|
||||
停止させません(getoption は設定値を返し、未設定は 0)。
|
||||
現在描画へ反映される項目:
|
||||
"antialias" : 0 で最近傍、それ以外で線形補間(obj.draw/drawpoly)。
|
||||
"blend" : obj.draw / obj.drawpoly の合成モードを番号で指定します。
|
||||
YMM4 のプロパティパネルにある「合成モード」のドロップダウンと
|
||||
並び順が同じで、番号は 0 から始まります。
|
||||
0=通常,1=ディザ合成,2=比較(暗),3=乗算,4=焼き込みカラー,
|
||||
5=焼き込み(リニア),6=比較(明),7=スクリーン,8=覆い焼きカラー,
|
||||
9=覆い焼き(リニア) - 加算,10=加算,11=オーバーレイ,
|
||||
12=ソフトライト,13=ハードライト,14=ビビッドライト,15=リニアライト,
|
||||
16=ピンライト,17=ハードミックス,18=差分,19=除外,20=減算,21=除算,
|
||||
22=色相,23=彩度,24=カラー,25=輝度,26=カラー比較(明),27=背景,
|
||||
28=カラー比較(暗),29=削除,30=背景でクリッピング,
|
||||
31=重ならない部分のみ,32=色反転マスク。
|
||||
範囲外の値や数値以外を指定した場合は通常モードになります。
|
||||
"draw_state" : このエフェクトが作業画像を出力するかどうかを
|
||||
真偽値で決めます。true で作業画像を出力し、false で入力を
|
||||
そのまま通します。obj.draw や setpixel を使わずに作業画像を
|
||||
そのまま出力させたいときや、逆に出力を止めたいときに使います。
|
||||
両エンジンで動きます。
|
||||
"drawtarget" : obj.draw / obj.drawpoly の描画先を切り替えます。
|
||||
"framebuffer"(既定)ではフレームバッファへ合成します。
|
||||
"tempbuffer" では作業用の tmp バッファへその場で合成します。
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h) の w, h は
|
||||
tmp バッファを初期化するサイズで、省略すると初期化しません。
|
||||
tmp へ描いた結果は obj.copybuffer("obj", "tmp") で作業画像へ
|
||||
戻せます。tempbuffer への合成は通常(ソースオーバー)で、blend は
|
||||
framebuffer への描画に適用されます。両エンジンで動きます。
|
||||
MoonSharp では tempbuffer への合成を GPU で実行し、GPU を
|
||||
利用できない環境では CPU の合成へ自動的に切り替わります。
|
||||
丸めの違いにより、合成の結果はエンジン間でごく僅かに
|
||||
異なることがあります。
|
||||
|
||||
○obj.pixeloption(名前, 値)
|
||||
ピクセル操作のオプションを状態として保持します。
|
||||
|
||||
○obj.setanchor(名前, 個数 [, オプション, ..])
|
||||
アンカーポイントをプレビュー上に表示し、マウスドラッグで座標を
|
||||
調整できるようにします。調整した座標はプロジェクトへ保存されます。
|
||||
名前 : 座標を格納する Lua 変数の名前を文字列で指定します。
|
||||
変数は pos={x0,y0,x1,y1,…} の並びで、xyz 指定時は
|
||||
{x0,y0,z0,x1,y1,z1,…} になります。座標はオブジェクトの
|
||||
中心が原点です。
|
||||
個数 : アンカーポイントの数を指定します。最大 32 個です。
|
||||
オプション : 文字列で列挙できます。
|
||||
"line" : アンカーポイントを線で結びます。
|
||||
"loop" : アンカーポイントを線で結び一周させます。
|
||||
"star" : 各アンカーポイントとオブジェクトの中心を線で結びます。
|
||||
"arm" : オブジェクトの中心から各アンカーポイントへ順に線で結びます。
|
||||
"xyz" : アンカーポイントを 3D 座標で扱います。既定は 2D です。
|
||||
戻り値は設置したアンカーポイントの数です。両エンジンで動きます。
|
||||
名前に "track" を指定するトラックバー連携は現在未対応で、0 を返します。
|
||||
例:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 テーブル -
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
YukkuriMovieMaker4의 「Lua 스크립트」 영상 이펙트에서
|
||||
사용 가능한 스크립트에는 Lua 언어를 사용합니다.
|
||||
스크립트 엔진으로는 MoonSharp (Lua 5.2 호환)이 채용되어 있습니다.
|
||||
스크립트는 동봉된 고속 런타임(LuaJIT)으로 실행되며,
|
||||
사용할 수 없는 환경에서는 MoonSharp (Lua 5.2 호환)으로 실행됩니다.
|
||||
|
||||
※ 이 이펙트는 AviUtl2의 스크립트 사양과는 다른 독자적인 구현입니다.
|
||||
※ AviUtl2의 스크립트 파일(*.anm2 등)과는 별도의 사양입니다.
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
- 주의 사항 -
|
||||
|
||||
○ 스크립트 실행 엔진은 MoonSharp (Lua 5.2 호환)입니다.
|
||||
○ 스크립트 실행 엔진은 LuaJIT(표준)과 MoonSharp (Lua 5.2 호환)입니다.
|
||||
○ 사용 가능한 표준 라이브러리는 다음으로 제한됩니다.
|
||||
table, string, math, bit32
|
||||
※ io, os, debug, ffi, require 등은 사용할 수 없습니다.
|
||||
@@ -26,15 +27,15 @@
|
||||
|
||||
- 실행 엔진과 자동 가속 -
|
||||
|
||||
픽셀 처리(getpixel/setpixel 이중 루프)를 포함하는 스크립트는
|
||||
구문을 분석하여 자동으로 더 빠른 엔진으로 분배됩니다.
|
||||
좌표・회전・불투명도 등 일반 스크립트는 기존과 동일하게 MoonSharp으로
|
||||
실행되며 동작은 전혀 바뀌지 않습니다.
|
||||
스크립트는 구문을 분석하여 자동으로 가장 적합한 엔진으로 분배됩니다.
|
||||
디렉티브가 없는 스크립트는 동봉된 고속 런타임(LuaJIT)으로 실행되며,
|
||||
자기 픽셀로 완결되는 픽셀 매핑은 더욱 빠른 CPU 커널로 변환됩니다.
|
||||
어느 쪽이든 결과는 MoonSharp과 일치합니다.
|
||||
|
||||
○ 자동 분배(디렉티브가 없을 때)
|
||||
· 자기 픽셀로 완결되는 픽셀 매핑(아래 조건) → CPU 커널(고속・엄밀)
|
||||
· 위 이외의 픽셀 조작 → 네이티브(LuaJIT, 배치된 경우에만)
|
||||
· 픽셀 조작 없음 → MoonSharp
|
||||
· 위 이외 → 네이티브(LuaJIT, 배치된 경우에만)
|
||||
· native 미배치 또는 빈 스크립트 → MoonSharp
|
||||
|
||||
○ 엔진 지정 디렉티브(스크립트 첫 줄의 주석)
|
||||
--!cpu : CPU 커널. 식 트리로 런타임 컴파일하여
|
||||
@@ -91,6 +92,32 @@
|
||||
선언을 동반하지 않으므로 값의 범위는 스크립트 내에서 처리하세요. AviUtl의
|
||||
--track / --check / --color 헤더 선언 표시도 기존과 동일하게 사용할 수 있습니다.
|
||||
|
||||
숫자 슬라이더가 4개 있으며, 각 값은 obj.slider0 ~ obj.slider3으로 참조할 수 있습니다.
|
||||
값은 정수이며 소수는 다루지 않습니다.
|
||||
|
||||
Slider0 : 정수 슬라이더 (범위: 1 ~ 10)
|
||||
Slider1 : 정수 슬라이더 (범위: 0 ~ 100)
|
||||
Slider2 : 정수 슬라이더 (범위: 0 ~ 1000)
|
||||
Slider3 : 정수 슬라이더 (범위: -1000 ~ 1000)
|
||||
|
||||
문자열 파라미터도 사용할 수 있으며, 각 값은 다음 이름으로 참조합니다.
|
||||
|
||||
obj.text : 텍스트 입력란의 문자열
|
||||
obj.font : 글꼴 선택란의 글꼴 이름
|
||||
obj.dir : 폴더 선택란의 경로
|
||||
obj.file_video : 동영상 파일의 경로
|
||||
obj.file_audio : 음성 파일의 경로
|
||||
obj.file_image : 이미지 파일의 경로
|
||||
obj.file_project : 프로젝트 파일의 경로
|
||||
obj.file_mp4 : MP4 파일의 경로
|
||||
obj.file_exo : EXO 파일의 경로
|
||||
obj.file_subtitle : 자막 파일의 경로
|
||||
obj.file_shader : 셰이더 파일의 경로
|
||||
|
||||
※슬라이더와 문자열 파라미터는 스크립트 본문에서 참조하면 이펙트 패널에 자동으로 표시됩니다.
|
||||
※파일 선택 경로는 obj.load에 전달해 이미지・동영상을 불러오는 데 사용할 수 있습니다.
|
||||
※이 파라미터들은 MoonSharp과 네이티브 두 엔진에서 모두 참조할 수 있습니다.
|
||||
|
||||
|
||||
- 전역 변수 -
|
||||
|
||||
@@ -211,6 +238,18 @@
|
||||
obj.track2 : 이펙트 패널의 Track2 현재값 [읽기 전용]
|
||||
obj.track3 : 이펙트 패널의 Track3 현재값 [읽기 전용]
|
||||
|
||||
○ 슬라이더
|
||||
obj.slider0 : 이펙트 패널의 Slider0 현재값(정수) [읽기 전용]
|
||||
obj.slider1 : 이펙트 패널의 Slider1 현재값(정수) [읽기 전용]
|
||||
obj.slider2 : 이펙트 패널의 Slider2 현재값(정수) [읽기 전용]
|
||||
obj.slider3 : 이펙트 패널의 Slider3 현재값(정수) [읽기 전용]
|
||||
|
||||
○ 문자열 파라미터
|
||||
obj.text : 텍스트 입력란의 문자열 [읽기 전용]
|
||||
obj.font : 글꼴 선택란의 글꼴 이름 [읽기 전용]
|
||||
obj.dir : 폴더 선택란의 경로 [읽기 전용]
|
||||
obj.file_video ~ obj.file_shader : 각 파일 선택란의 경로 [읽기 전용]
|
||||
|
||||
○ 레이어
|
||||
obj.layer : 오브젝트가 배치된 레이어 번호 [읽기 전용]
|
||||
※ 전역 변수 layer와 동일한 값입니다.
|
||||
@@ -446,10 +485,59 @@
|
||||
스크립트를 중단시키지 않습니다(getoption은 설정값을 반환, 미설정은 0).
|
||||
현재 그리기에 반영되는 항목:
|
||||
"antialias" : 0이면 최근접, 그 외는 선형 보간(obj.draw / obj.drawpoly).
|
||||
"blend" : 합성 모드 번호(obj.draw / obj.drawpoly). YMM4 속성
|
||||
패널의 "합성 모드" 드롭다운과 동일한 순서(0부터 시작):
|
||||
0=보통,1=디졸브,2=비교(어두움),3=곱하기,4=색상번,
|
||||
5=구워내기(선형),6=비교(밝음),7=화면,8=색상 닷지,
|
||||
9=선형 닷지 ‐ 가산,10=가산,11=오버레이,12=소프트 라이트,
|
||||
13=하드 라이트,14=선명한 라이트,15=리니어 라이트,16=핀 라이트,
|
||||
17=하드 믹스,18=차분,19=제외,20=감산,21=디비전,22=색조,
|
||||
23=채도,24=컬러,25=밝기,26=색상 비교(밝음),27=배경,
|
||||
28=색상 비교(어두운),29=삭제,30=배경에서 클리핑,
|
||||
31=겹치지 않는 부분만,32=색상 반전 마스크.
|
||||
범위를 벗어나거나 잘못된 값은 0(보통)으로 처리합니다.
|
||||
"draw_state" : 이 이펙트가 작업 이미지를 출력할지를 불리언으로
|
||||
정합니다. true는 작업 이미지를 출력하고, false는 입력을 그대로
|
||||
통과시킵니다. obj.draw나 setpixel을 쓰지 않고 작업 이미지를
|
||||
출력하거나, 반대로 출력을 막을 때 사용합니다. 두 엔진 모두에서
|
||||
동작합니다.
|
||||
"drawtarget" : obj.draw / obj.drawpoly의 그리기 대상을 바꿉니다.
|
||||
"framebuffer"(기본)는 프레임 버퍼에 합성합니다. "tempbuffer"는
|
||||
작업용 tmp 버퍼에 즉시 합성합니다.
|
||||
obj.setoption("drawtarget", "tempbuffer", w, h)의 w, h는 tmp
|
||||
버퍼를 초기화하는 크기이며, 생략하면 초기화하지 않습니다. tmp에
|
||||
그린 결과는 obj.copybuffer("obj", "tmp")로 작업 이미지에 되돌릴
|
||||
수 있습니다. tempbuffer로의 합성은 보통(소스 오버)이며, blend는
|
||||
framebuffer 그리기에 적용됩니다. 두 엔진 모두에서 동작합니다.
|
||||
MoonSharp에서는 tempbuffer로의 합성을 GPU에서 실행하며, GPU를
|
||||
사용할 수 없는 환경에서는 CPU 합성으로 자동 전환됩니다. 반올림
|
||||
차이로 인해 합성 결과가 엔진 간에 아주 조금 다를 수 있습니다.
|
||||
|
||||
○ obj.pixeloption(이름, 값)
|
||||
픽셀 조작 옵션을 상태로 보존합니다.
|
||||
|
||||
○ obj.setanchor(이름, 개수 [, 옵션, ..])
|
||||
프리뷰에 앵커 포인트를 표시하고 마우스 드래그로 좌표를 조정할 수
|
||||
있게 합니다. 조정한 좌표는 프로젝트에 저장됩니다.
|
||||
이름 : 좌표를 받을 Lua 변수 이름을 문자열로 지정합니다. 변수는
|
||||
pos={x0,y0,x1,y1,…} 배열이며, "xyz" 지정 시
|
||||
{x0,y0,z0,x1,y1,z1,…}가 됩니다. 좌표는 오브젝트 중심이
|
||||
원점입니다.
|
||||
개수 : 앵커 포인트 수를 지정합니다. 최대 32개입니다.
|
||||
옵션 : 문자열로 열거할 수 있습니다.
|
||||
"line" : 앵커 포인트를 선으로 잇습니다.
|
||||
"loop" : 앵커 포인트를 선으로 잇고 한 바퀴 닫습니다.
|
||||
"star" : 각 앵커 포인트를 오브젝트 중심과 선으로 잇습니다.
|
||||
"arm" : 오브젝트 중심에서 각 앵커 포인트로 차례로 잇습니다.
|
||||
"xyz" : 앵커 포인트를 3D 좌표로 다룹니다. 기본은 2D입니다.
|
||||
설치한 앵커 포인트 수를 반환합니다. 두 엔진 모두에서 동작합니다.
|
||||
이름에 "track"을 지정하는 트랙바 연동은 현재 미지원이며 0을 반환합니다.
|
||||
예:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 테이블 -
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
YukkuriMovieMaker4 的"Lua 脚本"视频特效使用
|
||||
Lua 语言编写脚本。
|
||||
脚本引擎采用 MoonSharp(兼容 Lua 5.2)。
|
||||
脚本由随附的高速运行时(LuaJIT)执行,
|
||||
在其不可用的环境下改由 MoonSharp(兼容 Lua 5.2)执行。
|
||||
|
||||
* 本特效为独立实现,与 AviUtl2 的脚本规范不同。
|
||||
* 与 AviUtl2 的脚本文件(*.anm2 等)为不同规范。
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
- 注意事项 -
|
||||
|
||||
○ 脚本执行引擎为 MoonSharp(兼容 Lua 5.2)。
|
||||
○ 脚本执行引擎为 LuaJIT(默认)与 MoonSharp(兼容 Lua 5.2)。
|
||||
○ 可用的标准库仅限以下内容:
|
||||
table, string, math, bit32
|
||||
* io、os、debug、ffi、require 等不可使用。
|
||||
@@ -26,14 +27,15 @@
|
||||
|
||||
- 执行引擎与自动加速 -
|
||||
|
||||
包含像素处理(getpixel/setpixel 双重循环)的脚本会被解析语法,
|
||||
并自动分配到更快的引擎。
|
||||
坐标、旋转、不透明度等普通脚本仍照旧由 MoonSharp 执行,行为不变。
|
||||
脚本会被解析语法,并自动分配到最合适的引擎。
|
||||
未指定指令的脚本由随附的高速运行时(LuaJIT)执行,
|
||||
自像素完结的像素映射会进一步转换为更快的 CPU 内核。
|
||||
两者的结果均与 MoonSharp 一致。
|
||||
|
||||
○ 自动分配(未指定指令时)
|
||||
· 自像素完结的像素映射(见下方条件)→ CPU 内核(高速、精确)
|
||||
· 上述以外的像素操作 → 原生(LuaJIT,仅在已部署时)
|
||||
· 无像素操作 → MoonSharp
|
||||
· 上述以外 → 原生(LuaJIT,仅在已部署时)
|
||||
· 未部署 native 或脚本为空 → MoonSharp
|
||||
|
||||
○ 引擎指定指令(脚本首行的注释)
|
||||
--!cpu :CPU 内核。运行时编译为表达式树,
|
||||
@@ -89,6 +91,32 @@
|
||||
自动显示在特效面板中(轨道条始终显示)。该通用用法不带范围・默认值声明,
|
||||
因此请在脚本内处理取值范围。AviUtl 的 --track / --check / --color 头声明显示仍可照常使用。
|
||||
|
||||
共有 4 个数值滑块,各值可通过 obj.slider0 ~ obj.slider3 引用。
|
||||
取值为整数,不处理小数。
|
||||
|
||||
Slider0 : 整数滑块 (范围: 1 ~ 10)
|
||||
Slider1 : 整数滑块 (范围: 0 ~ 100)
|
||||
Slider2 : 整数滑块 (范围: 0 ~ 1000)
|
||||
Slider3 : 整数滑块 (范围: -1000 ~ 1000)
|
||||
|
||||
还可使用字符串参数,各值通过以下名称引用。
|
||||
|
||||
obj.text : 文本输入框的字符串
|
||||
obj.font : 字体选择框的字体名
|
||||
obj.dir : 文件夹选择框的路径
|
||||
obj.file_video : 视频文件的路径
|
||||
obj.file_audio : 音频文件的路径
|
||||
obj.file_image : 图像文件的路径
|
||||
obj.file_project : 项目文件的路径
|
||||
obj.file_mp4 : MP4 文件的路径
|
||||
obj.file_exo : EXO 文件的路径
|
||||
obj.file_subtitle : 字幕文件的路径
|
||||
obj.file_shader : 着色器文件的路径
|
||||
|
||||
※滑块与字符串参数在脚本本体引用它们时会自动显示在特效面板中。
|
||||
※文件选择的路径可传给 obj.load 用于加载图像・视频。
|
||||
※这些参数在 MoonSharp 与原生两种引擎中均可引用。
|
||||
|
||||
|
||||
- 全局变量 -
|
||||
|
||||
@@ -209,6 +237,18 @@
|
||||
obj.track2 : 特效面板 Track2 的当前值 [只读]
|
||||
obj.track3 : 特效面板 Track3 的当前值 [只读]
|
||||
|
||||
○ 滑块
|
||||
obj.slider0 : 特效面板 Slider0 的当前值(整数) [只读]
|
||||
obj.slider1 : 特效面板 Slider1 的当前值(整数) [只读]
|
||||
obj.slider2 : 特效面板 Slider2 的当前值(整数) [只读]
|
||||
obj.slider3 : 特效面板 Slider3 的当前值(整数) [只读]
|
||||
|
||||
○ 字符串参数
|
||||
obj.text : 文本输入框的字符串 [只读]
|
||||
obj.font : 字体选择框的字体名 [只读]
|
||||
obj.dir : 文件夹选择框的路径 [只读]
|
||||
obj.file_video ~ obj.file_shader : 各文件选择框的路径 [只读]
|
||||
|
||||
○ 图层
|
||||
obj.layer : 对象所在的图层编号 [只读]
|
||||
* 与全局变量 layer 的值相同。
|
||||
@@ -439,10 +479,51 @@
|
||||
(getoption 返回设置值,未设置为 0)。
|
||||
当前会反映到绘制的项目:
|
||||
"antialias" : 0 为最近邻,其它为线性插值(obj.draw / obj.drawpoly)。
|
||||
"blend" : 合成模式编号(obj.draw / obj.drawpoly)。与 YMM4 属性
|
||||
面板中「合成模式」下拉列表相同的顺序(从 0 开始):
|
||||
0=普通,1=溶解,2=对比(暗),3=相乘,4=颜色加深,5=线性加深,
|
||||
6=对比(明),7=画面,8=颜色减淡,9=线性减淡 (相加),10=相加,
|
||||
11=覆盖,12=柔光,13=强光,14=亮光,15=明暗,16=点光,17=实色混合,
|
||||
18=反差,19=排除,20=相减,21=相除,22=色相,23=饱和度,24=颜色,
|
||||
25=亮度,26=颜色对比(明),27=背景,28=颜色对比(暗),29=清除,
|
||||
30=按背景裁剪,31=异或,32=颜色反转遮罩。超出范围或无效的值
|
||||
将按 0(普通)处理。
|
||||
"draw_state" : 用布尔值决定该效果是否输出工作图像。true 输出
|
||||
工作图像,false 则原样传递输入。可用于不使用 obj.draw 或
|
||||
setpixel 也输出工作图像,或反过来抑制输出。两个引擎都可用。
|
||||
"drawtarget" : 切换 obj.draw / obj.drawpoly 的绘制目标。
|
||||
"framebuffer"(默认)合成到帧缓冲。"tempbuffer" 则就地合成到
|
||||
工作用 tmp 缓冲。obj.setoption("drawtarget", "tempbuffer", w, h)
|
||||
中的 w, h 是初始化 tmp 缓冲的尺寸,省略则不初始化。画到 tmp 的
|
||||
结果可用 obj.copybuffer("obj", "tmp") 取回工作图像。合成到
|
||||
tempbuffer 使用普通(源覆盖),blend 应用于 framebuffer 的绘制。
|
||||
两个引擎都可用。在 MoonSharp 中,合成到 tempbuffer 在 GPU 上
|
||||
执行,GPU 不可用时会自动切换到 CPU 合成。由于舍入方式不同,
|
||||
合成结果在引擎之间可能存在极小差异。
|
||||
|
||||
○ obj.pixeloption(名称, 值)
|
||||
将像素操作的选项作为状态保存。
|
||||
|
||||
○ obj.setanchor(名称, 个数 [, 选项, ..])
|
||||
在预览上显示锚点,可用鼠标拖动调整坐标。调整后的坐标会随工程保存。
|
||||
名称 : 以字符串指定接收坐标的 Lua 变量名。变量排列为
|
||||
pos={x0,y0,x1,y1,…},指定 "xyz" 时为 {x0,y0,z0,x1,y1,z1,…}。
|
||||
坐标以对象中心为原点。
|
||||
个数 : 指定锚点数量。最多 32 个。
|
||||
选项 : 可用字符串列举。
|
||||
"line" : 用线连接锚点。
|
||||
"loop" : 用线连接锚点并闭合一圈。
|
||||
"star" : 将每个锚点与对象中心用线连接。
|
||||
"arm" : 从对象中心依次连接到各锚点。
|
||||
"xyz" : 以 3D 坐标处理锚点。默认是 2D。
|
||||
返回设置的锚点数量。两个引擎都可用。
|
||||
名称指定 "track" 的轨道条联动暂不支持,返回 0。
|
||||
示例:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 表 -
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
YukkuriMovieMaker4 的「Lua 腳本」視訊特效使用
|
||||
Lua 語言編寫腳本。
|
||||
腳本引擎採用 MoonSharp(相容 Lua 5.2)。
|
||||
腳本由隨附的高速執行環境(LuaJIT)執行,
|
||||
在其不可用的環境下改由 MoonSharp(相容 Lua 5.2)執行。
|
||||
|
||||
* 本特效為獨立實作,與 AviUtl2 的腳本規範不同。
|
||||
* 與 AviUtl2 的腳本檔案(*.anm2 等)為不同規範。
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
- 注意事項 -
|
||||
|
||||
○ 腳本執行引擎為 MoonSharp(相容 Lua 5.2)。
|
||||
○ 腳本執行引擎為 LuaJIT(預設)與 MoonSharp(相容 Lua 5.2)。
|
||||
○ 可用的標準函式庫僅限以下內容:
|
||||
table, string, math, bit32
|
||||
* io、os、debug、ffi、require 等不可使用。
|
||||
@@ -26,14 +27,15 @@
|
||||
|
||||
- 執行引擎與自動加速 -
|
||||
|
||||
包含像素處理(getpixel/setpixel 雙重迴圈)的腳本會被解析語法,
|
||||
並自動分配到更快的引擎。
|
||||
座標、旋轉、不透明度等一般腳本仍照舊由 MoonSharp 執行,行為不變。
|
||||
腳本會被解析語法,並自動分配到最合適的引擎。
|
||||
未指定指令的腳本由隨附的高速執行環境(LuaJIT)執行,
|
||||
自像素完結的像素映射會進一步轉換為更快的 CPU 核心。
|
||||
兩者的結果均與 MoonSharp 一致。
|
||||
|
||||
○ 自動分配(未指定指令時)
|
||||
· 自像素完結的像素映射(見下方條件)→ CPU 核心(高速、精確)
|
||||
· 上述以外的像素操作 → 原生(LuaJIT,僅在已部署時)
|
||||
· 無像素操作 → MoonSharp
|
||||
· 上述以外 → 原生(LuaJIT,僅在已部署時)
|
||||
· 未部署 native 或腳本為空 → MoonSharp
|
||||
|
||||
○ 引擎指定指令(腳本首行的註解)
|
||||
--!cpu :CPU 核心。執行時編譯為運算式樹,
|
||||
@@ -89,6 +91,32 @@
|
||||
自動顯示於特效面板中(軌道條始終顯示)。此通用用法不帶範圍・預設值宣告,
|
||||
因此請在腳本內處理取值範圍。AviUtl 的 --track / --check / --color 標頭宣告顯示仍可照常使用。
|
||||
|
||||
共有 4 個數值滑桿,各值可透過 obj.slider0 ~ obj.slider3 參照。
|
||||
取值為整數,不處理小數。
|
||||
|
||||
Slider0 : 整數滑桿 (範圍: 1 ~ 10)
|
||||
Slider1 : 整數滑桿 (範圍: 0 ~ 100)
|
||||
Slider2 : 整數滑桿 (範圍: 0 ~ 1000)
|
||||
Slider3 : 整數滑桿 (範圍: -1000 ~ 1000)
|
||||
|
||||
亦可使用字串參數,各值透過以下名稱參照。
|
||||
|
||||
obj.text : 文字輸入框的字串
|
||||
obj.font : 字型選擇框的字型名
|
||||
obj.dir : 資料夾選擇框的路徑
|
||||
obj.file_video : 影片檔案的路徑
|
||||
obj.file_audio : 音訊檔案的路徑
|
||||
obj.file_image : 圖片檔案的路徑
|
||||
obj.file_project : 專案檔案的路徑
|
||||
obj.file_mp4 : MP4 檔案的路徑
|
||||
obj.file_exo : EXO 檔案的路徑
|
||||
obj.file_subtitle : 字幕檔案的路徑
|
||||
obj.file_shader : 著色器檔案的路徑
|
||||
|
||||
※滑桿與字串參數在腳本本體參照它們時會自動顯示於特效面板中。
|
||||
※檔案選擇的路徑可傳給 obj.load 用於載入圖片・影片。
|
||||
※這些參數在 MoonSharp 與原生兩種引擎中皆可參照。
|
||||
|
||||
|
||||
- 全域變數 -
|
||||
|
||||
@@ -209,6 +237,18 @@
|
||||
obj.track2 : 特效面板 Track2 的當前值 [唯讀]
|
||||
obj.track3 : 特效面板 Track3 的當前值 [唯讀]
|
||||
|
||||
○ 滑桿
|
||||
obj.slider0 : 特效面板 Slider0 的當前值(整數) [唯讀]
|
||||
obj.slider1 : 特效面板 Slider1 的當前值(整數) [唯讀]
|
||||
obj.slider2 : 特效面板 Slider2 的當前值(整數) [唯讀]
|
||||
obj.slider3 : 特效面板 Slider3 的當前值(整數) [唯讀]
|
||||
|
||||
○ 字串參數
|
||||
obj.text : 文字輸入框的字串 [唯讀]
|
||||
obj.font : 字型選擇框的字型名 [唯讀]
|
||||
obj.dir : 資料夾選擇框的路徑 [唯讀]
|
||||
obj.file_video ~ obj.file_shader : 各檔案選擇框的路徑 [唯讀]
|
||||
|
||||
○ 圖層
|
||||
obj.layer : 物件所在的圖層編號 [唯讀]
|
||||
* 與全域變數 layer 的值相同。
|
||||
@@ -439,10 +479,52 @@
|
||||
(getoption 回傳設定值,未設定為 0)。
|
||||
目前會反映到繪製的項目:
|
||||
"antialias" : 0 為最近鄰,其它為線性內插(obj.draw / obj.drawpoly)。
|
||||
"blend" : 合成模式編號(obj.draw / obj.drawpoly)。與 YMM4 屬性
|
||||
面板中「合成模式」下拉選單相同的順序(從 0 開始):
|
||||
0=一般,1=Dissolve,2=比較(暗),3=相乘,4=Color burn,5=陰影,
|
||||
6=比較(亮),7=畫面,8=Color dodge,9=Linear dodge (Add),
|
||||
10=相加,11=覆蓋,12=Soft light,13=Hard light,14=Vivid light,
|
||||
15=明暗,16=Pin light,17=Hard mix,18=差異,19=Exclution,
|
||||
20=相減,21=Division,22=Hue,23=Saturation,24=色,25=亮度,
|
||||
26=Lighter color,27=Behind,28=Darker color,29=Clear,
|
||||
30=Clipping by background,31=XOR,32=Color inversion mask。
|
||||
超出範圍或無效的值將視為 0(一般)。
|
||||
"draw_state" : 以布林值決定此效果是否輸出工作影像。true 輸出
|
||||
工作影像,false 則原樣傳遞輸入。可用於不使用 obj.draw 或
|
||||
setpixel 也輸出工作影像,或反過來抑制輸出。兩個引擎都可用。
|
||||
"drawtarget" : 切換 obj.draw / obj.drawpoly 的繪製目標。
|
||||
"framebuffer"(預設)合成到影格緩衝。"tempbuffer" 則就地合成到
|
||||
工作用 tmp 緩衝。obj.setoption("drawtarget", "tempbuffer", w, h)
|
||||
中的 w, h 是初始化 tmp 緩衝的尺寸,省略則不初始化。畫到 tmp 的
|
||||
結果可用 obj.copybuffer("obj", "tmp") 取回工作影像。合成到
|
||||
tempbuffer 使用一般(來源覆蓋),blend 套用於 framebuffer 的繪製。
|
||||
兩個引擎都可用。在 MoonSharp 中,合成到 tempbuffer 在 GPU 上
|
||||
執行,GPU 無法使用時會自動切換到 CPU 合成。由於捨入方式不同,
|
||||
合成結果在引擎之間可能存在極小差異。
|
||||
|
||||
○ obj.pixeloption(名稱, 值)
|
||||
將像素操作的選項作為狀態保存。
|
||||
|
||||
○ obj.setanchor(名稱, 個數 [, 選項, ..])
|
||||
在預覽上顯示錨點,可用滑鼠拖曳調整座標。調整後的座標會隨專案保存。
|
||||
名稱 : 以字串指定接收座標的 Lua 變數名。變數排列為
|
||||
pos={x0,y0,x1,y1,…},指定 "xyz" 時為 {x0,y0,z0,x1,y1,z1,…}。
|
||||
座標以物件中心為原點。
|
||||
個數 : 指定錨點數量。最多 32 個。
|
||||
選項 : 可用字串列舉。
|
||||
"line" : 用線連接錨點。
|
||||
"loop" : 用線連接錨點並閉合一圈。
|
||||
"star" : 將每個錨點與物件中心用線連接。
|
||||
"arm" : 從物件中心依序連接到各錨點。
|
||||
"xyz" : 以 3D 座標處理錨點。預設是 2D。
|
||||
回傳設置的錨點數量。兩個引擎都可用。
|
||||
名稱指定 "track" 的軌道條連動暫不支援,回傳 0。
|
||||
範例:
|
||||
num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end
|
||||
|
||||
|
||||
- ymm4 表 -
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
---
|
||||
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブジェクトの座標・拡縮・回転・不透明度・ピクセルを直接制御できる映像エフェクトプラグイン**です。
|
||||
スクリプトエンジンには MoonSharp(Lua 5.2 互換)が採用されており、`obj.x` や `obj.alpha` といった変数をスクリプトから書き換えることで、AviUtl のスクリプト制御に近い感覚でアニメーションを組み立てられます。
|
||||
スクリプトは同梱の高速ランタイム(LuaJIT)で実行され、`obj.x` や `obj.alpha` といった変数をスクリプトから書き換えることで、AviUtl のスクリプト制御に近い感覚でアニメーションを組み立てられます。高速ランタイムを利用できない環境では MoonSharp(Lua 5.2 互換)で実行されます。
|
||||
|
||||
座標・拡縮・回転・不透明度の制御に加えて、`obj.getpixel` / `obj.setpixel` / `obj.getpixeldata` によるピクセル単位の画像加工、アニメーション制作向けの数学ユーティリティ群(`anim` テーブル)、4 系統のトラックバー(Track0〜Track3)によるスクリプトへのパラメータ受け渡しに対応しています。
|
||||
|
||||
@@ -46,7 +46,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
|
||||
本プラグインは YMM4 の「映像エフェクト」として動作し、エフェクトの種類一覧では「Luaスクリプト」として表示されます。
|
||||
|
||||
内部的には MoonSharp(Lua 5.2 互換のスクリプトエンジン)を組み込んでおり、ユーザーが記述した Lua スクリプトをフレームごとに実行します。スクリプト内で `obj.x` や `obj.alpha` といったグローバル変数を書き換えると、その値がオブジェクトの座標・拡縮・回転・不透明度として描画に反映されます。
|
||||
内部的には高速ランタイム(LuaJIT)と MoonSharp(Lua 5.2 互換のスクリプトエンジン)を組み込んでおり、ユーザーが記述した Lua スクリプトをフレームごとに実行します。スクリプト内で `obj.x` や `obj.alpha` といったグローバル変数を書き換えると、その値がオブジェクトの座標・拡縮・回転・不透明度として描画に反映されます。
|
||||
|
||||
このエフェクトは独自のスクリプト実行系を基盤としつつ、AviUtl のアニメーション効果スクリプト(`.anm` 系)の一部に対する互換層を備えています(詳細は[AviUtl スクリプトの部分互換](#9-aviutl-スクリプトの部分互換)を参照)。AviUtl 向けの EXO 出力(`.exo`)には対応していません。
|
||||
|
||||
@@ -60,7 +60,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
| YukkuriMovieMaker4 | 最新版を推奨 |
|
||||
| ランタイム | .NET 10.0 |
|
||||
|
||||
※ スクリプトエンジン(MoonSharp)はプラグインに同梱されており、別途インストールする必要はありません。
|
||||
※ スクリプトエンジン(LuaJIT・MoonSharp)はプラグインに同梱されており、別途インストールする必要はありません。
|
||||
|
||||
---
|
||||
|
||||
@@ -76,7 +76,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
|
||||
### 1. スクリプトエンジン
|
||||
|
||||
スクリプトの実行エンジンには MoonSharp(Lua 5.2 互換)を使用しています。加えて、自ピクセル完結のピクセル写像(`obj.getpixel` で読み取り `obj.setpixel` で書き戻す二重ループ)は構文解析で検出して **CPU カーネル(式ツリー)** または **GPU カーネル(Direct2D ピクセルシェーダ)** へ実行時コンパイルして高速化し、それ以外のピクセル操作を含むスクリプトは同梱の高速ランタイム(**LuaJIT**)で自動実行されます(詳細は[実行エンジンの自動振り分け](#実行エンジンの自動振り分け)を参照)。いずれのエンジンでも利用可能な標準ライブラリは以下に限定されています。
|
||||
スクリプトの実行エンジンには、同梱の高速ランタイム(**LuaJIT**)と MoonSharp(Lua 5.2 互換)を使用しています。ディレクティブを書いていないスクリプトは LuaJIT で実行され、自ピクセル完結のピクセル写像(`obj.getpixel` で読み取り `obj.setpixel` で書き戻す二重ループ)は構文解析で検出して **CPU カーネル(式ツリー)** へ実行時コンパイルしてさらに高速化されます。`native` フォルダが配備されていない環境と空のスクリプトは MoonSharp で実行されます(詳細は[実行エンジンの自動振り分け](#実行エンジンの自動振り分け)を参照)。いずれのエンジンでも利用可能な標準ライブラリは以下に限定されています。
|
||||
|
||||
- `table`、`string`、`math`、`bit32`
|
||||
- 基本関数: `type`、`tostring`、`tonumber`、`select`、`error`、`assert`、`print`、`ipairs`、`pairs`、`next`、`unpack`、`setmetatable`、`getmetatable`、`rawget`、`rawset`、`rawequal`、`rawlen`、`pcall`、`xpcall`
|
||||
@@ -98,6 +98,9 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
| `obj.rxr`, `obj.ryr`, `obj.rzr` | 変更可 | 回転角(ラジアン)。同名の度数版より優先して反映される |
|
||||
| `obj.w`, `obj.h`, `obj.hw`, `obj.hh`, `obj.cx`, `obj.cy`, `obj.cz`, `obj.diagonal` | 読み取り専用 | 入力画像のサイズ・中心座標・対角線長 |
|
||||
| `obj.track0`〜`obj.track3` | 読み取り専用 | トラックバーの現在値(後述) |
|
||||
| `obj.slider0`〜`obj.slider3` | 読み取り専用 | 整数スライダーの現在値(後述) |
|
||||
| `obj.text`, `obj.font`, `obj.dir` | 読み取り専用 | テキスト入力欄の文字列、フォント名、フォルダパス(後述) |
|
||||
| `obj.file_video`〜`obj.file_shader` | 読み取り専用 | 各ファイル選択欄のパス(後述) |
|
||||
| `obj.time`, `obj.frame`, `obj.totalframe`, `obj.totaltime`, `obj.t`, `obj.framerate`, `obj.layer`, `obj.index`, `obj.num` | 読み取り専用 | 時間・フレーム・レイヤー等の情報 |
|
||||
|
||||
### 3. ピクセル操作機能
|
||||
@@ -110,7 +113,7 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
- **`obj.putpixeldata()`**: 互換性のために定義された空実装関数です。`setpixel` / `PixelDataProxy:set` による変更は自動的に反映されるため、呼び出す必要はありません。
|
||||
`getpixel` / `setpixel` / `getpixeldata` のいずれかを最初に呼び出した時点で、GPU 上の画像データを CPU 側へ転送する処理が一度だけ発生します。ピクセル操作を行わないスクリプトではこの転送は発生しません。
|
||||
|
||||
これらのピクセル操作を含むスクリプトは自動的に高速化されます。自ピクセル完結のピクセル写像は CPU カーネル(式ツリー)または GPU カーネル(Direct2D ピクセルシェーダ)へ、それ以外は高速ランタイム(LuaJIT)へ自動で振り分けられ、いずれも従来エンジンに比べて大幅(内部計測で数十倍)に高速化されます。CPU カーネルと LuaJIT の出力結果は従来エンジンと一致します(GPU カーネルのみ float32 精度のためごく僅かに異なり得ます)。詳細・制約は[実行エンジンの自動振り分け](#実行エンジンの自動振り分け)を参照してください。
|
||||
これらのピクセル操作を含むスクリプトは自動的に高速化されます。自ピクセル完結のピクセル写像は CPU カーネル(式ツリー)へ、それ以外は高速ランタイム(LuaJIT)へ自動で振り分けられ、いずれも MoonSharp に比べて大幅(内部計測で数十倍)に高速化されます。CPU カーネルと LuaJIT の出力結果は MoonSharp と一致します(明示指定のみで使われる GPU カーネルは float32 精度のためごく僅かに異なり得ます)。詳細・制約は[実行エンジンの自動振り分け](#実行エンジンの自動振り分け)を参照してください。
|
||||
|
||||
### 4. scene テーブルと ymm4 テーブル
|
||||
|
||||
@@ -177,6 +180,10 @@ YukkuriMovieMaker4(YMM4)上で動作する、**Luaスクリプトでオブ
|
||||
エフェクトパネルには 4 本のトラックバー(アニメーション対応)があり、各値はスクリプト内で `obj.track0`〜`obj.track3` として参照できます。スライダー表示範囲はいずれも -100〜100、デフォルト値は 0、表示形式は小数点以下2桁です。トラックバーは常に表示されます。
|
||||
|
||||
チェックボックス(`obj.check0`〜`obj.check3`)とカラーピッカー(`color`)は、スクリプト本体でそれらを参照すると自動的にエフェクトパネルへ表示されます(参照を消すと非表示に戻ります)。これにより、`--` ヘッダを書かなくても必要な入力欄だけを出せます。なお、この一般利用ではスライダーのようなラベル・範囲・既定値の宣言は伴わないため、値の範囲はスクリプト内で扱ってください。AviUtl 互換の `--track`/`--check`/`--color` ヘッダによる宣言表示は従来どおり利用できます([AviUtl スクリプトの部分互換](#9-aviutl-スクリプトの部分互換)を参照)。
|
||||
|
||||
数値スライダーが 4 本あり、各値はスクリプト内で `obj.slider0`〜`obj.slider3` として参照できます。値は整数で、表示範囲は `obj.slider0` が 1〜10、`obj.slider1` が 0〜100、`obj.slider2` が 0〜1000、`obj.slider3` が -1000〜1000 です。状態の切り替えなど、補間を伴わない整数値の受け渡しに使えます。
|
||||
|
||||
文字列パラメータも利用できます。テキスト入力欄は `obj.text`、フォント選択欄は `obj.font`、フォルダ選択欄は `obj.dir` で参照します。ファイル選択欄は種類ごとに `obj.file_video` / `obj.file_audio` / `obj.file_image` / `obj.file_project` / `obj.file_mp4` / `obj.file_exo` / `obj.file_subtitle` / `obj.file_shader` で参照し、選択したファイルのパスを取得できます。取得したパスは `obj.load` へ渡して画像・動画の読み込みに使えます。スライダーと文字列パラメータは、スクリプト本体でそれらを参照すると自動的にエフェクトパネルへ表示されます。いずれのパラメータも MoonSharp とネイティブの両エンジンから参照できます。
|
||||
|
||||
### 7. スクリプトエディタの支援機能
|
||||
|
||||
@@ -206,12 +213,13 @@ AviUtl のアニメーション効果スクリプト(`.anm` 系)のうち、
|
||||
- **`@` による複数セクション**: 1 つのスクリプトに `@名前` で複数の効果が定義されている場合、先頭のセクションのみを実行します。
|
||||
- **`obj.rand(st, ed [, seed [, frame]])`**: 指定範囲(`st`〜`ed`)の整数を返す決定論的な乱数です。`seed` と `frame` が同じであれば常に同じ値を返し、`frame` を省略すると現在のフレームを用います。従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)で同じ値を返します。
|
||||
- **`obj.load("figure", 名前, 色, サイズ [, ライン [, アスペクト]])`**: 円・四角形・三角形・五角形・六角形・星形を生成し、オブジェクトのバッファを置き換えて描画します(出力は図形サイズに合わせて生成され、中心に配置されます)。`ライン` を省略するか `0` で塗りつぶし、サイズ以上の値でも塗りつぶしになります。`アスペクト`(-1.0〜1.0)で幅・高さを歪曲できます。
|
||||
- **描画・メディア・バッファ・オプション API**: `obj.draw` / `obj.drawpoly` による描画合成、`obj.load` の `"text"` / `"image"` / `"movie"`、`obj.setfont`、`obj.copybuffer`、`obj.effect`、`obj.getvalue`、`obj.setoption` / `obj.getoption` / `obj.pixeloption` に対応しています。これらは従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)の双方で動作します。
|
||||
- **描画・メディア・バッファ・オプション API**: `obj.draw` / `obj.drawpoly` による描画合成、`obj.load` の `"text"` / `"image"` / `"movie"`、`obj.setfont`、`obj.copybuffer`、`obj.effect`、`obj.getvalue`、`obj.setoption` / `obj.getoption` / `obj.pixeloption` に対応しています。これらは従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)の双方で動作します。`obj.setoption` では `antialias` に加えて、`obj.draw` / `obj.drawpoly` の合成モードを YMM4 の並びで指定する `blend`、描画先を `"framebuffer"` / `"tempbuffer"` で切り替える `drawtarget`、作業画像の出力可否を切り替える `draw_state` に対応します。MoonSharp では `tempbuffer` への合成を GPU で実行し、GPU を利用できない環境では CPU の合成へ自動的に切り替わります。丸めの違いにより、合成の結果はエンジン間でごく僅かに異なることがあります。
|
||||
- **`obj.setanchor(name, count [, option, ...])`**: プレビュー上にドラッグ可能なアンカーポイントを表示し、その座標を `name` の Lua 変数(`pos={x0,y0,x1,y1,…}`、`"xyz"` 指定時は `{x0,y0,z0,…}`)へ格納します。座標はオブジェクトの中心が原点で、ドラッグで調整した値はプロジェクトへ保存されます。最大 32 個で、`"line"` / `"loop"` / `"star"` / `"arm"` の線結びと `"xyz"` の 3D 指定に対応します。設置数を返し、従来エンジン(MoonSharp)と高速ランタイム(LuaJIT)の双方で動作します。`name` に `"track"` を指定するトラックバー連携は未対応です。
|
||||
- **`obj.effect` の AviUtl/AviUtl2 互換マップ**: `obj.effect("エフェクト名", "パラメータ名", 値, …)` はまず互換マップを参照し、AviUtl/AviUtl2 の名前として宣言したエフェクトを、対応する YMM4 の映像エフェクトとプロパティへ変換して適用します。値の倍率とオフセットの変換まで宣言できます。互換マップに宣言が無い名前は、従来どおり YMM4 のエフェクト名・キーワードでそのまま解決するため、既存の呼び出しはそのまま動きます。この互換マップは YMM4 自身が AviUtl の `.exo` へ書き出す変換を逆向きにたどって構築しているため、往復しても結果が一致します。対象のエンジンは指定子 `--!aviutl` または `--!aviutl2` で切り替え、指定子を書かないときは `--!aviutl` として扱います。互換マップが対応するエフェクト名の一覧はドキュメントの「obj の関数」を参照してください。
|
||||
|
||||
次のような機能は、この互換層では対象外です(呼び出しを含むスクリプトは意図どおりには動作しません)。
|
||||
|
||||
- `obj.setanchor`、`scene.set` / `scene.get` などの未実装関数
|
||||
- `scene.set` / `scene.get` などの未実装関数
|
||||
- `require` によるモジュール読み込み、`io` / `dofile` などの任意ファイルアクセス(`obj.load("image"/"movie")` のみ、先頭ヘッダー検証付きで対応)
|
||||
|
||||
---
|
||||
@@ -223,8 +231,8 @@ AviUtl のアニメーション効果スクリプト(`.anm` 系)のうち、
|
||||
スクリプトは内容に応じて 4 つのエンジンへ自動的に振り分けられます。
|
||||
|
||||
- **自ピクセル完結のピクセル写像**(`for y … for x … obj.getpixel … obj.setpixel … end end` の形)→ **CPU カーネル(式ツリー)** へ実行時コンパイルして実行。
|
||||
- **上記以外のピクセル操作を含むスクリプト**(`obj.getpixeldata` や近傍参照・別座標書き込みなど)→ 同梱の高速ランタイム **LuaJIT** で実行(ネイティブ実行)。
|
||||
- **変形のみのスクリプト** → 従来の **MoonSharp** で実行。
|
||||
- **上記以外のスクリプト** → 同梱の高速ランタイム **LuaJIT** で実行(ネイティブ実行)。
|
||||
- **`native` フォルダが配備されていない環境と空のスクリプト** → **MoonSharp** で実行。
|
||||
|
||||
スクリプトの先頭行に次のディレクティブを書くと、エンジンを明示指定できます。
|
||||
|
||||
@@ -237,7 +245,7 @@ AviUtl のアニメーション効果スクリプト(`.anm` 系)のうち、
|
||||
|
||||
CPU / GPU カーネルが成立するのは、四則演算・`math.*`・比較・しきい値の「条件 and 値1 or 値2」・`local` 変数のみを使い、処理中の自ピクセル(`obj.getpixel(x, y)`)と `obj` / `scene` / `time` 等の値だけを参照する純粋な写像(色変換・グレースケール・ガンマ・しきい値・チャンネル混合など)の場合です。近傍参照(ぼかし等)・別座標への書き込み・`getpixeldata`・`getobject`・テーブル/文字列操作・`if` 文などを含む場合はカーネル化されず、自動的に LuaJIT または MoonSharp で実行されます。コンパイル済みのカーネルはスクリプト本文をキーにキャッシュされ、初回フレームのみコンパイルコストを払います。
|
||||
|
||||
ネイティブ実行は**専用の別プロセス**で行われ、ピクセルバッファは共有メモリ経由で受け渡されます。スクリプトが無限ループに陥った場合でも **5 秒のタイムアウトでプロセスを強制終了**するため本体は固まらず、終了後は自動的に復帰します。出力結果は従来エンジンと一致します。
|
||||
ネイティブ実行は**専用の別プロセス**で行われ、ピクセルバッファは共有メモリ経由で受け渡されます。ピクセルの転送はスクリプトがピクセルへ初めてアクセスした時点でのみ行われるため、変形や描画だけのスクリプトでは転送が発生しません。ワーカープロセスは入力画像のサイズが変わっても再起動せず、フレームをまたいで再利用されます。スクリプトが無限ループに陥った場合でも **5 秒のタイムアウトでプロセスを強制終了**するため本体は固まらず、終了後は自動的に復帰します。出力結果は MoonSharp と一致します。
|
||||
|
||||
`obj.getobject` はネイティブ実行でも利用できます。呼び出し時に本体プロセスへ同期的に問い合わせてシーンオブジェクトを解決するため、従来エンジンと同じ結果を返します。同じタグ・同じフレームへの連続した問い合わせはフレーム内でキャッシュされ、2 回目以降は往復を行いません。
|
||||
|
||||
@@ -264,7 +272,7 @@ CPU / GPU カーネルが成立するのは、四則演算・`math.*`・比較
|
||||
|
||||
### グローバル変数のリセットと整合性チェック
|
||||
|
||||
内部の Lua 実行環境(Script / Table インスタンス)は性能のためフレームをまたいで再利用されますが、スクリプトが定義したユーザー定義のグローバル変数や、`obj` / `scene` / `anim` / `ymm4` テーブルへスクリプトが追加したキーは、各フレームの実行開始時に初期状態のスナップショットと比較して取り除かれます。これにより、あるフレームでスクリプトが作成した状態が次のフレームへ意図せず持ち越されることを防いでいます。
|
||||
内部の Lua 実行環境は性能のためフレームをまたいで再利用されますが、スクリプトが定義したユーザー定義のグローバル変数や、`obj` / `scene` / `anim` / `ymm4` テーブルへスクリプトが追加したキーは、各フレームの実行開始時に初期状態のスナップショットと比較して取り除かれます。これにより、あるフレームでスクリプトが作成した状態が次のフレームへ意図せず持ち越されることを防いでいます。このリセットは LuaJIT と MoonSharp のどちらのエンジンでも同じように行われます。
|
||||
|
||||
また、実行のたびに組み込みの `math` グローバルがテーブル型のまま残っているかを確認し、スクリプトの誤操作などで破壊されていた場合は Lua 実行環境ごと再構築します。
|
||||
|
||||
@@ -280,6 +288,14 @@ CPU / GPU カーネルが成立するのは、四則演算・`math.*`・比較
|
||||
| **Track1** | 数値 | 0.00 | -100 〜 100 | ✔ | `obj.track1` として参照できる汎用パラメータ |
|
||||
| **Track2** | 数値 | 0.00 | -100 〜 100 | ✔ | `obj.track2` として参照できる汎用パラメータ |
|
||||
| **Track3** | 数値 | 0.00 | -100 〜 100 | ✔ | `obj.track3` として参照できる汎用パラメータ |
|
||||
| **Slider0** | 整数 | 1 | 1 〜 10 | - | `obj.slider0` として参照できる整数パラメータ |
|
||||
| **Slider1** | 整数 | 0 | 0 〜 100 | - | `obj.slider1` として参照できる整数パラメータ |
|
||||
| **Slider2** | 整数 | 0 | 0 〜 1000 | - | `obj.slider2` として参照できる整数パラメータ |
|
||||
| **Slider3** | 整数 | 0 | -1000 〜 1000 | - | `obj.slider3` として参照できる整数パラメータ |
|
||||
| **Text** | 文字列 | 空 | - | - | `obj.text` として参照できるテキスト入力 |
|
||||
| **Font** | 文字列 | メイリオ | - | - | `obj.font` として参照できるフォント名 |
|
||||
| **Directory** | 文字列 | 空 | - | - | `obj.dir` として参照できるフォルダパス |
|
||||
| **FileVideo**〜**FileShader** | 文字列 | 空 | - | - | `obj.file_video`〜`obj.file_shader` として参照できるファイルパス |
|
||||
|
||||
---
|
||||
|
||||
@@ -358,7 +374,7 @@ obj.alpha = anim.ease_out(t) * 255
|
||||
- **AviUtl 互換は部分的**: AviUtl のアニメーション効果スクリプトのうち、変形・不透明度・乱数の範囲のみ実行できます([AviUtl スクリプトの部分互換](#9-aviutl-スクリプトの部分互換)を参照)。描画・フィルタ・ファイルアクセス系の関数、および AviUtl 向けの EXO 出力(`.exo`)には対応していません。
|
||||
- **実行タイムアウト**: スクリプトの実行は 5000ms(5秒)でタイムアウトし、超過した場合は強制終了されエラーとして扱われます。無限ループが発生しないよう注意してください。
|
||||
- **利用可能な標準ライブラリの制限**: `table`、`string`、`math`、`bit32` および基本関数のみ利用できます。`io`、`os`、`debug`、`ffi`、`require` は利用できません。
|
||||
- **ピクセル操作の負荷**: `obj.getpixel` / `obj.setpixel` / `obj.getpixeldata` は実際の入力画像にアクセスするため、各フレームで最初に呼び出した際に GPU→CPU へのデータ転送が発生します(GPU カーネルはこの転送を行いません)。不要な場合は呼び出しを省略することで処理を高速化できます。これらを含むスクリプトは内容に応じて CPU カーネル・GPU カーネル・高速ランタイム(LuaJIT)のいずれかで自動実行され大幅に高速化されます。詳細は[実行エンジンの自動振り分け](#実行エンジンの自動振り分け)を参照。
|
||||
- **ピクセル操作の負荷**: `obj.getpixel` / `obj.setpixel` / `obj.getpixeldata` は実際の入力画像にアクセスするため、各フレームで最初に呼び出した際に GPU→CPU へのデータ転送が発生します(GPU カーネルはこの転送を行いません)。不要な場合は呼び出しを省略することで処理を高速化できます。これらを含むスクリプトは内容に応じて CPU カーネルまたは高速ランタイム(LuaJIT)で自動実行され大幅に高速化されます。詳細は[実行エンジンの自動振り分け](#実行エンジンの自動振り分け)を参照。
|
||||
- **`math.random` はフレームごとの決定論的な乱数**: 毎フレーム `frame` の値でシードし直されるため、同一フレームでは常に同じ値になります。フレームをまたいで変化する乱数的な値が必要な場合は `anim.rand` の利用を検討してください。
|
||||
- **`obj.oz` は出力に反映されません**: スクリプト実行後にコンテキストへ読み戻されますが、現在の実装では中心点オフセットの出力計算に使用されていません。
|
||||
- **エクスポートは先頭の1件のみ**: 複数アイテムを選択した状態でも、エクスポートされるスクリプトは先頭のアイテムのもののみです(インポート・クリアは選択中のすべてのアイテムに適用されます)。
|
||||
@@ -383,8 +399,8 @@ obj.alpha = anim.ease_out(t) * 255
|
||||
|
||||
| ソフトウェア | 用途 | ライセンス |
|
||||
|---|---|---|
|
||||
| [MoonSharp](https://github.com/moonsharp-devs/moonsharp) | 標準のLua実行エンジン(Lua 5.2 互換) | 3-Clause BSD License |
|
||||
| [LuaJIT](https://github.com/LuaJIT/LuaJIT) | ピクセル操作向け高速ランタイム(`native/luajit.exe`・`lua51.dll`) | MIT License |
|
||||
| [MoonSharp](https://github.com/moonsharp-devs/moonsharp) | フォールバック用のLua実行エンジン(Lua 5.2 互換) | 3-Clause BSD License |
|
||||
| [LuaJIT](https://github.com/LuaJIT/LuaJIT) | 標準の高速ランタイム(`native/luajit.exe`・`lua51.dll`) | MIT License |
|
||||
|
||||
### MoonSharp(3-Clause BSD License)
|
||||
|
||||
|
||||
+17
-8
@@ -14,21 +14,28 @@
|
||||
<h1>エンジンと高速化</h1>
|
||||
|
||||
<p>
|
||||
このプラグインには複数の実行エンジンがあります。標準は MoonSharp ですが、重いピクセル処理のために
|
||||
LuaJIT ネイティブレーンや、CPU / GPU カーネルへ変換するレーンを選べます。
|
||||
座標などを動かすだけのスクリプトでは MoonSharp で十分速く、エンジンを意識する必要はありません。
|
||||
このプラグインには複数の実行エンジンがあります。標準は同梱の LuaJIT ネイティブレーンで、
|
||||
決まった形の重いピクセル処理はさらに CPU カーネルへ変換されます。Lua 5.2 互換の MoonSharp は
|
||||
フォールバック用の従来エンジンです。指定子を書かなくても、内容に応じて自動で最適なレーンが選ばれます。
|
||||
</p>
|
||||
|
||||
<h2>エンジンの種類</h2>
|
||||
|
||||
<table>
|
||||
<tr><th>エンジン</th><th>指定子</th><th>特徴</th></tr>
|
||||
<tr><td>MoonSharp</td><td><code>--!moonsharp</code>(既定)</td><td>Lua 5.2 互換。全機能が使える標準エンジン</td></tr>
|
||||
<tr><td>ネイティブ(LuaJIT)</td><td><code>--!native</code></td><td>別プロセスの LuaJIT で実行。ピクセル処理が大幅に高速</td></tr>
|
||||
<tr><td>ネイティブ(LuaJIT)</td><td><code>--!native</code>(既定)</td><td>別プロセスの LuaJIT で実行。ピクセル処理が大幅に高速</td></tr>
|
||||
<tr><td>MoonSharp</td><td><code>--!moonsharp</code></td><td>Lua 5.2 互換。フォールバック用の従来エンジン</td></tr>
|
||||
<tr><td>CPU カーネル</td><td><code>--!cpu</code></td><td>決まった形のピクセルループを並列実行に変換。MoonSharp と一致する結果</td></tr>
|
||||
<tr><td>GPU カーネル</td><td><code>--!gpu</code></td><td>ピクセルループを GPU シェーダーに変換。最速だが float32 精度(明示指定のみ)</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
スライダー <code>obj.slider0</code> ~ <code>obj.slider3</code> と文字列パラメータ
|
||||
<code>obj.text</code> / <code>obj.font</code> / <code>obj.dir</code> / <code>obj.file_*</code> は、
|
||||
MoonSharp とネイティブのどちらのエンジンでも同じ名前で参照できます。
|
||||
CPU カーネルと GPU カーネルは数値計算に特化するため、文字列を扱いません。
|
||||
</div>
|
||||
|
||||
<h2>指定子の書き方</h2>
|
||||
|
||||
<p>
|
||||
@@ -50,9 +57,8 @@ end</code></pre>
|
||||
|
||||
<ul>
|
||||
<li>後述のカーネル条件に当てはまるピクセルループは、CPU カーネルで実行します。結果は MoonSharp と一致します。</li>
|
||||
<li><code>obj.setoption</code> を使う描画系のスクリプトは、MoonSharp で実行します。</li>
|
||||
<li>カーネル条件には当てはまらないものの <code>getpixel</code> や <code>setpixel</code> を使うスクリプトは、ネイティブが使えればネイティブで実行します。</li>
|
||||
<li>それ以外は MoonSharp で実行します。</li>
|
||||
<li>それ以外のスクリプトは、同梱の LuaJIT ネイティブで実行します。結果は MoonSharp と一致します。</li>
|
||||
<li><code>native</code> フォルダが配備されていない環境と空のスクリプトは、MoonSharp で実行します。</li>
|
||||
</ul>
|
||||
|
||||
<div class="note">
|
||||
@@ -106,6 +112,9 @@ end</code></pre>
|
||||
<li><code>--!gpu</code> を指定しても、GPU カーネルを初期化できない場合は CPU カーネル、さらに MoonSharp の順で
|
||||
フォールバックします。</li>
|
||||
<li><code>--!cpu</code> を指定してもカーネル条件に合わないスクリプトは、ほかのエンジンで実行されます。</li>
|
||||
<li>MoonSharp では <code>tempbuffer</code> への描画合成を GPU で実行し、GPU を利用できない環境では
|
||||
CPU の合成へ自動的に切り替わります。丸めの違いにより、合成の結果はエンジン間で
|
||||
ごく僅かに異なることがあります。</li>
|
||||
</ul>
|
||||
|
||||
<div class="warn">
|
||||
|
||||
+3
-3
@@ -20,9 +20,9 @@ YukkuriMovieMaker4 の映像エフェクト「Lua スクリプト」の公式ド
|
||||
</p>
|
||||
|
||||
<p>
|
||||
標準のスクリプトエンジンは Lua 5.2 互換の MoonSharp です。
|
||||
重いピクセル処理のためには、LuaJIT で実行する <code>--!native</code> レーンと、
|
||||
CPU・GPU カーネルへ変換する <code>--!cpu</code>・<code>--!gpu</code> レーンも用意しています。
|
||||
標準のスクリプトエンジンは LuaJIT で実行するネイティブレーンで、
|
||||
決まった形のピクセル処理は <code>--!cpu</code> の CPU カーネルへ変換されます。
|
||||
Lua 5.2 互換の MoonSharp はフォールバックとして使われ、明示指定の <code>--!gpu</code> レーンも用意しています。
|
||||
詳しくは<a href="engines.html">エンジンと高速化</a>を参照してください。
|
||||
</p>
|
||||
|
||||
|
||||
+101
-1
@@ -167,12 +167,112 @@ obj.load("text", "サンプル")</code></pre>
|
||||
<tr><td><code>obj.draw([ox, oy, oz, zoom, alpha, aspect])</code></td><td>現在のバッファをオフセット・拡大率・不透明度を指定して描画する</td></tr>
|
||||
<tr><td><code>obj.drawpoly(x0,y0,z0, x1,y1,z1, x2,y2,z2, x3,y3,z3 [, u0,v0, ... ,u3,v3] [, alpha])</code></td><td>4 頂点のテクスチャ付きポリゴンを描画する。UV を省略すると画像全体を使う</td></tr>
|
||||
<tr><td><code>obj.copybuffer(dst, src)</code></td><td>バッファ間でコピーする。ID は <code>obj</code>(作業画像)・<code>tmp</code>・<code>cache:名前</code>。書き込み先が <code>obj</code> のときのみ作業画像を置き換える</td></tr>
|
||||
<tr><td><code>obj.setoption(name [, value])</code></td><td>オプションを設定する。<code>antialias</code> は <code>obj.draw</code> で参照される</td></tr>
|
||||
<tr><td><code>obj.setoption(name [, value])</code></td><td>オプションを設定する。<code>antialias</code> は <code>obj.draw</code> で参照される。<code>blend</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の合成モードを番号で指定する。番号は下記の「合成モード」を参照。<code>draw_state</code> は真偽値で、<code>true</code> なら作業画像を出力し、<code>false</code> なら入力をそのまま通す。<code>drawtarget</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の描画先を <code>"framebuffer"</code> と <code>"tempbuffer"</code> で切り替える。詳細は下記の「描画先」を参照</td></tr>
|
||||
<tr><td><code>obj.getoption(name)</code></td><td>設定したオプションを取得する</td></tr>
|
||||
<tr><td><code>obj.getvalue(name)</code></td><td><code>obj</code> の数値メンバーを名前で取得する</td></tr>
|
||||
<tr><td><code>obj.pixeloption(name [, value])</code></td><td>ピクセル処理向けのオプションを設定する</td></tr>
|
||||
<tr><td><code>obj.setanchor(name, count [, option, ...])</code></td><td>プレビュー上にドラッグ可能なアンカーポイントを表示し、その座標を <code>name</code> の Lua 変数へ格納する。設置数を返す。詳細は下記の「アンカーポイント」を参照</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>合成モード</h3>
|
||||
|
||||
<p>
|
||||
<code>obj.setoption("blend", 番号)</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の描画に合成モードを設定します。
|
||||
番号は YMM4 のプロパティパネルにある「合成モード」のドロップダウンと並び順が同じで、0 から始まります。
|
||||
範囲外の値や数値以外を指定したときは通常モードになります。
|
||||
</p>
|
||||
|
||||
<pre><code>obj.setoption("blend", 3)
|
||||
obj.draw()</code></pre>
|
||||
|
||||
<table>
|
||||
<tr><th>番号</th><th>合成モード</th></tr>
|
||||
<tr><td><code>0</code></td><td>通常</td></tr>
|
||||
<tr><td><code>1</code></td><td>ディザ合成</td></tr>
|
||||
<tr><td><code>2</code></td><td>比較(暗)</td></tr>
|
||||
<tr><td><code>3</code></td><td>乗算</td></tr>
|
||||
<tr><td><code>4</code></td><td>焼き込みカラー</td></tr>
|
||||
<tr><td><code>5</code></td><td>焼き込み(リニア)</td></tr>
|
||||
<tr><td><code>6</code></td><td>比較(明)</td></tr>
|
||||
<tr><td><code>7</code></td><td>スクリーン</td></tr>
|
||||
<tr><td><code>8</code></td><td>覆い焼きカラー</td></tr>
|
||||
<tr><td><code>9</code></td><td>覆い焼き(リニア) - 加算</td></tr>
|
||||
<tr><td><code>10</code></td><td>加算</td></tr>
|
||||
<tr><td><code>11</code></td><td>オーバーレイ</td></tr>
|
||||
<tr><td><code>12</code></td><td>ソフトライト</td></tr>
|
||||
<tr><td><code>13</code></td><td>ハードライト</td></tr>
|
||||
<tr><td><code>14</code></td><td>ビビッドライト</td></tr>
|
||||
<tr><td><code>15</code></td><td>リニアライト</td></tr>
|
||||
<tr><td><code>16</code></td><td>ピンライト</td></tr>
|
||||
<tr><td><code>17</code></td><td>ハードミックス</td></tr>
|
||||
<tr><td><code>18</code></td><td>差分</td></tr>
|
||||
<tr><td><code>19</code></td><td>除外</td></tr>
|
||||
<tr><td><code>20</code></td><td>減算</td></tr>
|
||||
<tr><td><code>21</code></td><td>除算</td></tr>
|
||||
<tr><td><code>22</code></td><td>色相</td></tr>
|
||||
<tr><td><code>23</code></td><td>彩度</td></tr>
|
||||
<tr><td><code>24</code></td><td>カラー</td></tr>
|
||||
<tr><td><code>25</code></td><td>輝度</td></tr>
|
||||
<tr><td><code>26</code></td><td>カラー比較(明)</td></tr>
|
||||
<tr><td><code>27</code></td><td>背景</td></tr>
|
||||
<tr><td><code>28</code></td><td>カラー比較(暗)</td></tr>
|
||||
<tr><td><code>29</code></td><td>削除</td></tr>
|
||||
<tr><td><code>30</code></td><td>背景でクリッピング</td></tr>
|
||||
<tr><td><code>31</code></td><td>重ならない部分のみ</td></tr>
|
||||
<tr><td><code>32</code></td><td>色反転マスク</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>描画先</h3>
|
||||
|
||||
<p>
|
||||
<code>obj.setoption("drawtarget", 先)</code> は <code>obj.draw</code>/<code>obj.drawpoly</code> の描画先を切り替えます。
|
||||
<code>"framebuffer"</code>(既定)ではフレームバッファへ合成します。
|
||||
<code>"tempbuffer"</code> では作業用の <code>tmp</code> バッファへその場で合成します。
|
||||
<code>obj.setoption("drawtarget", "tempbuffer", w, h)</code> の <code>w, h</code> は <code>tmp</code> バッファを初期化するサイズで、省略すると初期化しません。
|
||||
<code>tmp</code> へ描いた結果は <code>obj.copybuffer("obj", "tmp")</code> で作業画像へ戻せます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code>tempbuffer</code> への合成は通常(ソースオーバー)で、<code>blend</code> は <code>framebuffer</code> への描画に適用されます。
|
||||
描画先の切り替えは両エンジンで動きます。
|
||||
MoonSharp では <code>tempbuffer</code> への合成を GPU で実行し、GPU を利用できない環境では CPU の合成へ自動的に切り替わります。
|
||||
丸めの違いにより、合成の結果はエンジン間でごく僅かに異なることがあります。
|
||||
</p>
|
||||
|
||||
<pre><code>obj.setoption("drawtarget", "tempbuffer", obj.w, obj.h)
|
||||
obj.draw()
|
||||
obj.setoption("drawtarget", "framebuffer")
|
||||
obj.copybuffer("obj", "tmp")</code></pre>
|
||||
|
||||
<h3>アンカーポイント</h3>
|
||||
|
||||
<p>
|
||||
<code>obj.setanchor(name, count [, option, ...])</code> は、プレビュー上にドラッグ可能なアンカーポイントを表示します。
|
||||
ドラッグで調整した座標はプロジェクトへ保存され、<code>name</code> で指定した Lua 変数へ格納されます。
|
||||
変数は <code>pos={x0,y0,x1,y1,…}</code> の並びで、<code>"xyz"</code> を指定すると <code>{x0,y0,z0,x1,y1,z1,…}</code> になります。
|
||||
座標はオブジェクトの中心が原点です。個数は最大 32 個です。
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr><th>オプション</th><th>意味</th></tr>
|
||||
<tr><td><code>"line"</code></td><td>アンカーポイントを線で結ぶ</td></tr>
|
||||
<tr><td><code>"loop"</code></td><td>アンカーポイントを線で結び一周させる</td></tr>
|
||||
<tr><td><code>"star"</code></td><td>各アンカーポイントとオブジェクトの中心を線で結ぶ</td></tr>
|
||||
<tr><td><code>"arm"</code></td><td>オブジェクトの中心から各アンカーポイントへ順に線で結ぶ</td></tr>
|
||||
<tr><td><code>"xyz"</code></td><td>アンカーポイントを 3D 座標で扱う。既定は 2D</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
戻り値は設置したアンカーポイントの数です。両エンジンで動きます。
|
||||
<code>name</code> に <code>"track"</code> を指定するトラックバー連携は現在未対応で、<code>0</code> を返します。
|
||||
</p>
|
||||
|
||||
<pre><code>num = obj.track0
|
||||
obj.setanchor("pos", num, "loop")
|
||||
for i = 0, num - 1 do
|
||||
obj.draw(pos[i * 2 + 1], pos[i * 2 + 2])
|
||||
end</code></pre>
|
||||
|
||||
<h3>互換マップ</h3>
|
||||
|
||||
<p>
|
||||
|
||||
+31
@@ -89,6 +89,11 @@ obj.rzr = time * anim.tau</code></pre>
|
||||
<tr><td><code>obj.num</code></td><td>入力の総数</td></tr>
|
||||
<tr><td><code>obj.track0</code> ~ <code>obj.track3</code></td><td>トラックバーの値(数値)</td></tr>
|
||||
<tr><td><code>obj.check0</code> ~ <code>obj.check3</code></td><td>チェックボックスの値(真偽値)</td></tr>
|
||||
<tr><td><code>obj.slider0</code> ~ <code>obj.slider3</code></td><td>整数スライダーの値</td></tr>
|
||||
<tr><td><code>obj.text</code></td><td>テキスト入力欄の文字列</td></tr>
|
||||
<tr><td><code>obj.font</code></td><td>フォント選択欄のフォント名</td></tr>
|
||||
<tr><td><code>obj.dir</code></td><td>フォルダ選択欄のパス</td></tr>
|
||||
<tr><td><code>obj.file_video</code> ~ <code>obj.file_shader</code></td><td>各ファイル選択欄のパス</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="note">
|
||||
@@ -112,6 +117,32 @@ if obj.check0 then
|
||||
obj.alpha = 255
|
||||
end</code></pre>
|
||||
|
||||
<h2>スライダーと文字列パラメータ</h2>
|
||||
|
||||
<p>
|
||||
<code>obj.slider0</code> ~ <code>obj.slider3</code> は整数スライダーの値です。小数を含みません。
|
||||
表示範囲は <code>obj.slider0</code> が 1 ~ 10、<code>obj.slider1</code> が 0 ~ 100、
|
||||
<code>obj.slider2</code> が 0 ~ 1000、<code>obj.slider3</code> が -1000 ~ 1000 です。
|
||||
状態の切り替えなど、整数値の受け渡しに使えます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
文字列パラメータも参照できます。<code>obj.text</code> はテキスト入力欄の文字列、
|
||||
<code>obj.font</code> はフォント名、<code>obj.dir</code> はフォルダのパスです。
|
||||
ファイル選択欄は種類ごとに <code>obj.file_video</code> / <code>obj.file_audio</code> /
|
||||
<code>obj.file_image</code> / <code>obj.file_project</code> / <code>obj.file_mp4</code> /
|
||||
<code>obj.file_exo</code> / <code>obj.file_subtitle</code> / <code>obj.file_shader</code> で参照し、
|
||||
選択したファイルのパスを取得します。取得したパスは <code>obj.load</code> へ渡して画像や動画を読み込めます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
スライダーと文字列パラメータは、スクリプトがそれらを参照するとパラメータパネルへ表示されます。
|
||||
いずれのパラメータも MoonSharp とネイティブの両エンジンから参照できます。
|
||||
</p>
|
||||
|
||||
<pre><code>local mode = obj.slider0
|
||||
obj.load("image", obj.file_image)</code></pre>
|
||||
|
||||
<h2>よく使う例</h2>
|
||||
|
||||
<h3>中心を基準に振り子のように揺らす</h3>
|
||||
|
||||
+2
-2
@@ -125,8 +125,8 @@ A チャンネル(インデックス <code>base + 4</code>)を変更する
|
||||
<p>
|
||||
ピクセル処理は重くなりがちです。このプラグインは <code>getpixel</code> / <code>setpixel</code> を含むスクリプトを
|
||||
自動的に高速なネイティブレーンへ振り分けます(利用できる場合)。さらに、二重ループで
|
||||
<code>getpixel</code> → 計算 → <code>setpixel</code> という決まった形のスクリプトは、CPU / GPU カーネルへ
|
||||
変換されてさらに高速に実行できます。詳しくは <a href="engines.html">エンジンと高速化</a> を参照してください。
|
||||
<code>getpixel</code> → 計算 → <code>setpixel</code> という決まった形のスクリプトは、CPU カーネルへ
|
||||
変換されてさらに高速に実行できます。<code>--!gpu</code> を明示すると GPU カーネルも使えます。詳しくは <a href="engines.html">エンジンと高速化</a> を参照してください。
|
||||
</p>
|
||||
|
||||
<div class="pager">
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
<tr><td><code>obj.index</code> / <code>obj.num</code></td><td>入力のインデックス / 総数</td></tr>
|
||||
<tr><td><code>obj.track0</code> ~ <code>obj.track3</code></td><td>トラックバーの値</td></tr>
|
||||
<tr><td><code>obj.check0</code> ~ <code>obj.check3</code></td><td>チェックボックスの値</td></tr>
|
||||
<tr><td><code>obj.slider0</code> ~ <code>obj.slider3</code></td><td>整数スライダーの値</td></tr>
|
||||
<tr><td><code>obj.text</code> / <code>obj.font</code> / <code>obj.dir</code></td><td>テキスト、フォント名、フォルダパス</td></tr>
|
||||
<tr><td><code>obj.file_video</code> ~ <code>obj.file_shader</code></td><td>各ファイル選択欄のパス</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>obj 関数</h2>
|
||||
|
||||
+275
-12
@@ -22,6 +22,7 @@ local mapSize = tonumber(arg[2])
|
||||
local workEventName = arg[3]
|
||||
local doneEventName = arg[4]
|
||||
local shimPath = arg[5]
|
||||
local stringParamsCap = tonumber(arg[6])
|
||||
|
||||
local hMap = k32.OpenFileMappingA(FILE_MAP_ALL_ACCESS, 0, mapName)
|
||||
assert(hMap ~= nil, "OpenFileMapping failed")
|
||||
@@ -49,12 +50,14 @@ local OFF_CB_FOUND = 10
|
||||
local OFF_CB_KIND = 11
|
||||
local OFF_LOAD_RESULT_W = 12
|
||||
local OFF_LOAD_RESULT_H = 13
|
||||
local OFF_STRING_PARAMS_LEN = 14
|
||||
local SCRIPT_OFFSET = 64 + 64 * 8
|
||||
local ERROR_OFFSET = SCRIPT_OFFSET + 128 * 1024
|
||||
local CB_TAG_OFFSET = ERROR_OFFSET + 4 * 1024
|
||||
local CB_TAG_MAX = 4096
|
||||
local CB_RESULT_OFFSET = CB_TAG_OFFSET + CB_TAG_MAX
|
||||
local PIXEL_OFFSET = CB_RESULT_OFFSET + 8 * 8
|
||||
local STRING_PARAMS_OFFSET = CB_RESULT_OFFSET + 8 * 8
|
||||
local PIXEL_OFFSET = STRING_PARAMS_OFFSET + stringParamsCap
|
||||
local FIRST_WRITABLE = 8
|
||||
local LAST_WRITABLE = 25
|
||||
local STATUS_CALLBACK = 3
|
||||
@@ -66,6 +69,8 @@ local CB_KIND_DRAWPOLY = 4
|
||||
local CB_KIND_LOADTEXT = 5
|
||||
local CB_KIND_LOADIMAGE = 6
|
||||
local CB_KIND_LOADMOVIE = 7
|
||||
local CB_KIND_SETANCHOR = 8
|
||||
local CB_KIND_REQUESTPIXELS = 9
|
||||
|
||||
assert(loadfile(shimPath))()
|
||||
|
||||
@@ -84,6 +89,141 @@ local buffers = {}
|
||||
local options = {}
|
||||
local pixeloptions = {}
|
||||
local dirty = false
|
||||
local pixelsValid = false
|
||||
local drawTarget = "frame"
|
||||
|
||||
local function ensurePixels()
|
||||
if pixelsValid then return end
|
||||
i32[OFF_CB_KIND] = CB_KIND_REQUESTPIXELS
|
||||
i32[OFF_STATUS] = STATUS_CALLBACK
|
||||
k32.SetEvent(doneEvent)
|
||||
k32.WaitForSingleObject(workEvent, INFINITE)
|
||||
pixelsValid = true
|
||||
end
|
||||
|
||||
local function sampleSource(src, srcW, srcH, u, v, linear)
|
||||
if not linear then
|
||||
local su = clamp(math.floor(u), 0, srcW - 1)
|
||||
local sv = clamp(math.floor(v), 0, srcH - 1)
|
||||
local si = (sv * srcW + su) * 4
|
||||
return src[si], src[si + 1], src[si + 2], src[si + 3]
|
||||
end
|
||||
local fx = u - 0.5
|
||||
local fy = v - 0.5
|
||||
local x0 = math.floor(fx)
|
||||
local y0 = math.floor(fy)
|
||||
local tx = fx - x0
|
||||
local ty = fy - y0
|
||||
local b, g, r, a = 0, 0, 0, 0
|
||||
for j = 0, 1 do
|
||||
local sy = clamp(y0 + j, 0, srcH - 1)
|
||||
local wy = (j == 0) and (1 - ty) or ty
|
||||
for i = 0, 1 do
|
||||
local sx = clamp(x0 + i, 0, srcW - 1)
|
||||
local w = wy * ((i == 0) and (1 - tx) or tx)
|
||||
local si = (sy * srcW + sx) * 4
|
||||
b = b + src[si] * w
|
||||
g = g + src[si + 1] * w
|
||||
r = r + src[si + 2] * w
|
||||
a = a + src[si + 3] * w
|
||||
end
|
||||
end
|
||||
return b, g, r, a
|
||||
end
|
||||
|
||||
local function compositeOver(dst, di, sb, sg, sr, sa)
|
||||
local inv = 1 - sa / 255
|
||||
dst[di] = math.floor(clamp(sb + dst[di] * inv, 0, 255))
|
||||
dst[di + 1] = math.floor(clamp(sg + dst[di + 1] * inv, 0, 255))
|
||||
dst[di + 2] = math.floor(clamp(sr + dst[di + 2] * inv, 0, 255))
|
||||
dst[di + 3] = math.floor(clamp(sa + dst[di + 3] * inv, 0, 255))
|
||||
end
|
||||
|
||||
local function compositeDrawInto(dst, dstW, dstH, src, srcW, srcH, ox, oy, zoom, aspect, alpha, linear)
|
||||
if srcW <= 0 or srcH <= 0 or dstW <= 0 or dstH <= 0 then return end
|
||||
local ca = clamp(aspect, -1, 1)
|
||||
local zx = zoom * (1 + ca)
|
||||
local zy = zoom * (1 - ca)
|
||||
if zx == 0 or zy == 0 then return end
|
||||
local ka = clamp(alpha, 0, 1)
|
||||
if ka <= 0 then return end
|
||||
local halfW = srcW * 0.5
|
||||
local halfH = srcH * 0.5
|
||||
local spanX = math.abs(halfW * zx)
|
||||
local spanY = math.abs(halfH * zy)
|
||||
local x0 = math.max(0, math.floor(ox - spanX))
|
||||
local x1 = math.min(dstW - 1, math.ceil(ox + spanX))
|
||||
local y0 = math.max(0, math.floor(oy - spanY))
|
||||
local y1 = math.min(dstH - 1, math.ceil(oy + spanY))
|
||||
for py = y0, y1 do
|
||||
for px = x0, x1 do
|
||||
local u = (px + 0.5 - ox) / zx + halfW
|
||||
local v = (py + 0.5 - oy) / zy + halfH
|
||||
if u >= 0 and u < srcW and v >= 0 and v < srcH then
|
||||
local sb, sg, sr, sa = sampleSource(src, srcW, srcH, u, v, linear)
|
||||
compositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function compositeDrawPolyInto(dst, dstW, dstH, src, srcW, srcH, poly, alpha, linear)
|
||||
if srcW <= 0 or srcH <= 0 or dstW <= 0 or dstH <= 0 then return end
|
||||
local x0p, y0p = poly[0], poly[1]
|
||||
local x1p, y1p = poly[3], poly[4]
|
||||
local x3p, y3p = poly[9], poly[10]
|
||||
local u0, v0 = poly[12], poly[13]
|
||||
local u1, v1 = poly[14], poly[15]
|
||||
local u3, v3 = poly[18], poly[19]
|
||||
local det = u0 * (v1 - v3) - v0 * (u1 - u3) + (u1 * v3 - v1 * u3)
|
||||
if math.abs(det) < 1e-9 then return end
|
||||
local inv = 1 / det
|
||||
local a = (x0p * (v1 - v3) - v0 * (x1p - x3p) + (x1p * v3 - v1 * x3p)) * inv
|
||||
local b = (u0 * (x1p - x3p) - x0p * (u1 - u3) + (u1 * x3p - x1p * u3)) * inv
|
||||
local c = (u0 * (v1 * x3p - x1p * v3) - v0 * (u1 * x3p - x1p * u3) + x0p * (u1 * v3 - v1 * u3)) * inv
|
||||
local d = (y0p * (v1 - v3) - v0 * (y1p - y3p) + (y1p * v3 - v1 * y3p)) * inv
|
||||
local e = (u0 * (y1p - y3p) - y0p * (u1 - u3) + (u1 * y3p - y1p * u3)) * inv
|
||||
local f = (u0 * (v1 * y3p - y1p * v3) - v0 * (u1 * y3p - y1p * u3) + y0p * (u1 * v3 - v1 * u3)) * inv
|
||||
local adet = a * e - b * d
|
||||
if math.abs(adet) < 1e-9 then return end
|
||||
local ka = clamp(alpha, 0, 1)
|
||||
if ka <= 0 then return end
|
||||
local minX, minY, maxX, maxY = poly[0], poly[1], poly[0], poly[1]
|
||||
for i = 0, 3 do
|
||||
local xx = poly[i * 3]
|
||||
local yy = poly[i * 3 + 1]
|
||||
if xx < minX then minX = xx end
|
||||
if xx > maxX then maxX = xx end
|
||||
if yy < minY then minY = yy end
|
||||
if yy > maxY then maxY = yy end
|
||||
end
|
||||
local bx0 = math.max(0, math.floor(minX))
|
||||
local bx1 = math.min(dstW - 1, math.ceil(maxX))
|
||||
local by0 = math.max(0, math.floor(minY))
|
||||
local by1 = math.min(dstH - 1, math.ceil(maxY))
|
||||
for py = by0, by1 do
|
||||
for px = bx0, bx1 do
|
||||
local dx = (px + 0.5) - c
|
||||
local dy = (py + 0.5) - f
|
||||
local u = (e * dx - b * dy) / adet
|
||||
local v = (-d * dx + a * dy) / adet
|
||||
if u >= 0 and u < srcW and v >= 0 and v < srcH then
|
||||
local sb, sg, sr, sa = sampleSource(src, srcW, srcH, u, v, linear)
|
||||
compositeOver(dst, (py * dstW + px) * 4, sb * ka, sg * ka, sr * ka, sa * ka)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ensureTemp()
|
||||
local t = buffers["t"]
|
||||
if not t then
|
||||
local n = width * height * 4
|
||||
t = { data = ffi.new("uint8_t[?]", n), w = width, h = height }
|
||||
buffers["t"] = t
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local function bufferKind(id)
|
||||
local c = id:match("^%s*(.)")
|
||||
@@ -96,6 +236,7 @@ local function bufferKind(id)
|
||||
return c, c
|
||||
end
|
||||
|
||||
local sandbox
|
||||
local obj = {}
|
||||
local scene = {}
|
||||
local ymm4 = {}
|
||||
@@ -103,6 +244,7 @@ local ymm4 = {}
|
||||
function obj.getpixel(x, y)
|
||||
x = math.floor(x); y = math.floor(y)
|
||||
if x < 0 or y < 0 or x >= width or y >= height then return 0, 0, 0, 0 end
|
||||
ensurePixels()
|
||||
local p = pixels + (y * width + x) * 4
|
||||
local a = p[3]
|
||||
if a <= 0 then return 0, 0, 0, 0 end
|
||||
@@ -113,6 +255,7 @@ end
|
||||
function obj.setpixel(x, y, r, g, b, a)
|
||||
x = math.floor(x); y = math.floor(y)
|
||||
if x < 0 or y < 0 or x >= width or y >= height then return end
|
||||
ensurePixels()
|
||||
a = a or 255
|
||||
dirty = true
|
||||
local aK = clamp(a, 0, 255) / 255
|
||||
@@ -124,6 +267,7 @@ function obj.setpixel(x, y, r, g, b, a)
|
||||
end
|
||||
|
||||
function obj.getpixeldata()
|
||||
ensurePixels()
|
||||
local total = width * height * 4
|
||||
local buf = pixels
|
||||
local pd = { width = width, height = height }
|
||||
@@ -199,6 +343,7 @@ local function applyLoadResult()
|
||||
i32[OFF_WIDTH] = newW
|
||||
i32[OFF_HEIGHT] = newH
|
||||
dirty = true
|
||||
pixelsValid = true
|
||||
obj.w = newW; obj.h = newH
|
||||
obj.hw = newW / 2; obj.hh = newH / 2
|
||||
obj.cx = newW / 2; obj.cy = newH / 2
|
||||
@@ -316,6 +461,13 @@ function obj.effect(name, ...)
|
||||
end
|
||||
|
||||
function obj.draw(ox, oy, oz, zoom, alpha, aspect)
|
||||
if drawTarget == "temp" then
|
||||
ensurePixels()
|
||||
local t = ensureTemp()
|
||||
compositeDrawInto(t.data, t.w, t.h, pixels, width, height,
|
||||
ox or 0, oy or 0, zoom or 1, aspect or 0, alpha or 1, (options.antialias or 1) ~= 0)
|
||||
return
|
||||
end
|
||||
cbResult[0] = ox or 0
|
||||
cbResult[1] = oy or 0
|
||||
cbResult[2] = oz or 0
|
||||
@@ -323,6 +475,7 @@ function obj.draw(ox, oy, oz, zoom, alpha, aspect)
|
||||
cbResult[4] = alpha or 1
|
||||
cbResult[5] = aspect or 0
|
||||
cbResult[6] = options.antialias or 1
|
||||
cbResult[7] = options.blend or 0
|
||||
i32[OFF_CB_KIND] = CB_KIND_DRAW
|
||||
i32[OFF_STATUS] = STATUS_CALLBACK
|
||||
k32.SetEvent(doneEvent)
|
||||
@@ -333,14 +486,15 @@ function obj.drawpoly(...)
|
||||
local n = select("#", ...)
|
||||
if n < 12 then return end
|
||||
local a = { ... }
|
||||
for i = 0, 11 do cbTagD[i] = a[i + 1] or 0 end
|
||||
local p = {}
|
||||
for i = 0, 11 do p[i] = a[i + 1] or 0 end
|
||||
if n >= 20 then
|
||||
for i = 0, 7 do cbTagD[12 + i] = a[13 + i] or 0 end
|
||||
for i = 0, 7 do p[12 + i] = a[13 + i] or 0 end
|
||||
else
|
||||
cbTagD[12] = 0; cbTagD[13] = 0
|
||||
cbTagD[14] = width; cbTagD[15] = 0
|
||||
cbTagD[16] = width; cbTagD[17] = height
|
||||
cbTagD[18] = 0; cbTagD[19] = height
|
||||
p[12] = 0; p[13] = 0
|
||||
p[14] = width; p[15] = 0
|
||||
p[16] = width; p[17] = height
|
||||
p[18] = 0; p[19] = height
|
||||
end
|
||||
local alpha = 1
|
||||
if n == 13 then
|
||||
@@ -348,8 +502,16 @@ function obj.drawpoly(...)
|
||||
elseif n >= 21 then
|
||||
alpha = a[21] or 1
|
||||
end
|
||||
cbTagD[20] = alpha
|
||||
p[20] = alpha
|
||||
if drawTarget == "temp" then
|
||||
ensurePixels()
|
||||
local t = ensureTemp()
|
||||
compositeDrawPolyInto(t.data, t.w, t.h, pixels, width, height, p, alpha, (options.antialias or 1) ~= 0)
|
||||
return
|
||||
end
|
||||
for i = 0, 20 do cbTagD[i] = p[i] end
|
||||
cbTagD[21] = options.antialias or 1
|
||||
cbTagD[22] = options.blend or 0
|
||||
i32[OFF_CB_KIND] = CB_KIND_DRAWPOLY
|
||||
i32[OFF_STATUS] = STATUS_CALLBACK
|
||||
k32.SetEvent(doneEvent)
|
||||
@@ -363,10 +525,22 @@ function obj.getvalue(target)
|
||||
return 0
|
||||
end
|
||||
|
||||
function obj.setoption(name, value)
|
||||
function obj.setoption(name, value, a, b)
|
||||
if type(name) ~= "string" then return end
|
||||
if value == nil then value = true end
|
||||
options[name] = value
|
||||
if name == "drawtarget" then
|
||||
if value == "tempbuffer" then
|
||||
drawTarget = "temp"
|
||||
if a ~= nil and b ~= nil then
|
||||
local w = math.max(1, math.floor(a))
|
||||
local h = math.max(1, math.floor(b))
|
||||
buffers["t"] = { data = ffi.new("uint8_t[?]", w * h * 4), w = w, h = h }
|
||||
end
|
||||
else
|
||||
drawTarget = "frame"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function obj.getoption(name)
|
||||
@@ -382,12 +556,53 @@ function obj.pixeloption(name, value)
|
||||
pixeloptions[name] = value
|
||||
end
|
||||
|
||||
function obj.setanchor(name, count, ...)
|
||||
if type(name) ~= "string" then return 0 end
|
||||
count = math.floor(count or 0)
|
||||
if count < 0 then count = 0 elseif count > 32 then count = 32 end
|
||||
if name == "track" then return 0 end
|
||||
|
||||
local connection, is3d = 0, false
|
||||
local optCount = select("#", ...)
|
||||
for i = 1, optCount do
|
||||
local o = select(i, ...)
|
||||
if o == "line" then connection = 1
|
||||
elseif o == "loop" then connection = 2
|
||||
elseif o == "star" then connection = 3
|
||||
elseif o == "arm" then connection = 4
|
||||
elseif o == "xyz" then is3d = true end
|
||||
end
|
||||
|
||||
local len = #name
|
||||
if len > CB_TAG_MAX then len = CB_TAG_MAX end
|
||||
ffi.copy(base + CB_TAG_OFFSET, name, len)
|
||||
i32[OFF_CB_TAGLEN] = len
|
||||
cbResult[0] = count
|
||||
cbResult[1] = is3d and 1 or 0
|
||||
cbResult[2] = connection
|
||||
i32[OFF_CB_KIND] = CB_KIND_SETANCHOR
|
||||
i32[OFF_STATUS] = STATUS_CALLBACK
|
||||
k32.SetEvent(doneEvent)
|
||||
k32.WaitForSingleObject(workEvent, INFINITE)
|
||||
|
||||
local stride = is3d and 3 or 2
|
||||
local pos = {}
|
||||
for i = 0, count - 1 do
|
||||
pos[i * stride + 1] = cbTagD[i * stride + 0]
|
||||
pos[i * stride + 2] = cbTagD[i * stride + 1]
|
||||
if is3d then pos[i * stride + 3] = cbTagD[i * stride + 2] end
|
||||
end
|
||||
sandbox[name] = pos
|
||||
return count
|
||||
end
|
||||
|
||||
function obj.copybuffer(dst, src)
|
||||
if type(dst) ~= "string" or type(src) ~= "string" then return end
|
||||
local sk, skey = bufferKind(src)
|
||||
local data, w, h
|
||||
if sk == "o" then
|
||||
data = ffi.string(pixels, width * height * 4)
|
||||
ensurePixels()
|
||||
data = pixels
|
||||
w = width; h = height
|
||||
elseif sk == "t" or sk == "c" then
|
||||
local b = buffers[skey]
|
||||
@@ -404,13 +619,17 @@ function obj.copybuffer(dst, src)
|
||||
width = w; height = h
|
||||
i32[OFF_WIDTH] = w; i32[OFF_HEIGHT] = h
|
||||
dirty = true
|
||||
pixelsValid = true
|
||||
obj.w = w; obj.h = h
|
||||
obj.hw = w / 2; obj.hh = h / 2
|
||||
obj.cx = w / 2; obj.cy = h / 2
|
||||
obj.cz = 0
|
||||
obj.diagonal = math.sqrt(w * w + h * h)
|
||||
elseif dk == "t" or dk == "c" then
|
||||
buffers[dkey] = { data = data, w = w, h = h }
|
||||
local n = w * h * 4
|
||||
local arr = ffi.new("uint8_t[?]", n)
|
||||
ffi.copy(arr, data, n)
|
||||
buffers[dkey] = { data = arr, w = w, h = h }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -457,7 +676,7 @@ function obj.getobject(tag, frame)
|
||||
return buildObject()
|
||||
end
|
||||
|
||||
local sandbox = {
|
||||
sandbox = {
|
||||
obj = obj, scene = scene, ymm4 = ymm4,
|
||||
anim = anim, bit32 = bit32, rawlen = rawlen,
|
||||
math = math, string = string, table = table,
|
||||
@@ -469,6 +688,23 @@ local sandbox = {
|
||||
}
|
||||
sandbox._G = sandbox
|
||||
|
||||
local function captureKeys(t)
|
||||
local keys = {}
|
||||
for k in pairs(t) do keys[k] = true end
|
||||
return keys
|
||||
end
|
||||
|
||||
local function resetExtraKeys(t, keys)
|
||||
for k in pairs(t) do
|
||||
if not keys[k] then t[k] = nil end
|
||||
end
|
||||
end
|
||||
|
||||
local sandboxKeys = captureKeys(sandbox)
|
||||
local objKeys = captureKeys(obj)
|
||||
local sceneKeys = captureKeys(scene)
|
||||
local ymm4Keys = captureKeys(ymm4)
|
||||
|
||||
local compiledCode, compiledChunk
|
||||
|
||||
local function loadFields()
|
||||
@@ -483,6 +719,7 @@ local function loadFields()
|
||||
obj.rx = f64[20]; obj.ry = f64[21]; obj.rz = f64[22]
|
||||
obj.rxr = f64[23]; obj.ryr = f64[24]; obj.rzr = f64[25]
|
||||
obj.track0 = f64[26]; obj.track1 = f64[27]; obj.track2 = f64[28]; obj.track3 = f64[29]
|
||||
obj.slider0 = f64[58]; obj.slider1 = f64[59]; obj.slider2 = f64[60]; obj.slider3 = f64[61]
|
||||
obj.time = f64[30]; obj.frame = f64[31]; obj.totalframe = f64[32]; obj.totaltime = f64[33]
|
||||
obj.t = f64[34]; obj.framerate = f64[35]; obj.layer = f64[36]; obj.index = f64[37]; obj.num = f64[38]
|
||||
scene.width = f64[39]; scene.height = f64[40]; scene.cx = f64[41]; scene.cy = f64[42]
|
||||
@@ -494,6 +731,23 @@ local function loadFields()
|
||||
obj.timelineframe = f64[51]; obj.timelinetime = f64[52]
|
||||
obj.check0 = f64[53] ~= 0; obj.check1 = f64[54] ~= 0; obj.check2 = f64[55] ~= 0; obj.check3 = f64[56] ~= 0
|
||||
sandbox.color = (f64[57] >= 0) and f64[57] or nil
|
||||
sandbox.time = f64[30]; sandbox.frame = f64[31]; sandbox.totalframe = f64[32]
|
||||
sandbox.framerate = f64[35]; sandbox.layer = f64[36]
|
||||
sandbox.timelineframe = f64[51]; sandbox.timelinetime = f64[52]
|
||||
end
|
||||
|
||||
local function loadStringParams()
|
||||
if i32[OFF_STRING_PARAMS_LEN] <= 0 then return end
|
||||
local p = base + STRING_PARAMS_OFFSET
|
||||
local count = ffi.cast("int32_t*", p)[0]
|
||||
local pos = 4
|
||||
for _ = 1, count do
|
||||
local nameLen = ffi.cast("int32_t*", p + pos)[0]; pos = pos + 4
|
||||
local name = ffi.string(p + pos, nameLen); pos = pos + nameLen
|
||||
local valLen = ffi.cast("int32_t*", p + pos)[0]; pos = pos + 4
|
||||
local val = ffi.string(p + pos, valLen); pos = pos + valLen
|
||||
obj[name] = val
|
||||
end
|
||||
end
|
||||
|
||||
local function storeFields()
|
||||
@@ -514,6 +768,7 @@ while true do
|
||||
if i32[OFF_COMMAND] == 1 then break end
|
||||
|
||||
dirty = false
|
||||
pixelsValid = false
|
||||
local scriptLen = i32[OFF_SCRIPTLEN]
|
||||
local code = ffi.string(base + SCRIPT_OFFSET, scriptLen)
|
||||
|
||||
@@ -533,16 +788,24 @@ while true do
|
||||
end
|
||||
|
||||
if compiledChunk and code == compiledCode then
|
||||
resetExtraKeys(sandbox, sandboxKeys)
|
||||
resetExtraKeys(obj, objKeys)
|
||||
resetExtraKeys(scene, sceneKeys)
|
||||
resetExtraKeys(ymm4, ymm4Keys)
|
||||
loadFields()
|
||||
loadStringParams()
|
||||
cacheTag = nil
|
||||
for k in pairs(options) do options[k] = nil end
|
||||
for k in pairs(pixeloptions) do pixeloptions[k] = nil end
|
||||
drawTarget = "frame"
|
||||
font.family = ""; font.size = 34; font.bold = false; font.italic = false; font.color = 0xFFFFFF
|
||||
math.randomseed(f64[31])
|
||||
setfenv(compiledChunk, sandbox)
|
||||
local ok, err = pcall(compiledChunk)
|
||||
if ok then
|
||||
storeFields()
|
||||
local ds = options.draw_state
|
||||
if ds == nil then f64[62] = 0 elseif ds == false or ds == 0 then f64[62] = 2 else f64[62] = 1 end
|
||||
i32[OFF_PIXELSDIRTY] = dirty and 1 or 0
|
||||
i32[OFF_STATUS] = 1
|
||||
k32.SetEvent(doneEvent)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする