Funkin/source/funkin/shaderslmfao/TitleOutline.hx

75 lines
1.8 KiB
Haxe
Raw Normal View History

package funkin.shaderslmfao;
2021-08-17 01:20:00 -04:00
2021-08-18 23:00:39 -04:00
import flixel.math.FlxPoint;
2021-08-17 01:20:00 -04:00
import flixel.system.FlxAssets.FlxShader;
class TitleOutline extends FlxShader
{
2021-08-18 23:00:39 -04:00
public var funnyX(default, set):Float = 0;
public var funnyY(default, set):Float = 0;
function set_funnyX(x:Float):Float
{
xPos.value[0] = x;
return x;
}
function set_funnyY(y:Float):Float
{
yPos.value[0] = y;
return y;
}
2021-08-17 01:20:00 -04:00
@:glFragmentSource('
#pragma header
// uniform float alphaShit;
2021-08-18 23:00:39 -04:00
uniform float xPos;
uniform float yPos;
2021-08-17 01:20:00 -04:00
2021-08-19 14:53:18 -04:00
uniform int numoutlines = 1;
2021-08-17 01:20:00 -04: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-18 23:00:39 -04:00
vec2 size = vec2(xPos, yPos);
2021-08-17 01:20:00 -04:00
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;
}
')
public function new()
{
super();
2021-08-18 23:00:39 -04:00
xPos.value = [0];
yPos.value = [0];
2021-08-17 01:20:00 -04:00
}
}