2022-12-02 21:37:07 -05:00
|
|
|
package funkin.shaderslmfao;
|
|
|
|
|
2022-12-07 02:29:48 -05:00
|
|
|
import flixel.math.FlxRect;
|
2022-12-02 21:37:07 -05:00
|
|
|
import flixel.system.FlxAssets.FlxShader;
|
|
|
|
|
|
|
|
class LeftMaskShader extends FlxShader
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
public var swagMaskX(default, set):Float = 0;
|
|
|
|
public var swagSprX(default, set):Float = 0;
|
|
|
|
public var frameUV(default, set):FlxRect;
|
2022-12-02 21:37:07 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function set_swagSprX(x:Float):Float
|
|
|
|
{
|
|
|
|
sprX.value[0] = x;
|
2022-12-02 21:37:07 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
return x;
|
|
|
|
}
|
2022-12-02 21:37:07 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function set_swagMaskX(x:Float):Float
|
|
|
|
{
|
|
|
|
maskX.value[0] = x;
|
2022-12-02 21:37:07 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
return x;
|
|
|
|
}
|
2022-12-02 21:37:07 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function set_frameUV(uv:FlxRect):FlxRect
|
|
|
|
{
|
|
|
|
trace("SETTING FRAMEUV");
|
|
|
|
trace(uv);
|
2022-12-07 02:29:48 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
uvFrameX.value[0] = uv.x;
|
|
|
|
uvFrameY.value[0] = uv.y;
|
2022-12-07 02:29:48 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
return uv;
|
|
|
|
}
|
2022-12-07 02:29:48 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
@:glFragmentSource('
|
2022-12-02 21:37:07 -05:00
|
|
|
#pragma header
|
|
|
|
|
|
|
|
uniform float sprX;
|
|
|
|
uniform float maskX;
|
|
|
|
|
2022-12-07 02:29:48 -05:00
|
|
|
uniform float uvFrameX;
|
|
|
|
uniform float uvFrameY;
|
|
|
|
|
2022-12-02 21:37:07 -05:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
|
|
|
|
float cutOff = maskX - sprX;
|
|
|
|
float sprPos = cutOff / openfl_TextureSize.x;
|
|
|
|
|
|
|
|
vec2 uv = openfl_TextureCoordv.xy;
|
|
|
|
|
|
|
|
vec4 color = flixel_texture2D(bitmap, uv);
|
|
|
|
|
2022-12-07 02:29:48 -05:00
|
|
|
if (uv.x < sprPos + uvFrameX)
|
2022-12-02 21:37:07 -05:00
|
|
|
{
|
|
|
|
color = vec4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gl_FragColor = color;
|
2022-12-07 02:29:48 -05:00
|
|
|
// vec4 testCol = vec4(openfl_Position.x, openfl_Position.y, openfl_Position.z, 1.0);
|
|
|
|
//gl_FragColor = vec4(1.0, openfl_TextureSize.x, 1.0, 1.0);
|
|
|
|
|
2022-12-02 21:37:07 -05:00
|
|
|
}
|
|
|
|
')
|
2023-01-22 22:25:45 -05:00
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
|
|
|
sprX.value = [0];
|
|
|
|
maskX.value = [0];
|
|
|
|
uvFrameX.value = [0];
|
|
|
|
uvFrameY.value = [0];
|
|
|
|
}
|
2022-12-02 21:37:07 -05:00
|
|
|
}
|