1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 19:33:36 +00:00
Funkin/source/funkin/graphics/shaders/TitleOutline.hx

75 lines
1.8 KiB
Haxe
Raw Normal View History

package funkin.graphics.shaders;
2021-08-17 05:20:00 +00:00
2021-08-19 03:00:39 +00:00
import flixel.math.FlxPoint;
2021-08-17 05:20:00 +00:00
import flixel.system.FlxAssets.FlxShader;
class TitleOutline extends FlxShader
{
public var funnyX(default, set):Float = 0;
public var funnyY(default, set):Float = 0;
2021-08-19 03:00:39 +00:00
function set_funnyX(x:Float):Float
{
xPos.value[0] = x;
2021-08-19 03:00:39 +00:00
return x;
}
2021-08-19 03:00:39 +00:00
function set_funnyY(y:Float):Float
{
yPos.value[0] = y;
2021-08-19 03:00:39 +00:00
return y;
}
2021-08-19 03:00:39 +00:00
@:glFragmentSource('
2021-08-17 05:20:00 +00:00
#pragma header
// uniform float alphaShit;
2021-08-19 03:00:39 +00:00
uniform float xPos;
uniform float yPos;
2021-08-17 05:20:00 +00:00
2021-08-19 18:53:18 +00:00
uniform int numoutlines = 1;
2021-08-17 05:20:00 +00:00
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);
2021-08-19 03:00:39 +00:00
vec2 size = vec2(xPos, yPos);
2021-08-17 05:20:00 +00:00
if (color.a == 0.0) {
float w = size.x / openfl_TextureSize.x;
float h = size.y / openfl_TextureSize.y;
2023-06-08 20:30:45 +00:00
2021-08-17 05:20:00 +00:00
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);
}
2023-06-08 20:30:45 +00:00
2021-08-17 05:20:00 +00:00
gl_FragColor = color;
}
')
public function new()
{
super();
2021-08-19 03:00:39 +00:00
xPos.value = [0];
yPos.value = [0];
}
2021-08-17 05:20:00 +00:00
}