diff --git a/Source/Engine/UI/GUI/Brushes/GPUTextureBrush.cs b/Source/Engine/UI/GUI/Brushes/GPUTextureBrush.cs
index f91e3dfe3..77ad80758 100644
--- a/Source/Engine/UI/GUI/Brushes/GPUTextureBrush.cs
+++ b/Source/Engine/UI/GUI/Brushes/GPUTextureBrush.cs
@@ -14,6 +14,12 @@ namespace FlaxEngine.GUI
[HideInEditor]
public GPUTexture Texture;
+ ///
+ /// The texture sampling filter mode.
+ ///
+ [ExpandGroups, Tooltip("The texture sampling filter mode.")]
+ public BrushFilter Filter = BrushFilter.Linear;
+
///
/// Initializes a new instance of the class.
///
@@ -36,7 +42,10 @@ namespace FlaxEngine.GUI
///
public void Draw(Rectangle rect, Color color)
{
- Render2D.DrawTexture(Texture, rect, color);
+ if (Filter == BrushFilter.Point)
+ Render2D.DrawTexturePoint(Texture, rect, color);
+ else
+ Render2D.DrawTexture(Texture, rect, color);
}
}
}
diff --git a/Source/Engine/UI/GUI/Brushes/IBrush.cs b/Source/Engine/UI/GUI/Brushes/IBrush.cs
index ec5ba420a..5e4df2694 100644
--- a/Source/Engine/UI/GUI/Brushes/IBrush.cs
+++ b/Source/Engine/UI/GUI/Brushes/IBrush.cs
@@ -2,6 +2,24 @@
namespace FlaxEngine.GUI
{
+ ///
+ /// Texture brush sampling modes.
+ ///
+ public enum BrushFilter
+ {
+ ///
+ /// The point sampling without blending.
+ ///
+ [Tooltip("The point sampling without blending.")]
+ Point = 0,
+
+ ///
+ /// The linear color sampling.
+ ///
+ [Tooltip("The linear color sampling.")]
+ Linear = 1,
+ };
+
///
/// Interface that unifies input source textures, sprites, render targets, and any other brushes to be used in a more generic way.
///
diff --git a/Source/Engine/UI/GUI/Brushes/SpriteBrush.cs b/Source/Engine/UI/GUI/Brushes/SpriteBrush.cs
index 9867e1f25..05c0bb2e2 100644
--- a/Source/Engine/UI/GUI/Brushes/SpriteBrush.cs
+++ b/Source/Engine/UI/GUI/Brushes/SpriteBrush.cs
@@ -11,9 +11,15 @@ namespace FlaxEngine.GUI
///
/// The sprite.
///
- [ExpandGroups]
+ [ExpandGroups, EditorOrder(0), Tooltip("The sprite.")]
public SpriteHandle Sprite;
+ ///
+ /// The texture sampling filter mode.
+ ///
+ [ExpandGroups, EditorOrder(1), Tooltip("The texture sampling filter mode.")]
+ public BrushFilter Filter = BrushFilter.Linear;
+
///
/// Initializes a new instance of the class.
///
@@ -36,7 +42,10 @@ namespace FlaxEngine.GUI
///
public void Draw(Rectangle rect, Color color)
{
- Render2D.DrawSprite(Sprite, rect, color);
+ if (Filter == BrushFilter.Point)
+ Render2D.DrawSpritePoint(Sprite, rect, color);
+ else
+ Render2D.DrawSprite(Sprite, rect, color);
}
}
}
diff --git a/Source/Engine/UI/GUI/Brushes/TextureBrush.cs b/Source/Engine/UI/GUI/Brushes/TextureBrush.cs
index 118128c71..1f772e0a6 100644
--- a/Source/Engine/UI/GUI/Brushes/TextureBrush.cs
+++ b/Source/Engine/UI/GUI/Brushes/TextureBrush.cs
@@ -1,5 +1,7 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
+using System;
+
namespace FlaxEngine.GUI
{
///
@@ -11,9 +13,15 @@ namespace FlaxEngine.GUI
///
/// The texture.
///
- [ExpandGroups, Tooltip("The texture asset.")]
+ [ExpandGroups, EditorOrder(0), Tooltip("The texture asset.")]
public Texture Texture;
+ ///
+ /// The texture sampling filter mode.
+ ///
+ [ExpandGroups, EditorOrder(1), Tooltip("The texture sampling filter mode.")]
+ public BrushFilter Filter = BrushFilter.Linear;
+
///
/// Initializes a new instance of the class.
///
@@ -36,7 +44,10 @@ namespace FlaxEngine.GUI
///
public void Draw(Rectangle rect, Color color)
{
- Render2D.DrawTexture(Texture, rect, color);
+ if (Filter == BrushFilter.Point)
+ Render2D.DrawTexturePoint(Texture?.Texture, rect, color);
+ else
+ Render2D.DrawTexture(Texture, rect, color);
}
}
}