1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-26 23:16:46 +00:00

screen wipe shader stuff testing

This commit is contained in:
Cameron Taylor 2021-09-11 14:08:34 -04:00
parent d13aa24fc8
commit f3bf578d4e
2 changed files with 87 additions and 0 deletions

View file

@ -16,6 +16,8 @@ import flixel.ui.FlxButton;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import lime.app.Application;
import openfl.filters.ShaderFilter;
import shaderslmfao.ScreenWipeShader;
import ui.AtlasMenuList;
import ui.MenuList;
import ui.OptionsState;
@ -250,6 +252,19 @@ class MainMenuState extends MusicBeatState
override function update(elapsed:Float)
{
if (FlxG.keys.justPressed.N)
{
var screenShit:FlxSprite = new FlxSprite().loadGraphic(Paths.image("shaderTransitionStuff/coolDots"));
var screenWipeShit:ScreenWipeShader = new ScreenWipeShader();
screenWipeShit.funnyShit.input = screenShit.pixels;
FlxTween.tween(screenWipeShit, {daAlphaShit: 1}, 2, {ease: FlxEase.quadInOut});
FlxG.camera.setFilters([new ShaderFilter(screenWipeShit)]);
}
if (FlxG.onMobile)
{
var touch:FlxTouch = FlxG.touches.getFirst();

View file

@ -0,0 +1,72 @@
package shaderslmfao;
import flixel.system.FlxAssets.FlxShader;
class ScreenWipeShader extends FlxShader
{
public var daAlphaShit(default, set):Float = 0;
function set_daAlphaShit(alpha:Float):Float
{
alphaShit.value[0] = alpha;
return alpha;
}
@:glFragmentSource('
#pragma header
uniform float alphaShit;
uniform float yPos;
uniform float xPos;
uniform sampler2D funnyShit;
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);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main()
{
vec2 funnyUv = openfl_TextureCoordv;
vec4 color = flixel_texture2D(bitmap, funnyUv);
vec2 reallyFunnyUv = vec2(vec2(0.0, 0.0) - gl_FragCoord.xy / openfl_TextureSize.xy);
vec4 gf = flixel_texture2D(funnyShit, openfl_TextureCoordv);
vec3 hsvTypeBeat = rgb2hsv(vec3(gf.r, gf.g, gf.b));
vec4 output = color;
// .b here actually means value?
if (hsvTypeBeat.b <= alphaShit)
color = vec4(0.0, 0.0, 0.0, 0.0);
gl_FragColor = color;
}
')
public function new()
{
super();
alphaShit.value = [0];
}
}