コミットを比較
44
コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
95997925c2
|
||
|
|
d5c8dc4a42
|
||
|
|
0a1a232d70
|
||
|
|
8e9d6bab92
|
||
|
|
573de65eac
|
||
|
|
a16d48430a
|
||
|
|
3a9adfc130
|
||
|
|
3acb29e37a
|
||
|
|
c48cfe1251
|
||
|
|
3da0c28fe6
|
||
|
|
c43fa215bc
|
||
|
|
32232b6435
|
||
|
|
4cc025c1ba
|
||
|
|
3866902139
|
||
|
|
52f384b482
|
||
|
|
70537dedc4
|
||
|
|
f8fb7217b5
|
||
|
|
ec20c30105
|
||
|
|
a3004b422e
|
||
|
|
2c433313f3
|
||
|
|
0944ec24b7
|
||
|
|
3b4cc42b7e
|
||
|
|
4253485354
|
||
|
|
ee74caca12
|
||
|
|
8a5ac1a07f
|
||
|
|
a791fc005a
|
||
|
|
2ee69da4eb
|
||
|
|
c14ce888f0
|
||
|
|
b65a1226bd
|
||
|
|
5231cedf84
|
||
|
|
282bb5716f
|
||
|
|
44ed81044c
|
||
|
|
f3fe50aa10
|
||
|
|
e53e6088a0
|
||
|
|
f26616806a
|
||
|
|
f78cb347b9
|
||
|
|
b83da702d6
|
||
|
|
847936e0d8
|
||
|
|
2cbcb407bb
|
||
|
|
5a8fab400b
|
||
|
|
028e099b77
|
||
|
|
48e80b920e
|
||
|
|
f1d08251a2
|
||
|
|
8d73023a78
|
検索条件に一致するファイルはありません
@@ -47,9 +47,8 @@ YukkuriMovieMaker4上で動作する、素材の明るい部分を光源とみ
|
||||
- 影: 前景のアイテムに「体積光の遮光」を付け、「体積光」の
|
||||
「遮光の番号」と同じ番号を選ぶと、光の筋に影を落とせます。
|
||||
影を落とすアイテムは、「体積光」を付けたアイテムより上のレイヤーに
|
||||
置いてください。番号は1から8までで、同じシーンの同じ番号に付けられる
|
||||
のは4つまでです。別のシーンのアイテムには、番号が同じでも影を落とし
|
||||
ません。
|
||||
置いてください。番号は1から8までで、同じ番号に付けられるのは
|
||||
4つまでです。
|
||||
|
||||
- 影の範囲: 影を落とすアイテムが影を落とすのは、光源の画像と光の筋の間に
|
||||
あるときだけです。影の縁は影を落とすアイテムの画像の縁のままで、
|
||||
|
||||
@@ -97,10 +97,6 @@ YukkuriMovieMaker4(YMM4)上で動作する、素材の明るい部分を光
|
||||
|
||||
「色」は光に掛ける色です。白では素材の画素の色のままになります。
|
||||
|
||||
次の画像は、ステンドグラスの窓の写真に適用した例です。「向き」は-60°、「手前への角度」は45°、「強さ」は700%、「しきい値」は30%で、ほかの項目は既定値です。上が入力、下が出力で、しきい値を超える明るいガラスの部分だけが光源になり、窓から右下へ光の筋が伸びます。元の写真は、Wikimedia CommonsにCC0で公開されているWmpearl氏の「[Stained glass window, Hammerfest Church](https://commons.wikimedia.org/wiki/File:Stained_glass_window,_Hammerfest_Church.JPG)」です。
|
||||
|
||||

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

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