Skip to content

Instantly share code, notes, and snippets.

@01010111
Created December 4, 2018 02:41
Show Gist options
  • Save 01010111/69e935f400154a3e751ecfe417424886 to your computer and use it in GitHub Desktop.
Save 01010111/69e935f400154a3e751ecfe417424886 to your computer and use it in GitHub Desktop.
Color replacement shader
package;
import flixel.system.FlxAssets;
import flixel.util.FlxColor;
class Shader extends FlxShader
{
@:glFragmentSource('
#pragma header
uniform float uMix;
uniform vec4 color;
void main()
{
vec4 sample = flixel_texture2D(bitmap, openfl_TextureCoordv);
gl_FragColor = mix(sample, color, uMix * sample.a);
}'
)
public function new(color:FlxColor = 0xFFFFFFFF)
{
super();
this.color.value = [color.redFloat, color.greenFloat, color.blueFloat, color.alphaFloat];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment