diff --git a/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.SliderPathDrawNode.cs b/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.SliderPathDrawNode.cs index adc37be1..8a1b8fa9 100644 --- a/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.SliderPathDrawNode.cs +++ b/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.SliderPathDrawNode.cs @@ -57,10 +57,8 @@ public record struct SliderTexturedVertex2D : IVertex private Vector2 drawSize; private float radius; private IShader shader; - private IShader maskShader; private IUniformBuffer shaderData; - private IUniformBuffer maskData; [StructLayout(LayoutKind.Sequential, Pack = 1)] private record struct SliderUniform @@ -79,14 +77,6 @@ private record struct SliderUniform private UniformPadding4 _p4; } - [StructLayout(LayoutKind.Sequential, Pack = 1)] - private record struct MaskUniform - { - public UniformBool WriteDepth; - - private UniformPadding12 _p1; - } - // We multiply the size param by 3 such that the amount of vertices is a multiple of the amount of vertices // per primitive (triangles in this case). Otherwise overflowing the batch will result in wrong // grouping of vertices into primitives. @@ -128,7 +118,6 @@ public override void ApplyState() drawSize = Source.DrawSize; radius = Source.PathRadius; shader = Source.hitFadeTextureShader; - maskShader = Source.depthMaskShader; var center = Source.PositionInBoundingBox(Vector2.Zero); var edge = Source.PositionInBoundingBox(new Vector2(Source.PathDistance, 0)); @@ -360,7 +349,7 @@ public override void Draw(IRenderer renderer) Reverse = reverse }; - maskData ??= renderer.CreateUniformBuffer(); + //maskData ??= renderer.CreateUniformBuffer(); halfCircleBatch ??= renderer.CreateLinearBatch(max_resolution * 100 * 3, 10, PrimitiveTopology.Triangles); quadBatch ??= renderer.CreateQuadBatch(200, 10); @@ -368,39 +357,32 @@ public override void Draw(IRenderer renderer) if (texture?.Available != true || segments.Length == 0) return; - renderer.PushDepthInfo(new DepthInfo(depthTest: true, writeDepth: true, function: BufferTestFunction.Always)); - maskData.Data = maskData.Data with { WriteDepth = true }; - maskShader.Bind(); - maskShader.BindUniformBlock("m_maskParameters", maskData); + shader.Bind(); + shader.BindUniformBlock("m_sliderParameters", shaderData); + + renderer.PushStencilInfo(new StencilInfo(stencilTest: true, testValue: 255, testFunction: BufferTestFunction.Always, passed: StencilOperation.Replace)); foreach (var i in innerTicks) { renderer.DrawQuad(renderer.WhitePixel, i, Color4.Transparent); } - maskShader.Unbind(); - renderer.PopDepthInfo(); + renderer.PopStencilInfo(); + renderer.PushStencilInfo(new StencilInfo(stencilTest: true, testValue: 255, testFunction: BufferTestFunction.NotEqual, passed: StencilOperation.Keep)); - shader.Bind(); - shader.BindUniformBlock("m_sliderParameters", shaderData); texture.Bind(); - updateVertexBuffer(); - shader.Unbind(); - - renderer.PushDepthInfo(new DepthInfo(depthTest: true, writeDepth: true, function: BufferTestFunction.Always)); - maskData.Data = maskData.Data with { WriteDepth = false }; - maskShader.Bind(); - maskShader.BindUniformBlock("m_maskParameters", maskData); - + // not needed right now, but it clears the stencil mask + renderer.PushStencilInfo(new StencilInfo(stencilTest: true, testValue: 0, testFunction: BufferTestFunction.Always, passed: StencilOperation.Replace)); foreach (var i in innerTicks) { renderer.DrawQuad(renderer.WhitePixel, i, Color4.Transparent); } + renderer.PopStencilInfo(); - maskShader.Unbind(); - renderer.PopDepthInfo(); + renderer.PopStencilInfo(); + shader.Unbind(); } protected override void Dispose(bool isDisposing) @@ -408,7 +390,6 @@ protected override void Dispose(bool isDisposing) base.Dispose(isDisposing); shaderData?.Dispose(); - maskData?.Dispose(); halfCircleBatch?.Dispose(); quadBatch?.Dispose(); segments.Dispose(); diff --git a/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.cs b/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.cs index 9dc8434a..33005786 100644 --- a/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.cs +++ b/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableSlider.Graphics.cs @@ -42,7 +42,6 @@ private static Texture generateSmoothPathTexture(IRenderer renderer, float radiu public partial class SliderPath : Drawable { public IEnumerable Ticks = Array.Empty(); - private IShader depthMaskShader { get; set; } private IShader hitFadeTextureShader { get; set; } private readonly List vertices = new(); @@ -220,7 +219,6 @@ private void load(IRenderer renderer, ShaderManager shaders) { texture = renderer.WhitePixel; - depthMaskShader = shaders.Load("DepthMask", "DepthMask"); hitFadeTextureShader = shaders.Load("SliderPositionAndColour", "Slider"); } diff --git a/osu.Game.Rulesets.Tau/Resources/Shaders/sh_DepthMask.fs b/osu.Game.Rulesets.Tau/Resources/Shaders/sh_DepthMask.fs deleted file mode 100644 index 1e6e7d1c..00000000 --- a/osu.Game.Rulesets.Tau/Resources/Shaders/sh_DepthMask.fs +++ /dev/null @@ -1,32 +0,0 @@ -// this shader can be used to disallow drawing over a certain region of screen -// creating a "mask" or a "substract" union between 2 shapes -// to use it: -// writeDepth = true; -// GLWrapper.PushDepthInfo( new DepthInfo( depthTest: true, writeDepth: true, function: DepthFunction.Always ) ); -// DrawMaskShape(); -// GLWrapper.PopDepthInfo(); -// ... // draw with different shader -// after this step, you are left with the mask still there. -// to erase it: -// writeDepth = false; -// GLWrapper.PushDepthInfo( new DepthInfo( depthTest: true, writeDepth: true, function: DepthFunction.Always ) ); -// DrawMaskShape(); -// GLWrapper.PopDepthInfo(); - -layout(location = 0) out vec4 o_colour; - -layout(std140, set = 0, binding = 0) uniform m_maskParameters { - bool writeDepth; -}; - -void main(void) -{ - o_colour = vec4(0.0, 0.0, 0.0, 0.0); - - if (writeDepth) { - gl_FragDepth = 0.0; - } - else { - gl_FragDepth = 1.0; - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Tau/Resources/Shaders/sh_DepthMask.vs b/osu.Game.Rulesets.Tau/Resources/Shaders/sh_DepthMask.vs deleted file mode 100644 index 8287e125..00000000 --- a/osu.Game.Rulesets.Tau/Resources/Shaders/sh_DepthMask.vs +++ /dev/null @@ -1,6 +0,0 @@ -layout(location = 0) in highp vec2 m_Position; - -void main(void) -{ - gl_Position = g_ProjMatrix * vec4(m_Position.xy, 1.0, 1.0); -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Tau/osu.Game.Rulesets.Tau.csproj b/osu.Game.Rulesets.Tau/osu.Game.Rulesets.Tau.csproj index ec727086..d35d0824 100644 --- a/osu.Game.Rulesets.Tau/osu.Game.Rulesets.Tau.csproj +++ b/osu.Game.Rulesets.Tau/osu.Game.Rulesets.Tau.csproj @@ -34,10 +34,6 @@ UI.resx - - - -