-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34e93fa
commit 03d9416
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package funkin.graphics.shaders; | ||
|
||
import flixel.system.FlxAssets.FlxShader; | ||
import flixel.util.FlxColor; | ||
import openfl.display.BitmapData; | ||
|
||
class TextureSwap extends FlxShader | ||
{ | ||
public var swappedImage(default, set):BitmapData; | ||
public var amount(default, set):Float; | ||
|
||
function set_swappedImage(_bitmapData:BitmapData):BitmapData | ||
{ | ||
image.input = _bitmapData; | ||
|
||
return _bitmapData; | ||
} | ||
|
||
function set_amount(val:Float):Float | ||
{ | ||
fadeAmount.value = [val]; | ||
|
||
return val; | ||
} | ||
|
||
@:glFragmentSource(' | ||
#pragma header | ||
|
||
uniform sampler2D image; | ||
uniform float fadeAmount; | ||
|
||
void main() | ||
{ | ||
vec4 tex = flixel_texture2D(bitmap, openfl_TextureCoordv); | ||
vec4 tex2 = flixel_texture2D(image, openfl_TextureCoordv); | ||
|
||
vec4 finalColor = mix(tex, vec4(tex2.rgb, tex.a), fadeAmount); | ||
|
||
gl_FragColor = finalColor; | ||
} | ||
') | ||
public function new() | ||
{ | ||
super(); | ||
|
||
this.amount = 1; | ||
} | ||
} |