Add BlurScaleWithSize to BlurPanel for resolution-independent blur
This commit is contained in:
@@ -11,9 +11,15 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[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; }
|
||||
|
||||
/// <summary>
|
||||
/// If checked, the blur strength will be scaled with the control size, which makes it resolution-independent.
|
||||
/// </summary>
|
||||
[EditorOrder(10)]
|
||||
public bool BlurScaleWithSize { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BlurPanel"/> class.
|
||||
/// </summary>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user