1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

Merge pull request #26647 from EVAST9919/triangles-masking

Enable masking for `Triangles` backgrounds where possible
This commit is contained in:
Dean Herbert 2024-01-21 12:20:40 +09:00 committed by GitHub
commit b588715d21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 15 additions and 12 deletions

View File

@ -15,6 +15,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
{
TriangleScale = 1.2f;
HideAlphaDiscrepancies = false;
ClampToDrawable = false;
}
protected override void Update()

View File

@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.Background
AddSliderStep("Triangle scale", 0f, 10f, 1f, s => triangles.TriangleScale = s);
AddSliderStep("Seed", 0, 1000, 0, s => triangles.Reset(s));
AddToggleStep("Masking", m => triangles.Masking = m);
AddToggleStep("ClampToDrawable", c => triangles.ClampToDrawable = c);
}
}
}

View File

@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual.Background
AddStep("White colour", () => box.Colour = triangles.Colour = maskedTriangles.Colour = Color4.White);
AddStep("Vertical gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientVertical(Color4.White, Color4.Red));
AddStep("Horizontal gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.Red));
AddToggleStep("Masking", m => maskedTriangles.Masking = m);
AddToggleStep("ClampToDrawable", c => maskedTriangles.ClampToDrawable = c);
}
}
}

View File

@ -78,9 +78,9 @@ namespace osu.Game.Graphics.Backgrounds
/// <summary>
/// If enabled, only the portion of triangles that falls within this <see cref="Drawable"/>'s
/// shape is drawn to the screen.
/// shape is drawn to the screen. Default is true.
/// </summary>
public bool Masking { get; set; }
public bool ClampToDrawable { get; set; } = true;
/// <summary>
/// Whether we should drop-off alpha values of triangles more quickly to improve
@ -257,7 +257,7 @@ namespace osu.Game.Graphics.Backgrounds
private IShader shader;
private Texture texture;
private bool masking;
private bool clamp;
private readonly List<TriangleParticle> parts = new List<TriangleParticle>();
private readonly Vector2 triangleSize = new Vector2(1f, equilateral_triangle_ratio) * triangle_size;
@ -276,7 +276,7 @@ namespace osu.Game.Graphics.Backgrounds
shader = Source.shader;
texture = Source.texture;
size = Source.DrawSize;
masking = Source.Masking;
clamp = Source.ClampToDrawable;
parts.Clear();
parts.AddRange(Source.parts);
@ -306,7 +306,7 @@ namespace osu.Game.Graphics.Backgrounds
Vector2 topLeft = particle.Position - new Vector2(relativeSize.X * 0.5f, 0f);
Quad triangleQuad = masking ? clampToDrawable(topLeft, relativeSize) : new Quad(topLeft.X, topLeft.Y, relativeSize.X, relativeSize.Y);
Quad triangleQuad = clamp ? clampToDrawable(topLeft, relativeSize) : new Quad(topLeft.X, topLeft.Y, relativeSize.X, relativeSize.Y);
var drawQuad = new Quad(
Vector2Extensions.Transform(triangleQuad.TopLeft * size, DrawInfo.Matrix),

View File

@ -34,9 +34,9 @@ namespace osu.Game.Graphics.Backgrounds
/// <summary>
/// If enabled, only the portion of triangles that falls within this <see cref="Drawable"/>'s
/// shape is drawn to the screen.
/// shape is drawn to the screen. Default is true.
/// </summary>
public bool Masking { get; set; }
public bool ClampToDrawable { get; set; } = true;
private readonly BindableFloat spawnRatio = new BindableFloat(1f);
@ -193,7 +193,7 @@ namespace osu.Game.Graphics.Backgrounds
private Vector2 size;
private float thickness;
private float texelSize;
private bool masking;
private bool clamp;
public TrianglesDrawNode(TrianglesV2 source)
: base(source)
@ -208,7 +208,7 @@ namespace osu.Game.Graphics.Backgrounds
texture = Source.texture;
size = Source.DrawSize;
thickness = Source.Thickness;
masking = Source.Masking;
clamp = Source.ClampToDrawable;
Quad triangleQuad = new Quad(
Vector2Extensions.Transform(Vector2.Zero, DrawInfo.Matrix),
@ -248,7 +248,7 @@ namespace osu.Game.Graphics.Backgrounds
{
Vector2 topLeft = particle.Position - new Vector2(relativeSize.X * 0.5f, 0f);
Quad triangleQuad = masking ? clampToDrawable(topLeft, relativeSize) : new Quad(topLeft.X, topLeft.Y, relativeSize.X, relativeSize.Y);
Quad triangleQuad = clamp ? clampToDrawable(topLeft, relativeSize) : new Quad(topLeft.X, topLeft.Y, relativeSize.X, relativeSize.Y);
var drawQuad = new Quad(
Vector2Extensions.Transform(triangleQuad.TopLeft * size, DrawInfo.Matrix),

View File

@ -150,6 +150,7 @@ namespace osu.Game.Graphics.UserInterface
TriangleScale = 4,
ColourDark = OsuColour.Gray(0.88f),
Shear = new Vector2(-0.2f, 0),
ClampToDrawable = false
},
},
},

View File

@ -95,6 +95,7 @@ namespace osu.Game.Overlays.Mods
Height = header_height,
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Velocity = 0.7f,
ClampToDrawable = false
},
headerText = new OsuTextFlowContainer(t =>
{