From 0366de36ce828294df877f15c7cf628cab5e6704 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 7 Feb 2023 14:13:02 +0100 Subject: [PATCH] Add `BlurScaleWithSize` to `BlurPanel` for resolution-independent blur --- Source/Engine/UI/GUI/Panels/BlurPanel.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/Engine/UI/GUI/Panels/BlurPanel.cs b/Source/Engine/UI/GUI/Panels/BlurPanel.cs index 8d4525113..0fe506e44 100644 --- a/Source/Engine/UI/GUI/Panels/BlurPanel.cs +++ b/Source/Engine/UI/GUI/Panels/BlurPanel.cs @@ -11,9 +11,15 @@ namespace FlaxEngine.GUI /// /// Gets or sets the blur strength. Defines how blurry the background is. Larger numbers increase blur, resulting in a larger runtime cost on the GPU. /// - [EditorOrder(0), Limit(0, 100, 0.0f), Tooltip("Blur strength defines how blurry the background is. Larger numbers increase blur, resulting in a larger runtime cost on the GPU.")] + [EditorOrder(0), Limit(0, 100, 0.0f)] public float BlurStrength { get; set; } + /// + /// If checked, the blur strength will be scaled with the control size, which makes it resolution-independent. + /// + [EditorOrder(10)] + public bool BlurScaleWithSize { get; set; } = false; + /// /// Initializes a new instance of the class. /// @@ -27,10 +33,13 @@ namespace FlaxEngine.GUI { base.Draw(); - float strength = BlurStrength; + var size = Size; + var strength = BlurStrength; + if (BlurScaleWithSize) + strength *= size.MinValue / 1000.0f; if (strength > Mathf.Epsilon) { - Render2D.DrawBlur(new Rectangle(Float2.Zero, Size), strength); + Render2D.DrawBlur(new Rectangle(Float2.Zero, size), strength); } } }