軸に平行な直線のずれを、タップを減らしたフィルターで描いて速くする
・「物理ベース」で軸に平行な短い直線のずれを、ステップの合計を畳み込んだタップのフィルターで描くよう変更-M
このコミットが含まれているのは:
14ファイル変更
+624
-31
検索条件に一致するファイルはありません
@@ -7,50 +7,67 @@ internal static class StepShaders
|
||||
{
|
||||
private const string LegacyName = "SpectrumColorShift";
|
||||
private const string PhysicalName = "SpectrumColorShiftPhysical";
|
||||
private const string FilterName = "SpectrumColorShiftPhysicalFilter";
|
||||
|
||||
private static readonly Variants Legacy = new(LegacyName);
|
||||
private static readonly Variants Physical = new(PhysicalName);
|
||||
private static readonly ShiftMode[] AllModes = Enum.GetValues<ShiftMode>();
|
||||
|
||||
public static IEnumerable<int> Counts => Enumerable.Range(0, Variants.CountLength).Select(Variants.CountAt);
|
||||
private static readonly Variants Legacy = new(LegacyName, AllModes, Spectrum.MinSteps, Spectrum.MaxSteps, Spectrum.StepQuantum);
|
||||
private static readonly Variants Physical = new(PhysicalName, AllModes, Spectrum.MinSteps, Spectrum.MaxSteps, Spectrum.StepQuantum);
|
||||
private static readonly Variants Filter = new(FilterName, [ShiftMode.Linear], SpectralFilter.TapQuantum, SpectralFilter.MaxTaps, SpectralFilter.TapQuantum);
|
||||
|
||||
public static IEnumerable<ShiftMode> Modes => Variants.Modes;
|
||||
public static IEnumerable<int> Counts => Legacy.Counts;
|
||||
|
||||
public static IEnumerable<int> FilterCounts => Filter.Counts;
|
||||
|
||||
public static IEnumerable<ShiftMode> Modes => AllModes;
|
||||
|
||||
public static byte[] DefaultBytes => Legacy.Bytes(ShiftMode.Linear, Spectrum.DefaultSteps);
|
||||
|
||||
public static string ResourceName(bool physical, ShiftMode mode, int count) => (physical ? Physical : Legacy).ResourceName(mode, count);
|
||||
|
||||
public static string FilterResourceName(int taps) => Filter.ResourceName(ShiftMode.Linear, taps);
|
||||
|
||||
public static Guid Select(bool physical, ShiftMode mode, int steps) => (physical ? Physical : Legacy).Id(mode, steps);
|
||||
|
||||
public static Guid SelectFilter(int taps) => Filter.Id(ShiftMode.Linear, taps);
|
||||
|
||||
public static void Load(ID2D1EffectContext effectContext)
|
||||
{
|
||||
Legacy.Load(effectContext);
|
||||
Physical.Load(effectContext);
|
||||
Filter.Load(effectContext);
|
||||
}
|
||||
|
||||
private sealed class Variants
|
||||
{
|
||||
public static ShiftMode[] Modes { get; } = Enum.GetValues<ShiftMode>();
|
||||
|
||||
public static int CountLength { get; } = (Spectrum.MaxSteps - Spectrum.MinSteps) / Spectrum.StepQuantum + 1;
|
||||
|
||||
private readonly string _name;
|
||||
private readonly ShiftMode[] _modes;
|
||||
private readonly int _minimum;
|
||||
private readonly int _maximum;
|
||||
private readonly int _quantum;
|
||||
private readonly int _length;
|
||||
private readonly Guid[] _ids;
|
||||
private readonly Lazy<byte[]>[] _bytes;
|
||||
|
||||
public Variants(string name)
|
||||
public Variants(string name, ShiftMode[] modes, int minimum, int maximum, int quantum)
|
||||
{
|
||||
_name = name;
|
||||
_ids = [.. Enumerable.Range(0, Modes.Length * CountLength).Select(_ => Guid.NewGuid())];
|
||||
_bytes = [.. Enumerable.Range(0, Modes.Length * CountLength).Select(index => new Lazy<byte[]>(() => Read(index)))];
|
||||
_modes = modes;
|
||||
_minimum = minimum;
|
||||
_maximum = maximum;
|
||||
_quantum = quantum;
|
||||
_length = (maximum - minimum) / quantum + 1;
|
||||
_ids = [.. Enumerable.Range(0, modes.Length * _length).Select(_ => Guid.NewGuid())];
|
||||
_bytes = [.. Enumerable.Range(0, modes.Length * _length).Select(index => new Lazy<byte[]>(() => Read(index)))];
|
||||
}
|
||||
|
||||
public static int CountAt(int index) => Spectrum.MinSteps + index * Spectrum.StepQuantum;
|
||||
public IEnumerable<int> Counts => Enumerable.Range(0, _length).Select(CountAt);
|
||||
|
||||
public string ResourceName(ShiftMode mode, int count) => $"{_name}{mode}{count}";
|
||||
|
||||
public Guid Id(ShiftMode mode, int steps) => _ids[IndexOf(mode, steps)];
|
||||
public Guid Id(ShiftMode mode, int count) => _ids[IndexOf(mode, count)];
|
||||
|
||||
public byte[] Bytes(ShiftMode mode, int steps) => _bytes[IndexOf(mode, steps)].Value;
|
||||
public byte[] Bytes(ShiftMode mode, int count) => _bytes[IndexOf(mode, count)].Value;
|
||||
|
||||
public void Load(ID2D1EffectContext effectContext)
|
||||
{
|
||||
@@ -61,10 +78,12 @@ internal static class StepShaders
|
||||
}
|
||||
}
|
||||
|
||||
private static int IndexOf(ShiftMode mode, int steps)
|
||||
=> Array.IndexOf(Modes, mode) * CountLength + (Spectrum.Padded(steps) - Spectrum.MinSteps) / Spectrum.StepQuantum;
|
||||
private int CountAt(int index) => _minimum + index * _quantum;
|
||||
|
||||
private int IndexOf(ShiftMode mode, int count)
|
||||
=> Array.IndexOf(_modes, mode) * _length + (Math.Clamp(count, _minimum, _maximum) - _minimum + _quantum - 1) / _quantum;
|
||||
|
||||
private byte[] Read(int index)
|
||||
=> PackResourceReader.ReadAllBytes(ShaderResourceUri.Get(ResourceName(Modes[index / CountLength], CountAt(index % CountLength))));
|
||||
=> PackResourceReader.ReadAllBytes(ShaderResourceUri.Get(ResourceName(_modes[index / _length], CountAt(index % _length))));
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする