Funkin/source/funkin/shaderslmfao/OverlayBlend.hx

70 lines
1.3 KiB
Haxe
Raw Normal View History

package funkin.shaderslmfao;
2021-08-27 02:42:23 -04:00
import flixel.math.FlxPoint;
import flixel.system.FlxAssets.FlxShader;
@:keep
2021-08-27 13:16:31 -04:00
class OverlayBlend extends FlxShader
2021-08-27 02:42:23 -04:00
{
// these r copypaste
public var funnyX(default, set):Float = 0;
public var funnyY(default, set):Float = 0;
2021-08-27 02:42:23 -04:00
function set_funnyX(x:Float):Float
{
xPos.value[0] = x;
2021-08-27 02:42:23 -04:00
return x;
}
2021-08-27 02:42:23 -04:00
function set_funnyY(y:Float):Float
{
yPos.value[0] = y;
2021-08-27 02:42:23 -04:00
return y;
}
2021-08-27 02:42:23 -04:00
@:glFragmentSource('
2021-08-27 02:42:23 -04:00
#pragma header
uniform float alphaShit;
2021-08-27 13:16:31 -04:00
uniform float yPos;
uniform float xPos;
2021-08-27 02:42:23 -04:00
uniform sampler2D funnyShit;
2021-08-27 13:16:31 -04:00
vec4 blendOverlay(vec4 base, vec4 blend)
2021-08-27 02:42:23 -04:00
{
2021-08-27 13:55:18 -04:00
vec4 mixed = mix(1.0 - 2.0 * (1.0 - base) * (1.0 - blend), 2.0 * base * blend, step(base, vec4(0.5)));
2021-08-27 18:08:01 -04:00
// mixed = mix(mixed, blend, base.a); // proper alpha mixing?
2021-08-27 13:55:18 -04:00
return mixed;
2021-08-27 02:42:23 -04:00
}
void main()
{
vec2 funnyUv = openfl_TextureCoordv;
vec4 color = flixel_texture2D(bitmap, funnyUv);
2023-06-08 16:30:45 -04:00
2021-08-27 13:16:31 -04:00
vec2 reallyFunnyUv = vec2(vec2(0.0, 0.0) - gl_FragCoord.xy / openfl_TextureSize.xy);
2021-08-27 02:42:23 -04:00
2021-08-27 13:16:31 -04:00
vec4 gf = flixel_texture2D(funnyShit, openfl_TextureCoordv.xy + vec2(0.1, 0.2));
2021-08-27 02:42:23 -04:00
2021-08-27 13:55:18 -04:00
vec4 mixedCol = blendOverlay(color, gf);
2021-08-27 13:16:31 -04:00
gl_FragColor = mixedCol;
2021-08-27 02:42:23 -04:00
}
')
public function new()
{
super();
2021-08-27 02:42:23 -04:00
xPos.value = [0];
yPos.value = [0];
}
2021-08-27 02:42:23 -04:00
}