1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-30 16:56:47 +00:00
Funkin/source/funkin/graphics/shaders/LeftMaskShader.hx

77 lines
1.5 KiB
Haxe
Raw Normal View History

package funkin.graphics.shaders;
2022-12-03 02:37:07 +00:00
2022-12-07 07:29:48 +00:00
import flixel.math.FlxRect;
2022-12-03 02:37:07 +00:00
import flixel.system.FlxAssets.FlxShader;
class LeftMaskShader extends FlxShader
{
public var swagMaskX(default, set):Float = 0;
public var swagSprX(default, set):Float = 0;
public var frameUV(default, set):FlxRect;
2022-12-03 02:37:07 +00:00
function set_swagSprX(x:Float):Float
{
sprX.value[0] = x;
2022-12-03 02:37:07 +00:00
return x;
}
2022-12-03 02:37:07 +00:00
function set_swagMaskX(x:Float):Float
{
maskX.value[0] = x;
2022-12-03 02:37:07 +00:00
return x;
}
2022-12-03 02:37:07 +00:00
function set_frameUV(uv:FlxRect):FlxRect
{
trace("SETTING FRAMEUV");
trace(uv);
2022-12-07 07:29:48 +00:00
uvFrameX.value[0] = uv.x;
uvFrameY.value[0] = uv.y;
2022-12-07 07:29:48 +00:00
return uv;
}
2022-12-07 07:29:48 +00:00
@:glFragmentSource('
2022-12-03 02:37:07 +00:00
#pragma header
uniform float sprX;
uniform float maskX;
2022-12-07 07:29:48 +00:00
uniform float uvFrameX;
uniform float uvFrameY;
2022-12-03 02:37:07 +00: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 07:29:48 +00:00
if (uv.x < sprPos + uvFrameX)
2022-12-03 02:37:07 +00:00
{
color = vec4(0.0, 0.0, 0.0, 0.0);
}
gl_FragColor = color;
2022-12-07 07:29:48 +00: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-03 02:37:07 +00:00
}
')
public function new()
{
super();
sprX.value = [0];
maskX.value = [0];
uvFrameX.value = [0];
uvFrameY.value = [0];
}
2022-12-03 02:37:07 +00:00
}