Last active
August 29, 2015 14:22
-
-
Save valbeat/60362fff42724f59303a to your computer and use it in GitHub Desktop.
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
Shader "Custom/shock_wave" { | |
Properties { | |
} | |
SubShader { | |
Pass { | |
// GLSLシェーダ | |
GLSLPROGRAM | |
#ifdef VERTEX | |
void main() | |
{ | |
//頂点の設定 | |
// gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | |
gl_Position = ftransform(); | |
gl_TexCoord[0] = gl_MultiTexCoord0; | |
} | |
#endif | |
#ifdef FRAGMENT | |
uniform sampler2D sceneTex; | |
uniform vec2 center; | |
uniform float time; | |
uniform vec3 shockParams; | |
void main() | |
{ | |
vec2 uv = gl_TexCoord[0].xy; | |
vec2 texCoord = uv; | |
float distance = distance(uv, center); | |
if ((distance <= (time + shockParams.z)) && (distance >= (time - shockParams.z))) { | |
float diff = (distance - time); | |
float powDiff = 1.0 - pow(abs(diff * shockParams.x), shockParams.y); | |
float diffTime = diff * powDiff; | |
vec2 diffUV = normalize(uv - center); | |
texCoord = uv + (diffUV * diffTime); | |
} | |
gl_FlagColor = texture2D(sceneTex, texCoord); | |
} | |
#endif | |
ENDGLSL | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment