From 3fb24d35cda00cd77c2e5db69654694775b749b8 Mon Sep 17 00:00:00 2001 From: routersys Date: Wed, 14 Oct 2026 08:19:13 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0=E3=82=A8?= =?UTF-8?q?=E3=83=95=E3=82=A7=E3=82=AF=E3=83=88=E3=81=AE=E4=B8=8B=E9=99=90?= =?UTF-8?q?=E3=81=A8=E4=B8=8A=E9=99=90=E3=81=AB=E5=90=8D=E5=89=8D=E3=82=92?= =?UTF-8?q?=E4=BB=98=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MetaballSpectrum/MetaballSpectrumCustomEffect.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/MetaballSpectrum/MetaballSpectrumCustomEffect.cs b/MetaballSpectrum/MetaballSpectrumCustomEffect.cs index aa5dd08..76875c3 100644 --- a/MetaballSpectrum/MetaballSpectrumCustomEffect.cs +++ b/MetaballSpectrum/MetaballSpectrumCustomEffect.cs @@ -44,6 +44,9 @@ internal sealed class MetaballSpectrumCustomEffect(IGraphicsDevicesAndContext de [CustomEffect(1)] private sealed class EffectImpl : D2D1CustomShaderEffectImplBase { + private const float MinimumLength = 0.001f; + private const float MinimumThreshold = 0.001f; + private const float MaximumThreshold = 0.999f; private const int HeaderByteSize = 48; private const int ConstantBufferByteSize = HeaderByteSize + ValueByteSize; @@ -51,19 +54,19 @@ internal sealed class MetaballSpectrumCustomEffect(IGraphicsDevicesAndContext de private readonly byte[] _values = new byte[ValueByteSize]; [CustomEffectProperty(PropertyType.Float, (int)PropertyIndex.FieldWidth)] - public float FieldWidth { get => _cb.FieldWidth; set { _cb.FieldWidth = Math.Max(value, 0.001f); UpdateConstants(); } } + public float FieldWidth { get => _cb.FieldWidth; set { _cb.FieldWidth = Math.Max(value, MinimumLength); UpdateConstants(); } } [CustomEffectProperty(PropertyType.Float, (int)PropertyIndex.FieldHeight)] - public float FieldHeight { get => _cb.FieldHeight; set { _cb.FieldHeight = Math.Max(value, 0.001f); UpdateConstants(); } } + public float FieldHeight { get => _cb.FieldHeight; set { _cb.FieldHeight = Math.Max(value, MinimumLength); UpdateConstants(); } } [CustomEffectProperty(PropertyType.Float, (int)PropertyIndex.ValueCount)] public float ValueCount { get => _cb.ValueCount; set { _cb.ValueCount = Math.Clamp(value, 0f, MaxValues); UpdateConstants(); } } [CustomEffectProperty(PropertyType.Float, (int)PropertyIndex.BlobRadius)] - public float BlobRadius { get => _cb.BlobRadius; set { _cb.BlobRadius = Math.Max(value, 0.001f); UpdateConstants(); } } + public float BlobRadius { get => _cb.BlobRadius; set { _cb.BlobRadius = Math.Max(value, MinimumLength); UpdateConstants(); } } [CustomEffectProperty(PropertyType.Float, (int)PropertyIndex.Threshold)] - public float Threshold { get => _cb.Threshold; set { _cb.Threshold = Math.Clamp(value, 0.001f, 0.999f); UpdateConstants(); } } + public float Threshold { get => _cb.Threshold; set { _cb.Threshold = Math.Clamp(value, MinimumThreshold, MaximumThreshold); UpdateConstants(); } } [CustomEffectProperty(PropertyType.Float, (int)PropertyIndex.RimThickness)] public float RimThickness { get => _cb.RimThickness; set { _cb.RimThickness = Math.Max(value, 0f); UpdateConstants(); } }