2022-03-08 03:13:53 -05:00
|
|
|
package funkin.shaderslmfao;
|
2021-04-18 01:43:28 -04:00
|
|
|
|
|
|
|
import flixel.system.FlxAssets.FlxShader;
|
|
|
|
|
|
|
|
class BuildingShaders
|
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
public var shader(default, null):BuildingShaderLegacy;
|
2021-04-18 01:43:28 -04:00
|
|
|
|
|
|
|
public function new():Void
|
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
shader = new BuildingShaderLegacy();
|
|
|
|
shader.buildingAlpha = 0;
|
2021-04-18 01:43:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function update(elapsed:Float):Void
|
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
shader.buildingAlpha += elapsed;
|
2021-04-18 01:43:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function reset()
|
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
shader.buildingAlpha = 0;
|
2021-04-18 01:43:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 01:18:23 -04:00
|
|
|
class BuildingShader extends FlxRuntimeShader
|
2021-04-18 01:43:28 -04:00
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
public var buildingAlpha(get, set):Float;
|
|
|
|
|
|
|
|
function get_buildingAlpha():Float
|
|
|
|
{
|
|
|
|
return getFloat('alphaShit');
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_buildingAlpha(value:Float):Float
|
|
|
|
{
|
|
|
|
// Every time buildingAlpha is changed, update the property of the shader.
|
|
|
|
setFloat('alphaShit', value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static final FRAGMENT_SHADER = "
|
|
|
|
#pragma header
|
|
|
|
|
|
|
|
uniform float alphaShit;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
|
|
|
|
|
|
|
|
if (color.a > 0.0)
|
|
|
|
color -= alphaShit;
|
|
|
|
|
|
|
|
gl_FragColor = color;
|
|
|
|
}
|
|
|
|
";
|
|
|
|
|
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super(FRAGMENT_SHADER, null, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BuildingShaderLegacy extends FlxShader
|
|
|
|
{
|
|
|
|
public var buildingAlpha(get, set):Float;
|
|
|
|
|
|
|
|
function get_buildingAlpha():Float
|
|
|
|
{
|
|
|
|
return alphaShit.value[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_buildingAlpha(value:Float):Float
|
|
|
|
{
|
|
|
|
// Every time buildingAlpha is changed, update the property of the shader.
|
|
|
|
alphaShit.value = [value];
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:43:28 -04:00
|
|
|
@:glFragmentSource('
|
|
|
|
#pragma header
|
|
|
|
|
|
|
|
uniform float alphaShit;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
|
|
|
|
|
2021-08-27 13:16:31 -04:00
|
|
|
|
|
|
|
|
2021-04-18 01:43:28 -04:00
|
|
|
if (color.a > 0.0)
|
|
|
|
color -= alphaShit;
|
|
|
|
|
|
|
|
gl_FragColor = color;
|
|
|
|
}
|
|
|
|
|
|
|
|
')
|
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|