overlay wit sunset background

This commit is contained in:
Cameron Taylor 2021-08-27 13:16:31 -04:00
parent f6729592bf
commit 5baae3ad58
4 changed files with 21 additions and 39 deletions

View file

@ -1,33 +0,0 @@
package;
import flixel.system.FlxAssets.FlxShader;
class OverlayShader extends FlxShader
{
@:glFragmentSource('
#pragma header
uniform vec4 uBlendColor;
vec3 blendLighten(base:Vec3, blend:Vec3) : Vec3 {
return mix(
1.0 - 2.0 * (1.0 - base) * (1.0 - blend),
2.0 * base * blend,
step( base, vec3(0.5) )
);
}
vec4 blendLighten(vec4 base, vec4 blend, float opacity)
{
return (blendLighten(base, blend) * opacity + base * (1.0 - opacity));
}
void main()
{
vec4 base = texture2D(bitmap, openfl_TextureCoordv);
gl_FragColor = blendLighten(base, uBlendColor, uBlendColor.a);
}')
public function new()
{
super();
}
}

View file

@ -48,6 +48,7 @@ import openfl.utils.ByteArray;
import shaderslmfao.BuildingShaders.BuildingShader;
import shaderslmfao.BuildingShaders;
import shaderslmfao.ColorSwap;
import shaderslmfao.OverlayBlend;
import ui.PreferencesMenu;
using StringTools;
@ -290,6 +291,14 @@ class PlayState extends MusicBeatState
defaultCamZoom *= 0.90;
var skyBG:FlxSprite = new FlxSprite(-120, -50).loadGraphic(Paths.image('limo/limoSunset'));
var overlayShader:OverlayBlend = new OverlayBlend();
var sunOverlay:FlxSprite = new FlxSprite().loadGraphic(Paths.image('limo/limoOverlay'));
sunOverlay.setGraphicSize(Std.int(sunOverlay.width * 2));
sunOverlay.updateHitbox();
overlayShader.funnyShit.input = sunOverlay.pixels;
skyBG.shader = overlayShader;
skyBG.scrollFactor.set(0.1, 0.1);
add(skyBG);

View file

@ -35,6 +35,8 @@ class BuildingShader extends FlxShader
{
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
if (color.a > 0.0)
color -= alphaShit;

View file

@ -3,7 +3,7 @@ package shaderslmfao;
import flixel.math.FlxPoint;
import flixel.system.FlxAssets.FlxShader;
class TitleOutline extends FlxShader
class OverlayBlend extends FlxShader
{
// these r copypaste
public var funnyX(default, set):Float = 0;
@ -27,13 +27,15 @@ class TitleOutline extends FlxShader
#pragma header
uniform float alphaShit;
uniform float yPos;
uniform float xPos;
uniform sampler2D funnyShit;
vec3 blendOverlay(vec3 base, vec3 blend)
vec4 blendOverlay(vec4 base, vec4 blend)
{
return mix(1.0 - 2.0 * (1.0 - base) * (1.0 - blend), 2.0 * base * blend, step(base, vec3(0.5)));
return mix(1.0 - 2.0 * (1.0 - base) * (1.0 - blend), 2.0 * base * blend, step(base, vec4(0.5)));
}
void main()
@ -41,12 +43,14 @@ class TitleOutline extends FlxShader
vec2 funnyUv = openfl_TextureCoordv;
vec4 color = flixel_texture2D(bitmap, funnyUv);
vec4 gf = flixel_texture2D(funnyShit, openfl_TextureCoordv);
vec2 reallyFunnyUv = vec2(vec2(0.0, 0.0) - gl_FragCoord.xy / openfl_TextureSize.xy);
vec4 gf = flixel_texture2D(funnyShit, openfl_TextureCoordv.xy + vec2(0.1, 0.2));
vec3 mixedCol = blendOverlay(color.rgb, gf.rgb);
vec4 mixedCol = blendOverlay(gf, color);
gl_FragColor = vec4(mixedCol, color.a);
gl_FragColor = mixedCol;
}
')