Skip to content

Commit

Permalink
feat: Added InverseDotsShader that emulates flash selections
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Oct 10, 2024
1 parent 8890cbf commit 097dbf5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions source/funkin/graphics/shaders/InverseDotsShader.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package funkin.graphics.shaders;

import flixel.addons.display.FlxRuntimeShader;

/**
* Create a little dotting effect.
*/
class InverseDotsShader extends FlxRuntimeShader
{
public function new()
{
super(Assets.getText(Paths.frag("InverseDots")));
}
}
4 changes: 2 additions & 2 deletions source/funkin/ui/title/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ class TitleState extends MusicBeatState
// maskShader.frameUV = gfDance.frame.uv;
// gfDance.shader = maskShader;

gfDance.shader = swagShader.shader;
// gfDance.shader = swagShader.shader;

// gfDance.shader = new TitleOutline();
gfDance.shader = new TitleOutline();

add(logoBl);

Expand Down

2 comments on commit 097dbf5

@NotHyper-474
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes cause the game crash on Linux (both C++ and HashLink targets):

Critical Error: Uncatchable Throw: [openfl.display.Shader] ERROR: Error compiling fragment shader
0:58(28): error: cannot initialize uniform numoutlines in GLSL ES 1.00 (GLSL 1.20 required)

#version 100
      
                                #ifdef GL_ES
                                #ifdef GL_FRAGMENT_PRECISION_HIGH
                                        precision highp float;
                                #else
                                        precision mediump float;
                                #endif
                                #endif

        varying float openfl_Alphav;
                varying vec4 openfl_ColorMultiplierv;
                varying vec4 openfl_ColorOffsetv;
                varying vec2 openfl_TextureCoordv;

                uniform bool openfl_HasColorTransform;
                uniform vec2 openfl_TextureSize;
                uniform sampler2D bitmap;

                uniform bool hasTransform;
                uniform bool hasColorTransform;

                vec4 flixel_texture2D(sampler2D bitmap, vec2 coord)
                {
                        vec4 color = texture2D(bitmap, coord);
                        if (!hasTransform)
                        {
                                return color;
                        }

                        if (color.a == 0.0)
                        {
                                return vec4(0.0, 0.0, 0.0, 0.0);
                        }

                        if (!hasColorTransform)
                        {
                                return color * openfl_Alphav;
                        }

                        color = vec4(color.rgb / color.a, color.a);

                        color = clamp(openfl_ColorOffsetv + (color * openfl_ColorMultiplierv), 0.0, 1.0);

                        if (color.a > 0.0)
                        {
                                return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
                        }
                        return vec4(0.0, 0.0, 0.0, 0.0);
                }



        // uniform float alphaShit;
        uniform float xPos;
        uniform float yPos;

        uniform int numoutlines = 1;

        vec3 rgb2hsv(vec3 c)
        {
            vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
            vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
            vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));

            float d = q.x - min(q.w, q.y);
            float e = 1.0e-10;
            return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
        }

        void main()
        {
            vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
            vec2 size = vec2(xPos, yPos);

            if (color.a == 0.0) {
                float w = size.x / openfl_TextureSize.x;
                float h = size.y / openfl_TextureSize.y;

                vec4 colorOffset = flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x - w, openfl_TextureCoordv.y - h));


                vec3 hsvShit = rgb2hsv(vec3(colorOffset.r, colorOffset.g, colorOffset.b));

                if (hsvShit.b <= 0.1 && colorOffset.a != 0.)
                    color = vec4(0.0, 1.0, 0.8, color.a);
            }

            gl_FragColor = color;
        }

    
Illegal instruction (core dumped)

@ninjamuffin99
Copy link
Member Author

@ninjamuffin99 ninjamuffin99 commented on 097dbf5 Oct 10, 2024 via email

Choose a reason for hiding this comment

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

Please sign in to comment.