Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting corner radius per corner #5959

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Feodor0090
Copy link
Contributor

@Feodor0090 Feodor0090 commented Aug 2, 2023

... i.e. now you can have 3 corners with radius 100 and the 4th with 10, for example.

Half-broken and non-mergeable at this state. Game probably won't run due to transforms.

If the direction is ok, i need help with bounding box calculation (now it calculates using the biggest radius) and uniforms buffer - there are too many paddings and idk how to rearrange the fields so nothing breaks.
Also, non-rounded borders and rounded renders in different manner so their combination looks weird. Didn't understand what to do with this too.
image
(bottom one is 0/50, top one is 5/50, notice the step where rounding begins)

xmldocs and interpolations will be done later. done

@bdach
Copy link
Collaborator

bdach commented Aug 2, 2023

Previously: #3652 (comment)

@Feodor0090
Copy link
Contributor Author

Feodor0090 commented Aug 3, 2023

image

While messing with edge effect rendering code, all that i managed to learn is that bottom-right quarter size is left unchanged from actual container size, and top-left quarters are growing in size so that glow "overrun" is equal to effect radius. Removing inflation in RectangleF effectRect = maskingInfo.Value.MaskingRect.Inflate(edgeEffect.Radius).Offset(edgeEffect.Offset); makes this work as expected, adding -Radius (shrinking) makes edge overruns to top-left quarter.

There is obviously something with either UV or g_MaskingRect, so i randomly did

diff --git a/osu.Framework/Resources/Shaders/sh_Masking.h b/osu.Framework/Resources/Shaders/sh_Masking.h
index e9190362a..68fd25ce1 100644
--- a/osu.Framework/Resources/Shaders/sh_Masking.h
+++ b/osu.Framework/Resources/Shaders/sh_Masking.h
@@ -63,7 +63,7 @@ lowp vec4 getBorderColour()
 
 highp float getCornerRadius()
 {
-       highp vec2 relativeTexCoord = v_MaskingPosition / (g_MaskingRect.zw - g_MaskingRect.xy);
+       highp vec2 relativeTexCoord = v_MaskingPosition / ((g_MaskingRect.zw - g_MaskingRect.xy)-vec2(g_MaskingBlendRange*2, g_MaskingBlendRange*2));
        highp float top = mix(g_CornerRadius.x, g_CornerRadius.z, step(0.5, relativeTexCoord.x));
        highp float bottom = mix(g_CornerRadius.y, g_CornerRadius.w, step(0.5, relativeTexCoord.x));
        return mix(top, bottom, step(0.5, relativeTexCoord.y));
@@ -71,7 +71,7 @@ highp float getCornerRadius()
 
 highp float getInnerCornerRadius()
 {
-       highp vec2 relativeTexCoord = v_MaskingPosition / (g_MaskingRect.zw - g_MaskingRect.xy);
+       highp vec2 relativeTexCoord = v_MaskingPosition / ((g_MaskingRect.zw - g_MaskingRect.xy)-vec2(g_MaskingBlendRange*2, g_MaskingBlendRange*2));
        highp float top = mix(g_InnerCornerRadius.x, g_InnerCornerRadius.z, step(0.5, relativeTexCoord.x));
        highp float bottom = mix(g_InnerCornerRadius.y, g_InnerCornerRadius.w, step(0.5, relativeTexCoord.x));
        return mix(top, bottom, step(0.5, relativeTexCoord.y));

and...
image
... it works?

Is this even a valid fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants