Skip to content

Instantly share code, notes, and snippets.

@jimmyjonezz
Created January 2, 2020 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmyjonezz/7866f962c10a2c77c094fe76e093fd4f to your computer and use it in GitHub Desktop.
Save jimmyjonezz/7866f962c10a2c77c094fe76e093fd4f to your computer and use it in GitHub Desktop.
shader_type canvas_item;
uniform float _PI = 3.1415926535897932384626433832795;
uniform float xx = 4.0;
uniform float yy = 2.0;
vec2 getPixelShift(vec2 center,vec2 pixelpos,float startradius,float size,float shockfactor, vec2 iResolution) {
float m_distance = distance(center,pixelpos);
if( m_distance > startradius && m_distance < startradius+size ) {
float sin_dist = sin((m_distance -startradius)/size* _PI )*shockfactor;
return ( pixelpos - normalize(pixelpos-center)*sin_dist )/ iResolution.xy;
} else
return pixelpos / iResolution.xy;
}
void fragment() {
vec2 iResolution = (1.0 / SCREEN_PIXEL_SIZE);
vec2 shockcenter1 = vec2(iResolution.x / xx, iResolution.y / xx * yy);
float startradius = mod(TIME , 1.0) * 600.0;
float size = mod(TIME , 1.0) * 200.0;
float shockfactor = 50.0 - mod(TIME , 1.0) * 50.0;
vec2 total_shift = getPixelShift(shockcenter1, FRAGCOORD.xy,startradius,size,20.0,iResolution);
// getPixelShift(shockcenter2,FRAGCOORD.xy,startradius,size,20.0,iResolution);
COLOR = texture(SCREEN_TEXTURE,total_shift);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment