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

CircularBlob shader improvements #5491

Merged
merged 3 commits into from
Oct 28, 2022
Merged

CircularBlob shader improvements #5491

merged 3 commits into from
Oct 28, 2022

Conversation

EVAST9919
Copy link
Contributor

  • pointCount is based on input parameters now (in ctb case should become around 10 instead of 50)
  • Removed early loop exit as suggested

@peppy peppy self-requested a review October 28, 2022 07:57
@peppy
Copy link
Member

peppy commented Oct 28, 2022

This crashes for me again.

[runtime] 2022-10-28 08:08:09 [error]: An unhandled error has occurred.
[runtime] 2022-10-28 08:08:09 [error]: osu.Framework.Graphics.OpenGL.Shaders.GLShader+PartCompilationFailedException: A osu.Framework.Graphics.OpenGL.Shaders.GLShaderPart failed to compile: sh_CircularBlob.fs:
[runtime] 2022-10-28 08:08:09 [error]: ERROR: 0:121: '<' does not operate on 'int' and 'float'

Here's a solution

diff --git a/osu.Framework/Resources/Shaders/sh_CircularBlobUtils.h b/osu.Framework/Resources/Shaders/sh_CircularBlobUtils.h
index dec834f0d..fc03d8972 100644
--- a/osu.Framework/Resources/Shaders/sh_CircularBlobUtils.h
+++ b/osu.Framework/Resources/Shaders/sh_CircularBlobUtils.h
@@ -24,7 +24,7 @@ highp float noise(highp vec2 st)
 }
 
 lowp float blobAlphaAt(highp vec2 pixelPos, mediump float innerRadius, highp float texelSize, mediump float frequency, mediump float amplitude, int seed)
-{    
+{
     // Compute angle of the current pixel in the (0, 2*PI) range
     mediump float pixelAngle = atan(0.5 - pixelPos.y, 0.5 - pixelPos.x) - HALF_PI;
     if (pixelAngle < 0.0)
@@ -32,7 +32,7 @@ lowp float blobAlphaAt(highp vec2 pixelPos, mediump float innerRadius, highp flo
 
     mediump float complexity = (frequency + amplitude) * 0.5 + 1.0;
 
-    mediump float pointCount = 5.0 * complexity;
+    int pointCount = int(5.0 * complexity);
     mediump float searchRange = 0.1 * complexity; // in radians
 
     mediump float pathRadius = innerRadius * 0.25;
@@ -48,7 +48,7 @@ lowp float blobAlphaAt(highp vec2 pixelPos, mediump float innerRadius, highp flo
     // Plot points within a search range and check which one is closest
     for (int i = 0; i < pointCount; i++)
     {
-        mediump float angle = startAngle + searchRange * float(i) / pointCount;
+        mediump float angle = startAngle + searchRange * float(i) / float(pointCount);
         highp vec2 cs = vec2(cos(angle - HALF_PI), sin(angle - HALF_PI));
 
         highp float noiseValue = noise(noisePosition + cs * vec2(frequency));
@@ -56,6 +56,6 @@ lowp float blobAlphaAt(highp vec2 pixelPos, mediump float innerRadius, highp flo
 
         shortestDistance = min(shortestDistance, distance(pixelPos, pos));
     }
-    
+
     return smoothstep(texelSize, 0.0, shortestDistance - pathRadius);
 }

Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As proposed

@peppy
Copy link
Member

peppy commented Oct 28, 2022

In testing, it looks like the point count multiplier could potentially be dropped further, but if so, it also needs to factor in the innerRadius, as dropping it too low with a thin radius will cause the line to completely disappear.

Might be worth experimenting further, but I think with the proposed crash fix this is good enough to get in for further performance testing.

@peppy peppy self-requested a review October 28, 2022 08:22
@peppy peppy enabled auto-merge October 28, 2022 08:23
@peppy peppy merged commit 05f461d into ppy:master Oct 28, 2022
@EVAST9919 EVAST9919 deleted the blob-quick-fix branch October 28, 2022 08:58
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