Hi,
It took me awhile till I had it working.
Im sure he found the shader at:
http://www.geeks3d.com/20091116/shader-library-2d-shockwave-post-processing-filter-glsl/
Now to the code:
Main.agc
SetWindowTitle( "test" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 640, 480 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetPrintColor(0,0,0)
SetSyncRate(0,0)
ImageID=loadimage("grid.jpg")
SpriteID=createsprite(ImageID)
//ShaderID=LoadSpriteShader("pixel.ps" )
ShaderID=LoadShader("Vertex.vs", "pixel.ps" )
SetSpriteShader(SpriteID,ShaderID)
setShaderConstantByName(ShaderID, "center",0.5,0.5,0.1,0)
setShaderConstantByName(ShaderID, "shockParams",10.0, 0.8, 0.05,0 )
do
if getpointerpressed()=1
setShaderConstantByName(ShaderID, "center", GetPointerX()/GetImageWidth(ImageID),GetPointerY()/GetImageHeight(ImageID),0,0)
Time#=0.0
endif
Time#=Time#+0.5*getframetime()
setShaderConstantByName(ShaderID, "time",Time#,0,0,0)
Print( ScreenFPS() )
print(Time#)
Sync()
loop
Vertex.vs
attribute vec4 position;
attribute vec4 color;
attribute vec2 uv;
varying vec2 uvVarying;
varying vec4 colorVarying;
varying vec2 posVarying;
uniform mat4 agk_Ortho;
void main()
{
gl_Position = agk_Ortho * position;
posVarying = position.xy;
uvVarying = uv;
colorVarying = color;
}
Pixel.ps
uniform sampler2D texture0;
varying vec2 uvVarying;
varying vec2 posVarying;
uniform vec2 agk_resolution;
uniform vec2 center; // Mouse position
uniform float time; // effect elapsed time
uniform vec3 shockParams; // 10.0, 0.8, 0.1
void main()
{
vec2 uv = uvVarying.xy;
vec2 texCoord = uv;
float dist = distance(uv, center);
if ((dist >= (time - shockParams.z)) && (dist <= (time + shockParams.z)))
{
float diff = (dist - 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_FragColor = texture2D(texture0, texCoord);
}
Picture
</div>