From f6729592bf3fc8c530153dfbea1b9d33a7d82a27 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 27 Aug 2021 02:42:23 -0400 Subject: [PATCH] multiply shader in progres --- source/TitleState.hx | 7 +++- source/shaderslmfao/MultiplyShader.hx | 31 ++++++++++++++ source/shaderslmfao/OverlayBlend.hx | 60 +++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 source/shaderslmfao/MultiplyShader.hx create mode 100644 source/shaderslmfao/OverlayBlend.hx diff --git a/source/TitleState.hx b/source/TitleState.hx index 49b8578dd..606ed3304 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -283,7 +283,6 @@ class TitleState extends MusicBeatState outlineShaderShit = new TitleOutline(); // logoBl.shader = swagShader.shader; // logoBl.shader = outlineShaderShit; - // logoBl.shader = alphaShader.shader; // trace(); // logoBl.screenCenter(); @@ -296,6 +295,12 @@ class TitleState extends MusicBeatState gfDance.antialiasing = true; add(gfDance); + // alphaShader.shader.funnyShit.input = gfDance.pixels; // old shit + + logoBl.shader = alphaShader.shader; + + // trace(alphaShader.shader.glFragmentSource) + // gfDance.shader = swagShader.shader; // gfDance.shader = new TitleOutline(); diff --git a/source/shaderslmfao/MultiplyShader.hx b/source/shaderslmfao/MultiplyShader.hx new file mode 100644 index 000000000..e86820ba1 --- /dev/null +++ b/source/shaderslmfao/MultiplyShader.hx @@ -0,0 +1,31 @@ +package; + +import flixel.system.FlxAssets.FlxShader; + +class MultiplyShader extends FlxShader +{ + @:glFragmentSource(' + #pragma header + uniform sampler2D funnyImage; + uniform vec4 uBlendColor; + + vec4 blendMultiply(vec4 base, vec4 blend) + { + return base * blend; + } + + vec4 blendMultiply(vec4 base, vec4 blend, float opacity) + { + return (blendMultiply(base, blend) * opacity + base * (1.0 - opacity)); + } + + void main() + { + vec4 base = texture2D(bitmap, openfl_TextureCoordv); + gl_FragColor = blendMultiply(base, uBlendColor, uBlendColor.a); + }') + public function new() + { + super(); + } +} \ No newline at end of file diff --git a/source/shaderslmfao/OverlayBlend.hx b/source/shaderslmfao/OverlayBlend.hx new file mode 100644 index 000000000..1cf74a02e --- /dev/null +++ b/source/shaderslmfao/OverlayBlend.hx @@ -0,0 +1,60 @@ +package shaderslmfao; + +import flixel.math.FlxPoint; +import flixel.system.FlxAssets.FlxShader; + +class TitleOutline extends FlxShader +{ + // these r copypaste + 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; + } + + @:glFragmentSource(' + #pragma header + + uniform float alphaShit; + + uniform sampler2D funnyShit; + + + vec3 blendOverlay(vec3 base, vec3 blend) + { + return mix(1.0 - 2.0 * (1.0 - base) * (1.0 - blend), 2.0 * base * blend, step(base, vec3(0.5))); + } + + void main() + { + vec2 funnyUv = openfl_TextureCoordv; + vec4 color = flixel_texture2D(bitmap, funnyUv); + + vec4 gf = flixel_texture2D(funnyShit, openfl_TextureCoordv); + + + vec3 mixedCol = blendOverlay(color.rgb, gf.rgb); + + gl_FragColor = vec4(mixedCol, color.a); + } + + ') + public function new() + { + super(); + + xPos.value = [0]; + yPos.value = [0]; + } +}