Created
September 30, 2021 15:25
-
-
Save shimeji87/1cc7a46c0abbd091c915a3591708b257 to your computer and use it in GitHub Desktop.
noise shader/tv static shader
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
package; | |
import flixel.system.FlxAssets.FlxShader; | |
// creds to shadertoy for the shader | |
// creds to halfbuzz for helpin with excluding transparency | |
class NoiseShader extends FlxShader { | |
@:glFragmentSource(" | |
#pragma header | |
uniform float iTime; | |
float Noise21 (vec2 p, float ta, float tb) { | |
return fract(sin(p.x*ta+p.y*tb)*5678.); | |
} | |
void main() | |
{ | |
vec2 uv = openfl_TextureCoordv.xy; | |
float t = iTime+123.; // tweak the start moment | |
float ta = t*.654321; | |
float tb = t*(ta*.123456); | |
float c = Noise21(uv, ta, tb); | |
vec3 col = vec3(c); | |
vec4 unmodifiedCol = flixel_texture2D(bitmap, openfl_TextureCoordv); | |
if(unmodifiedCol.a == 0.0){ | |
gl_FragColor = unmodifiedCol; | |
} else { | |
gl_FragColor = vec4(col,1.); | |
} | |
} | |
") | |
public function new() { | |
super(); | |
iTime.value = [0.0]; | |
} | |
public function update(elapsed:Float) { | |
if (!PauseSubState.paused) | |
iTime.value[0] += elapsed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
shadertoy link: https://www.shadertoy.com/view/tdXXRM